From ca93b4a1ac9d07ea150572801fd47f9a0818abff Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 18 Oct 2013 14:16:53 -0400 Subject: Clean up some stuff, including a few spots where exceptions were not being handled correctly. --- node/Buffer.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'node/Buffer.hpp') diff --git a/node/Buffer.hpp b/node/Buffer.hpp index 73d0e5de..1767ae04 100644 --- a/node/Buffer.hpp +++ b/node/Buffer.hpp @@ -301,6 +301,25 @@ public: append(b._b,b._l); } + /** + * 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 * -- cgit v1.2.3