summaryrefslogtreecommitdiffstats
path: root/depends/classparser/src/membuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'depends/classparser/src/membuffer.h')
-rw-r--r--depends/classparser/src/membuffer.h105
1 files changed, 52 insertions, 53 deletions
diff --git a/depends/classparser/src/membuffer.h b/depends/classparser/src/membuffer.h
index 2ea3a69b..ab83412a 100644
--- a/depends/classparser/src/membuffer.h
+++ b/depends/classparser/src/membuffer.h
@@ -7,58 +7,57 @@
namespace util
{
- class membuffer
+class membuffer
+{
+public:
+ membuffer(char *buffer, std::size_t size)
+ {
+ current = start = buffer;
+ end = start + size;
+ }
+ ~membuffer()
+ {
+ // maybe? possibly? left out to avoid confusion. for now.
+ // delete start;
+ }
+ /**
+ * Read some value. That's all ;)
+ */
+ template <class T> void read(T &val)
+ {
+ val = *(T *)current;
+ current += sizeof(T);
+ }
+ /**
+ * Read a big-endian number
+ * valid for 2-byte, 4-byte and 8-byte variables
+ */
+ template <class T> void read_be(T &val)
{
- public:
- membuffer(char * buffer, std::size_t size)
- {
- current = start = buffer;
- end = start + size;
- }
- ~membuffer()
- {
- // maybe? possibly? left out to avoid confusion. for now.
- //delete start;
- }
- /**
- * Read some value. That's all ;)
- */
- template <class T>
- void read(T& val)
- {
- val = *(T *)current;
- current += sizeof(T);
- }
- /**
- * Read a big-endian number
- * valid for 2-byte, 4-byte and 8-byte variables
- */
- template <class T>
- void read_be(T& val)
- {
- val = util::bigswap(*(T *)current);
- current += sizeof(T);
- }
- /**
- * Read a string in the format:
- * 2B length (big endian, unsigned)
- * length bytes data
- */
- void read_jstr(std::string & str)
- {
- uint16_t length = 0;
- read_be(length);
- str.append(current,length);
- current += length;
- }
- /**
- * Skip N bytes
- */
- void skip (std::size_t N)
- {
- current += N;
- }
- private:
- char * start, *end, *current;
- };
+ val = util::bigswap(*(T *)current);
+ current += sizeof(T);
+ }
+ /**
+ * Read a string in the format:
+ * 2B length (big endian, unsigned)
+ * length bytes data
+ */
+ void read_jstr(std::string &str)
+ {
+ uint16_t length = 0;
+ read_be(length);
+ str.append(current, length);
+ current += length;
+ }
+ /**
+ * Skip N bytes
+ */
+ void skip(std::size_t N)
+ {
+ current += N;
+ }
+
+private:
+ char *start, *end, *current;
+};
}