This class provides read access for clumplet structure Note: it doesn't make a copy of buffer it reads
| 43 | // This class provides read access for clumplet structure |
| 44 | // Note: it doesn't make a copy of buffer it reads |
| 45 | class ClumpletReader : protected AutoStorage |
| 46 | { |
| 47 | public: |
| 48 | enum Kind |
| 49 | { |
| 50 | EndOfList, |
| 51 | Tagged, |
| 52 | UnTagged, |
| 53 | SpbAttach, |
| 54 | SpbStart, |
| 55 | Tpb, |
| 56 | WideTagged, |
| 57 | WideUnTagged, |
| 58 | SpbSendItems, |
| 59 | SpbReceiveItems, |
| 60 | SpbResponse, |
| 61 | InfoResponse, |
| 62 | InfoItems |
| 63 | }; |
| 64 | |
| 65 | struct KindList |
| 66 | { |
| 67 | Kind kind; |
| 68 | UCHAR tag; |
| 69 | }; |
| 70 | |
| 71 | struct SingleClumplet |
| 72 | { |
| 73 | UCHAR tag; |
| 74 | FB_SIZE_T size; |
| 75 | const UCHAR* data; |
| 76 | }; |
| 77 | |
| 78 | // Constructor prepares an object from plain PB |
| 79 | ClumpletReader(Kind k, const UCHAR* buffer, FB_SIZE_T buffLen); |
| 80 | ClumpletReader(MemoryPool& pool, Kind k, const UCHAR* buffer, FB_SIZE_T buffLen); |
| 81 | |
| 82 | // Different versions of clumplets may have different kinds |
| 83 | ClumpletReader(const KindList* kl, const UCHAR* buffer, FB_SIZE_T buffLen, FPTR_VOID raise = NULL); |
| 84 | ClumpletReader(MemoryPool& pool, const KindList* kl, const UCHAR* buffer, FB_SIZE_T buffLen, FPTR_VOID raise = NULL); |
| 85 | virtual ~ClumpletReader() { } |
| 86 | |
| 87 | // Create a copy of reader |
| 88 | ClumpletReader(MemoryPool& pool, const ClumpletReader& from); |
| 89 | ClumpletReader(const ClumpletReader& from); |
| 90 | |
| 91 | // Navigation in clumplet buffer |
| 92 | bool isEof() const { return cur_offset >= getBufferLength(); } |
| 93 | void moveNext(); |
| 94 | void rewind(); |
| 95 | bool find(UCHAR tag); |
| 96 | bool next(UCHAR tag); |
| 97 | |
| 98 | // Methods which work with currently selected clumplet |
| 99 | UCHAR getClumpTag() const; |
| 100 | FB_SIZE_T getClumpLength() const; |
| 101 | |
| 102 | SLONG getInt() const; |