1 /* 2 Defining Private variables in exactly one location, to keep them in 3 sync, remember to undefine this, so this is not visible outside this 4 header, unless included from an .icc file 5 */ 6 /* 7 NOTE: This define is done outside the Header guard, and undefined in 8 the end. This is to make it possible to include this from an .icc 9 file, even if the header has been included from before. 10 */ 11 #define SBBYTEBUFFER_PRIVATE_VARIABLES \ 12 size_t size_; \ 13 boost::shared_array<char> buffer; \ 14 SbBool invalid; \ 15 static SbByteBuffer invalidBuffer_; 16 17 #ifndef COIN_SBBYTEBUFFER_H 18 #define COIN_SBBYTEBUFFER_H 19 20 #include <cstring> 21 #include <Inventor/SbBasic.h> 22 23 #ifndef ABI_BREAKING_OPTIMIZE 24 class SbByteBufferP; 25 #else 26 #include <boost/shared_array.hpp> 27 #endif //ABI_BREAKING_OPTIMIZE 28 29 30 31 //Consider making a general Buffer class for non bytes; 32 //Implements as a minimum the Buffer concept as defined by 33 //http://www.boost.org/doc/libs/1_37_0/libs/graph/doc/Buffer.html 34 class COIN_DLL_API SbByteBuffer { 35 public: 36 SbByteBuffer(const char * buffer); 37 SbByteBuffer(const SbByteBuffer & buffer); 38 SbByteBuffer(size_t size = 0, const char * buffer = NULL); 39 SbByteBuffer(size_t size, const unsigned char * buffer); 40 ~SbByteBuffer(); 41 42 SbBool isValid() const; 43 size_t size() const; 44 SbBool empty() const; 45 46 const char & operator[](size_t idx) const; 47 SbByteBuffer & operator=(const SbByteBuffer & in); 48 SbBool operator==(const SbByteBuffer & that) const; 49 SbByteBuffer & operator+=(const SbByteBuffer & buf) { 50 this->push(buf); 51 return *this; 52 } 53 54 void push(const SbByteBuffer & buf); 55 56 const char * constData() const; 57 char * data(); 58 59 static SbByteBuffer & invalidBuffer(); 60 void makeUnique(); 61 62 private: 63 #ifndef ABI_BREAKING_OPTIMIZE 64 SbByteBufferP * pimpl; 65 #else 66 SBBYTEBUFFER_PRIVATE_VARIABLES 67 #endif //ABI_BREAKING_OPTIMIZE 68 }; 69 70 #ifdef ABI_BREAKING_OPTIMIZE 71 #include "SbByteBufferP.icc" 72 #endif //ABI_BREAKING_OPTIMIZE 73 74 #endif // !COIN_SBBYTEBUFFER_H 75 76 //The SBBYTEBUFFER_PRIVATE_VARIABLES must survice an inclusion from the .icc file 77 #ifndef COIN_ICC_INCLUDE 78 #undef SBBYTEBUFFER_PRIVATE_VARIABLES 79 #endif //COIN_ICC_INCLUDE 80