diff options
Diffstat (limited to 'src/unstable/blob.h')
| -rw-r--r-- | src/unstable/blob.h | 125 | 
1 files changed, 125 insertions, 0 deletions
| diff --git a/src/unstable/blob.h b/src/unstable/blob.h new file mode 100644 index 0000000..5b8cabd --- /dev/null +++ b/src/unstable/blob.h | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2007-2019 Xagasoft, All rights reserved. | ||
| 3 | * | ||
| 4 | * This file is part of the libbu++ library and is released under the | ||
| 5 | * terms of the license contained in the file LICENSE. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef BU_BLOB_H | ||
| 9 | #define BU_BLOB_H | ||
| 10 | |||
| 11 | #include <stdint.h> | ||
| 12 | |||
| 13 | namespace Bu | ||
| 14 | { | ||
| 15 | /** | ||
| 16 | * Blob contans a sequence of binary values. This is basically the | ||
| 17 | * replacement for the old libbu++ Bu::String, std::string classes, or the | ||
| 18 | * tradition C char * string. The Blob is static and immutable, and a good | ||
| 19 | * choice when dealing with any sequence of binary data that you don't | ||
| 20 | * need to interpret further. | ||
| 21 | * | ||
| 22 | * If you're dealing with data that contains language, such as human text, | ||
| 23 | * then use the Bu::Text class instead. | ||
| 24 | */ | ||
| 25 | class Blob | ||
| 26 | { | ||
| 27 | public: | ||
| 28 | Blob(); | ||
| 29 | Blob( const Blob &rSrc ); | ||
| 30 | Blob( const char *pSrc ); | ||
| 31 | Blob( const void *pSrc, int32_t iSize ); | ||
| 32 | virtual ~Blob(); | ||
| 33 | |||
| 34 | int32_t getSize() const; | ||
| 35 | char *getData() const; | ||
| 36 | |||
| 37 | char *c_str() const; | ||
| 38 | |||
| 39 | Blob &operator=( const Blob &rRhs ); | ||
| 40 | Blob &operator=( const char *pRhs ); | ||
| 41 | |||
| 42 | class const_iterator; | ||
| 43 | class iterator | ||
| 44 | { | ||
| 45 | friend class Blob; | ||
| 46 | friend class const_iterator; | ||
| 47 | private: | ||
| 48 | iterator( Blob *pBlob, bool bForward ); | ||
| 49 | |||
| 50 | public: | ||
| 51 | iterator(); | ||
| 52 | iterator( const iterator &rSrc ); | ||
| 53 | |||
| 54 | bool isValid() const; | ||
| 55 | operator bool() const; | ||
| 56 | char &operator *(); | ||
| 57 | |||
| 58 | iterator &operator++( int ); | ||
| 59 | iterator &operator++(); | ||
| 60 | iterator &operator--( int ); | ||
| 61 | iterator &operator--(); | ||
| 62 | bool operator==( const iterator &rRhs ); | ||
| 63 | bool operator==( const const_iterator &rRhs ); | ||
| 64 | bool operator!=( const iterator &rRhs ); | ||
| 65 | bool operator!=( const const_iterator &rRhs ); | ||
| 66 | |||
| 67 | iterator &operator=( iterator &rRhs ); | ||
| 68 | |||
| 69 | private: | ||
| 70 | Blob *pBlob; | ||
| 71 | int32_t iIndex; | ||
| 72 | bool bForward; | ||
| 73 | }; | ||
| 74 | |||
| 75 | class const_iterator | ||
| 76 | { | ||
| 77 | friend class Blob; | ||
| 78 | friend class iterator; | ||
| 79 | private: | ||
| 80 | const_iterator( const Blob *pBlob, bool bForward ); | ||
| 81 | |||
| 82 | public: | ||
| 83 | const_iterator(); | ||
| 84 | const_iterator( const const_iterator &rSrc ); | ||
| 85 | const_iterator( const iterator &rSrc ); | ||
| 86 | |||
| 87 | bool isValid() const; | ||
| 88 | operator bool() const; | ||
| 89 | char operator *() const; | ||
| 90 | |||
| 91 | const_iterator &operator++( int ); | ||
| 92 | const_iterator &operator++(); | ||
| 93 | const_iterator &operator--( int ); | ||
| 94 | const_iterator &operator--(); | ||
| 95 | bool operator==( const iterator &rRhs ); | ||
| 96 | bool operator==( const const_iterator &rRhs ); | ||
| 97 | bool operator!=( const iterator &rRhs ); | ||
| 98 | bool operator!=( const const_iterator &rRhs ); | ||
| 99 | |||
| 100 | const_iterator &operator=( iterator &rRhs ); | ||
| 101 | const_iterator &operator=( const_iterator &rRhs ); | ||
| 102 | |||
| 103 | private: | ||
| 104 | const Blob *pBlob; | ||
| 105 | int32_t iIndex; | ||
| 106 | bool bForward; | ||
| 107 | }; | ||
| 108 | |||
| 109 | iterator begin(); | ||
| 110 | const_iterator begin() const; | ||
| 111 | iterator end(); | ||
| 112 | const_iterator end() const; | ||
| 113 | iterator rbegin(); | ||
| 114 | const_iterator rbegin() const; | ||
| 115 | iterator rend(); | ||
| 116 | const_iterator rend() const; | ||
| 117 | |||
| 118 | private: | ||
| 119 | char *pData; | ||
| 120 | int32_t iSize; | ||
| 121 | }; | ||
| 122 | } | ||
| 123 | |||
| 124 | #endif | ||
| 125 | |||
