Minor tweaks and a new deque operator
This commit is contained in:
@@ -49,9 +49,9 @@
|
||||
// streambuffer.write_int32(0);
|
||||
//
|
||||
// // Write the data, and calculate its length in bytes.
|
||||
// int64_t write_count_1 = streambuffer.write_count();
|
||||
// int64_t write_count_1 = streambuffer.total_writes();
|
||||
// write_data(stream);
|
||||
// int64_t write_count_2 = streambuffer.write_count();
|
||||
// int64_t write_count_2 = streambuffer.total_writes();
|
||||
// int64_t data_len = write_count_2 - write_count_1;
|
||||
//
|
||||
// // Overwrite the previously-written dummy length.
|
||||
@@ -130,7 +130,7 @@
|
||||
// Here is the construction that accomplishes this:
|
||||
//
|
||||
// // Get the stream's read count before parsing the message.
|
||||
// size_t read_count_before = streambuffer.read_count();
|
||||
// size_t read_count_before = streambuffer.total_reads();
|
||||
//
|
||||
// // Parse the message, but if there's an EOF, deal with it:
|
||||
// try {
|
||||
@@ -164,7 +164,7 @@
|
||||
//
|
||||
// A StreamBuffer that reads from an external block of bytes is read-only.
|
||||
// Attempts to write to this buffer will be caught and will cause an abort. The
|
||||
// write_count for such a buffer returns the 'len' value that you initialized
|
||||
// total_writes for such a buffer returns the 'len' value that you initialized
|
||||
// the buffer with.
|
||||
//
|
||||
// USING A STREAMBUFFER TO READ AN ENTIRE FILE
|
||||
@@ -251,13 +251,13 @@ public:
|
||||
~StreamBuffer();
|
||||
|
||||
// Get the total number of bytes ever read from this buffer.
|
||||
int64_t read_count() const;
|
||||
int64_t total_reads() const;
|
||||
|
||||
// Get the total number of bytes ever written to this buffer.
|
||||
int64_t write_count() const;
|
||||
int64_t total_writes() const;
|
||||
|
||||
// Delete all data and (if not fixed-size) free the buffer.
|
||||
// Also resets the read and write counts.
|
||||
// Discard all data. Reset total read and write counts.
|
||||
// Frees up as much space as possible.
|
||||
void clear();
|
||||
|
||||
// Write block of bytes into the buffer.
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
|
||||
// Read a block of bytes from the buffer.
|
||||
//
|
||||
// May throw StreamEof if the specified number of bytes aren't present.
|
||||
// Throws StreamEof if the specified number of bytes aren't present.
|
||||
//
|
||||
const char *read_bytes(int64_t bytes);
|
||||
|
||||
@@ -316,7 +316,7 @@ public:
|
||||
|
||||
// Read other types from the buffer.
|
||||
//
|
||||
// May throw StreamEof if the specified number of bytes aren't present.
|
||||
// Throws StreamEof if the specified number of bytes aren't present.
|
||||
// Read string with a length limit will throw 'StreamCorruption' if the
|
||||
// length is too long.
|
||||
//
|
||||
@@ -345,10 +345,10 @@ public:
|
||||
void verify_eof();
|
||||
|
||||
// Rewind the read cursor to a previous position.
|
||||
void unread_to(int64_t read_count);
|
||||
void unread_to(int64_t total_reads);
|
||||
|
||||
// Rewind the write cursor to a previous position.
|
||||
void unwrite_to(int64_t write_count);
|
||||
void unwrite_to(int64_t total_writes);
|
||||
|
||||
// Calculate a noncryptographic but good hash of what's in the buffer.
|
||||
util::HashValue hash() const;
|
||||
|
||||
Reference in New Issue
Block a user