summaryrefslogtreecommitdiffstats
path: root/depends/classparser/src/membuffer.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-11-04 02:53:05 +0100
committerPetr Mrázek <peterix@gmail.com>2013-11-04 02:53:05 +0100
commitbb7e8985f6d189de0acac6a1c3033cb16378c1fb (patch)
tree7c2e88c7184a7f5acf5e7a03be5c5f0bf6904113 /depends/classparser/src/membuffer.h
parentd6e4fb29713d6ce55b092c0e22412f6121e7f516 (diff)
downloadMultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.gz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.lz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.xz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.zip
Reformat and (slightly) decruft all the things.
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;
+};
}