diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-10-18 14:16:53 -0400 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-10-18 14:16:53 -0400 |
commit | ca93b4a1ac9d07ea150572801fd47f9a0818abff (patch) | |
tree | 8ec8916b82baab567a3d9cc66471b866f8ef1809 /node/Buffer.hpp | |
parent | 03b909603ae6010d7bf059de688c0cfe0f96a0a3 (diff) | |
download | infinitytier-ca93b4a1ac9d07ea150572801fd47f9a0818abff.tar.gz infinitytier-ca93b4a1ac9d07ea150572801fd47f9a0818abff.zip |
Clean up some stuff, including a few spots where exceptions were not being handled correctly.
Diffstat (limited to 'node/Buffer.hpp')
-rw-r--r-- | node/Buffer.hpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/node/Buffer.hpp b/node/Buffer.hpp index 73d0e5de..1767ae04 100644 --- a/node/Buffer.hpp +++ b/node/Buffer.hpp @@ -302,6 +302,25 @@ public: } /** + * Increment size and return pointer to field of specified size + * + * The memory isn't actually written, so this is a shortcut for a multi-step + * process involving getting the current pointer and adding size. + * + * @param l Length of field to append + * @return Pointer to beginning of appended field of length 'l' + */ + inline char *appendField(unsigned int l) + throw(std::out_of_range) + { + if ((_l + l) > C) + throw std::out_of_range("Buffer: append beyond capacity"); + char *r = _b + _l; + _l += l; + return r; + } + + /** * Increment size by a given number of bytes * * The contents of new space are undefined. |