Enable C++ style file I/O when writing binary output
from bufferlists.
Signed-off-by: John Spray <john.spray@inktank.com>
return crc;
}
+
+/**
+ * Binary write all contents to a C++ stream
+ */
+void buffer::list::write_stream(std::ostream &out) const
+{
+ for (std::list<ptr>::const_iterator p = _buffers.begin(); p != _buffers.end(); ++p) {
+ if (p->length() > 0) {
+ out.write(p->c_str(), p->length());
+ }
+ }
+}
+
+
void buffer::list::hexdump(std::ostream &out) const
{
std::ios_base::fmtflags original_flags = out.flags();
void encode_base64(list& o);
void decode_base64(list& o);
+ void write_stream(std::ostream &out) const;
void hexdump(std::ostream &out) const;
int read_file(const char *fn, std::string *error);
ssize_t read_fd(int fd, size_t len);