| 159 | |
| 160 | template <typename ThriftStruct> |
| 161 | std::string ThriftDebugString(const ThriftStruct& ts) { |
| 162 | using namespace apache::thrift::transport; |
| 163 | using namespace apache::thrift::protocol; |
| 164 | auto* buffer = new TMemoryBuffer; |
| 165 | std::shared_ptr<TTransport> trans(buffer); |
| 166 | TDebugProtocol protocol(trans); |
| 167 | |
| 168 | ts.write(&protocol); |
| 169 | |
| 170 | uint8_t* buf; |
| 171 | uint32_t size; |
| 172 | buffer->getBuffer(&buf, &size); |
| 173 | return std::string((char*)buf, (unsigned int)size); |
| 174 | } |
| 175 | |
| 176 | // TODO(dreiss): This is badly broken. Don't use it unless you are me. |
| 177 | #if 0 |