7 typedef unsigned int size_t;
8 typedef unsigned char UCHAR;
11 class status_exception : public std::exception {
13 class fatal_exception : public status_exception {
18 _IO_cookie_io_functions_t;
19 void gds__log(const TEXT*, ...);
22 class MemoryPool* mbk_pool;
25 class PermanentStorage {
26 private: MemoryPool& pool;
27 protected: explicit PermanentStorage(MemoryPool& p) : pool(p) {
30 class AutoStorage : public PermanentStorage {
31 public: static MemoryPool& getAutoMemoryPool();
32 protected: AutoStorage() : PermanentStorage(getAutoMemoryPool()) {
35 class AbstractString : private AutoStorage {
36 typedef const char* const_pointer;
38 INLINE_BUFFER_SIZE = 32, INIT_RESERVE = 16 };
39 public: inline const_pointer c_str() const {
42 class StringComparator {
44 template<typename Comparator> class StringBase : public AbstractString {
45 typedef StringBase<Comparator> StringType;
46 inline StringType& append(const StringType& str) {
49 typedef StringBase<StringComparator> string;
50 class ClumpletReader : protected AutoStorage {
52 Tagged, UnTagged, SpbAttach, SpbStart, Tpb };
53 ClumpletReader(Kind k, const UCHAR* buffer, size_t buffLen);
58 UCHAR getClumpTag() const;
59 size_t getClumpLength() const;
60 const UCHAR* getBytes() const;
61 size_t getBufferLength() const {
62 size_t rc = getBufferEnd() - getBuffer();
63 if (rc == 1 && kind != UnTagged && kind != SpbStart) {
66 size_t getCurOffset() const {
70 virtual const UCHAR* getBuffer() const {
72 virtual const UCHAR* getBufferEnd() const {
75 void ClumpletReader::dump() const {
76 class ClumpletDump : public ClumpletReader {
77 public: ClumpletDump(Kind k, const UCHAR* buffer, size_t buffLen) : ClumpletReader(k, buffer, buffLen) {
79 static string hexString(const UCHAR* b, size_t len) {
87 ClumpletDump d(kind, getBuffer(), getBufferLength());
91 gds__log("Clump %d at offset %d: %s", d.getClumpTag(), d.getCurOffset(), ClumpletDump::hexString(d.getBytes(), d.getClumpLength()).c_str());
94 catch(const fatal_exception& x) {