- explicit WrapperOutputStream(OutputStream &o);
- virtual ~WrapperOutputStream() { }
-
-protected:
- virtual void write_internal(const void *data, size_t len);
-
-private:
- OutputStream ℜ
-};
-
-/* Like WrapperOutputStream, but additionally computes a checksum of data as it
- * is written. */
-class ChecksumOutputStream : public OutputStream {
-public:
- explicit ChecksumOutputStream(OutputStream &o);
- virtual ~ChecksumOutputStream() { }
-
- /* Once a checksum is computed, no further data should be written to the
- * stream. */
- const uint8_t *finish_and_checksum();
- size_t checksum_size() const { return csum.checksum_size(); }
-
-protected:
- virtual void write_internal(const void *data, size_t len);
-
-private:
- OutputStream ℜ
- SHA1Checksum csum;
-};
-
-/* Simple wrappers that encode integers using a StringOutputStream and return
- * the encoded result. */
-std::string encode_u16(uint16_t val);
-std::string encode_u32(uint32_t val);
-std::string encode_u64(uint64_t val);
-std::string encode_objref(const struct uuid &segment, uint32_t object);
-
-/* A class which is used to pack multiple objects into a single segment, with a
- * lookup table to quickly locate each object. Call new_object() to get an
- * OutputStream to which a new object may be written, and optionally
- * finish_object() when finished writing the current object. Only one object
- * may be written to a segment at a time; if multiple objects must be written
- * concurrently, they must be to different segments. */
-class SegmentWriter {
-public:
- SegmentWriter(OutputStream *output, struct uuid u);
- ~SegmentWriter();
-
- struct uuid get_uuid() const { return id; }
-
- // Start writing out a new object to this segment.
- OutputStream *new_object(int *id);
- void finish_object();