aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bufferstore.h
diff options
context:
space:
mode:
authorFritz Elfert <felfert@to.com>1999-06-28 08:56:01 +0000
committerFritz Elfert <felfert@to.com>1999-06-28 08:56:01 +0000
commit34b70b0b46e34a73308a4034cc9b1c70209b9eb4 (patch)
tree7abe8be40fde08828d3606e13c41435b2fc9a26c /lib/bufferstore.h
parent3d3be141551bb4622da1cb610e4f6f798dd1715e (diff)
downloadplptools-34b70b0b46e34a73308a4034cc9b1c70209b9eb4.tar.gz
plptools-34b70b0b46e34a73308a4034cc9b1c70209b9eb4.tar.bz2
plptools-34b70b0b46e34a73308a4034cc9b1c70209b9eb4.zip
First import.
Diffstat (limited to 'lib/bufferstore.h')
-rw-r--r--lib/bufferstore.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/bufferstore.h b/lib/bufferstore.h
new file mode 100644
index 0000000..4840689
--- /dev/null
+++ b/lib/bufferstore.h
@@ -0,0 +1,50 @@
+#ifndef _bufferstore_h
+#define _bufferstore_h
+
+#include "bool.h"
+class ostream;
+
+class bufferStore {
+public:
+ bufferStore();
+ bufferStore(const unsigned char*buff, long len);
+ ~bufferStore();
+ bufferStore(const bufferStore &a);
+ void operator =(const bufferStore &a);
+
+ // Reading Utils
+ unsigned long getLen() const;
+ unsigned char getByte(long pos) const;
+ unsigned int getWord(long pos) const;
+ unsigned int getDWord(long pos) const;
+ const char* getString(long pos=0) const;
+ void discardFirstBytes(int n);
+ friend ostream &operator<<(ostream &s, const bufferStore &m);
+ bool empty() const;
+
+ // Writing utils
+ void init();
+ void init(const unsigned char*buff, long len);
+ void addByte(unsigned char c);
+ void addWord(int a);
+ void addDWord(long a);
+ void addString(const char* s);
+ void addStringT(const char* s);
+ void addBuff(const bufferStore &s, long maxLen=-1);
+
+private:
+ void checkAllocd(long newLen);
+
+ long len;
+ long lenAllocd;
+ long start;
+ unsigned char* buff;
+
+ enum c { MIN_LEN = 300 };
+};
+
+inline bool bufferStore::empty() const {
+ return (len-start) == 0;
+}
+
+#endif