Beamlib 3.1.1
This is the Beam C++ class library.
Loading...
Searching...
No Matches
BBuffer.h
Go to the documentation of this file.
1/*******************************************************************************
2 * BBuffer.h Buffer Class
3 * T.Barnaby, BEAM Ltd, 27/2/94
4 * Copyright (c) 2012 All Right Reserved, Beam Ltd, http://www.beam.ltd.uk
5 *******************************************************************************
6 *
7 * For license see LICENSE.txt at the root of the beamlib source tree.
8 */
9#ifndef BBUFFER_H
10#define BBUFFER_H 1
11
12#include <BTypes.h>
13#include <BString.h>
14#include <BError.h>
15#include <BComplex.h>
16#include <BEndian.h>
17
18#if IS_BIG_ENDIAN
19#define BBigEndian 1
20#else
21#define BBigEndian 0
22#endif
23
24class BTimeStamp;
25
27class BBuffer {
28public:
29 BBuffer(BUInt size = 0);
30 ~BBuffer();
31
32 int setSize(BUInt32 size);
33 int setData(const void* data, BUInt32 size);
34 int writeData(BUInt32 pos, const void* data, BUInt32 size);
35
36 char* data();
37 BUInt32 size();
38
39 int resize(BUInt32 size){ return setSize(size); }
40protected:
42 char* odata;
44};
45
47class BBufferStore : public BBuffer{
48public:
49 BBufferStore(BUInt size = 0, int swapBytes = BBigEndian);
51
53 void setPos(BUInt32 pos);
54
56 void setHexString(BString s);
57
58 int push(BInt8 v);
59 int push(BUInt8 v);
60 int push(BInt16 v);
61 int push(BUInt16 v);
62 int push(BInt32 v);
63 int push(BUInt32 v);
64 int push(BInt64 v);
65 int push(BUInt64 v);
66 int push(BFloat32 v);
67 int push(BFloat64 v);
68 int push(const BString& v);
69 int push(const BError& v);
70 int push(const BTimeStamp& v);
71 int push(const BComplex& v);
72 int push(BUInt32 nBytes, const void* data, const char* swapType = "1");
73
74 int pop(BInt8& v);
75 int pop(BUInt8& v);
76 int pop(BInt16& v);
77 int pop(BUInt16& v);
78 int pop(BInt32& v);
79 int pop(BUInt32& v);
80 int pop(BInt64& v);
81 int pop(BUInt64& v);
82 int pop(BFloat32& v);
83 int pop(BFloat64& v);
84 int pop(BString& v);
85 int pop(BError& v);
86 int pop(BTimeStamp& v);
87 int pop(BComplex& v);
88 int pop(BUInt32 nBytes, void* data, const char* swapType = "1");
89
90protected:
93};
94
95#endif
#define BBigEndian
Definition: BBuffer.h:21
std::complex< BFloat64 > BComplex
This is a complex number using BFloat64 sized parameters. It is based on the Standard C++ library com...
Definition: BComplex.h:17
int16_t BInt16
Definition: BTypes.h:21
double BFloat64
Definition: BTypes.h:28
uint16_t BUInt16
Definition: BTypes.h:22
BUInt32 BUInt
Definition: BTypes.h:33
uint32_t BUInt32
Definition: BTypes.h:24
uint8_t BUInt8
Definition: BTypes.h:20
int32_t BInt32
Definition: BTypes.h:23
int64_t BInt64
Definition: BTypes.h:25
float BFloat32
Definition: BTypes.h:27
int8_t BInt8
Definition: BTypes.h:19
uint64_t BUInt64
Definition: BTypes.h:26
Create and manipulate a variable sized byte data buffer. Has functions to store and retrieve basic an...
Definition: BBuffer.h:47
void setPos(BUInt32 pos)
Definition: BBuffer.cpp:91
int push(BInt8 v)
Definition: BBuffer.cpp:131
BString getHexString()
Definition: BBuffer.cpp:95
BUInt32 opos
Definition: BBuffer.h:91
~BBufferStore()
Definition: BBuffer.cpp:84
int oswapBytes
Definition: BBuffer.h:92
int pop(BInt8 &v)
Definition: BBuffer.cpp:244
BUInt32 getPos()
Definition: BBuffer.cpp:87
void setHexString(BString s)
Definition: BBuffer.cpp:117
Create and manipulate a variable sized byte data buffer.
Definition: BBuffer.h:27
char * odata
Definition: BBuffer.h:42
BUInt32 odataSize
Definition: BBuffer.h:41
~BBuffer()
Definition: BBuffer.cpp:25
char * data()
The data.
Definition: BBuffer.cpp:55
BUInt32 size()
Size of the buffer in bytes.
Definition: BBuffer.cpp:33
int resize(BUInt32 size)
Alternative to setSize()
Definition: BBuffer.h:39
int setSize(BUInt32 size)
Sets the bufer size.
Definition: BBuffer.cpp:37
int setData(const void *data, BUInt32 size)
Sets buffer data resized to contain the data.
Definition: BBuffer.cpp:59
BUInt32 osize
Definition: BBuffer.h:43
int writeData(BUInt32 pos, const void *data, BUInt32 size)
Writes data into buffer from offset pos.
Definition: BBuffer.cpp:69
Error return class. This class is used to return the error status from a function....
Definition: BError.h:31
This class stores and manipulates ASCII strings.
Definition: BString.h:20
A date and time storage class with microsecond resolution.
Definition: BTimeStamp.h:17