Having come from the Java world where I can do: /ByteArrayOutputStream out = new ByteArrayOutputStream(); BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(out, null); SpecificDatumWriter<lswrapper> writer = new SpecificDatumWriter<>(xx.class);
writer.write(content, encoder); encoder.flush(); out.close(); return out.toByteArray();/ I am now trying to do the equivalent in C++. The documentation shows: /std::auto_ptr<avro::OutputStream> out = avro::memoryOutputStream(); avro::EncoderPtr e = avro::binaryEncoder(); e->init(*out); ... avro::encode(*e, <xx>);/ and I can do this but I don't know how to then get a copy of the encoded bytes. I would like to get this in a variable of type: /std::vector<uint8_t>/ so that I can pass this back for use elsewhere in my program, but avro::OutputStream does not seem to provide any methods to do this. I have tried instead doing: /ostringstream os; auto_ptr<avro::OutputStream> oStream = avro::ostreamOutputStream(os); / and then using /os.str()/ to access the data, but I am not sure if this is right and it does not seem to work. Seems like it should be simple, but I can't figure it out! -- View this message in context: http://apache-avro.679487.n3.nabble.com/Getting-access-to-binary-encoded-data-C-tp4028890.html Sent from the Avro - Users mailing list archive at Nabble.com.