Coin  4.0.7
Coin3D core library
Loading...
Searching...
No Matches
SbByteBuffer.h
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 std::shared_ptr<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 <memory>
22#include <Inventor/SbBasic.h>
23
24#ifndef ABI_BREAKING_OPTIMIZE
25class SbByteBufferP;
26#endif //ABI_BREAKING_OPTIMIZE
27
28
29
30//Consider making a general Buffer class for non bytes;
31//Implements as a minimum the Buffer concept as defined by
32//http://www.boost.org/doc/libs/1_37_0/libs/graph/doc/Buffer.html
34 public:
35 SbByteBuffer(const char * buffer);
36 SbByteBuffer(const SbByteBuffer & buffer);
37 SbByteBuffer(size_t size = 0, const char * buffer = NULL);
38 SbByteBuffer(size_t size, const unsigned char * buffer);
40
41 SbBool isValid() const;
42 size_t size() const;
43 SbBool empty() const;
44
45 const char & operator[](size_t idx) const;
47 SbBool operator==(const SbByteBuffer & that) const;
48 SbByteBuffer & operator+=(const SbByteBuffer & buf) {
49 this->push(buf);
50 return *this;
51 }
52
53 void push(const SbByteBuffer & buf);
54
55 const char * constData() const;
56 char * data();
57
58 static SbByteBuffer & invalidBuffer();
59 void makeUnique();
60
61 private:
62#ifndef ABI_BREAKING_OPTIMIZE
63 SbByteBufferP * pimpl;
64#else
65 SBBYTEBUFFER_PRIVATE_VARIABLES
66#endif //ABI_BREAKING_OPTIMIZE
67};
68
69#ifdef ABI_BREAKING_OPTIMIZE
70#include "SbByteBufferP.icc"
71#endif //ABI_BREAKING_OPTIMIZE
72
73#endif // !COIN_SBBYTEBUFFER_H
74
75//The SBBYTEBUFFER_PRIVATE_VARIABLES must survive an inclusion from the .icc file
76#ifndef COIN_ICC_INCLUDE
77#undef SBBYTEBUFFER_PRIVATE_VARIABLES
78#endif //COIN_ICC_INCLUDE
Definition SbByteBuffer.h:33
The SbList class is a template container class for lists.
Definition SbList.h:70
SbList< Type > & operator=(const SbList< Type > &l)
Definition SbList.h:99
int operator==(const SbList< Type > &l) const
Definition SbList.h:209
Type operator[](const int index) const
Definition SbList.h:195
void push(const Type item)
Definition SbList.h:180