bool StringToThrift(ThriftStruct & ts, cf_cpstr buf, cf_int bufLen) { using namespace apache::thrift::transport; using namespace apache::thrift::protocol; TMemoryBuffer * pmembuffer = new TMemoryBuffer; pmembuffer->write((cf_const uint8_t *)buf, size_t(bufLen)); shared_ptr<TMemoryBuffer> membuffer(pmembuffer); shared_ptr<TProtocol> protocol(new TBinaryProtocol(membuffer)); ts.read(protocol.get()); return true; }
static bool StringToThrift(const std::string& buff, \ ThriftStruct* ts) { using namespace apache::thrift::transport; using namespace apache::thrift::protocol; TMemoryBuffer* buffer = new TMemoryBuffer; buffer->write((const uint8_t*)buff.data(), buff.size()); boost::shared_ptr<TTransport> trans(buffer); TBinaryProtocol protocol(trans); ts->read(&protocol); return true; }