bool BufferedConnectionWriter::applyConvertTextMode() { if (convertTextModePending) { convertTextModePending = false; Bottle b; StringOutputStream sos; for (size_t i = 0; i < lst_used; i++) { yarp::os::ManagedBytes& m = *(lst[i]); sos.write(m.usedBytes()); } const std::string& str = sos.str(); b.fromBinary(str.c_str(), (int)str.length()); std::string replacement = b.toString() + "\n"; for (auto& i : lst) { delete i; } lst_used = 0; target = &lst; lst.clear(); stopPool(); Bytes data((char*)replacement.c_str(), replacement.length()); appendBlockCopy(data); } return true; }
void testWrite() { report(0,"testing writing..."); StringOutputStream sos; char txt[] = "Hello my friend"; Bytes b(txt,ACE_OS::strlen(txt)); sos.write(b); checkEqual(txt,sos.toString(),"single write"); StringOutputStream sos2; sos2.write('y'); sos2.write('o'); checkEqual("yo",sos2.toString(),"multiple writes"); }
// only "point" is expected to have characters around here void CPointfile::saxCharacters (message_info_t *ctx, const xmlChar *ch, int len) { m_characters.write(reinterpret_cast<const char*>(ch), len); }