aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2019-05-25 23:04:09 -0700
committerMike Buland <eichlan@xagasoft.com>2019-05-25 23:04:09 -0700
commit26aa4bd668a2f2358b03634bce78c58085f14164 (patch)
tree49ddbcfec9af34e0a49d00614d7437c39988b7ef
parent3a27454dca4a16d021a4d418f0725adccc5baabb (diff)
downloadlibbu++-26aa4bd668a2f2358b03634bce78c58085f14164.tar.gz
libbu++-26aa4bd668a2f2358b03634bce78c58085f14164.tar.bz2
libbu++-26aa4bd668a2f2358b03634bce78c58085f14164.tar.xz
libbu++-26aa4bd668a2f2358b03634bce78c58085f14164.zip
Started work on the SharedCore BlobBuilder.
This will contain everything that made Bu::String flexible and fast when building, and a nightmare for multi-threaded programming.
Diffstat (limited to '')
-rw-r--r--src/unstable/blob.h8
-rw-r--r--src/unstable/blobbuilder.cpp63
-rw-r--r--src/unstable/blobbuilder.h53
3 files changed, 123 insertions, 1 deletions
diff --git a/src/unstable/blob.h b/src/unstable/blob.h
index daee5f9..b48f488 100644
--- a/src/unstable/blob.h
+++ b/src/unstable/blob.h
@@ -8,7 +8,7 @@
8#ifndef BU_BLOB_H 8#ifndef BU_BLOB_H
9#define BU_BLOB_H 9#define BU_BLOB_H
10 10
11#include <stdint.h> 11#include "bu/config.h"
12 12
13namespace Bu 13namespace Bu
14{ 14{
@@ -19,6 +19,12 @@ namespace Bu
19 * choice when dealing with any sequence of binary data that you don't 19 * choice when dealing with any sequence of binary data that you don't
20 * need to interpret further. 20 * need to interpret further.
21 * 21 *
22 * You may note that Blob doesn't have any append, prepend, etc. methods.
23 * This is because Blobs are designed to be more or less immutable. If you
24 * need that functionality (which is quite likely), check out
25 * Bu::BlobBuilder which offers a flexible, fast interface to build Blobs
26 * dynamically, piece at a time.
27 *
22 * If you're dealing with data that contains language, such as human text, 28 * If you're dealing with data that contains language, such as human text,
23 * then use the Bu::Text class instead. 29 * then use the Bu::Text class instead.
24 */ 30 */
diff --git a/src/unstable/blobbuilder.cpp b/src/unstable/blobbuilder.cpp
index 73271f8..b98476b 100644
--- a/src/unstable/blobbuilder.cpp
+++ b/src/unstable/blobbuilder.cpp
@@ -5,4 +5,67 @@
5 * terms of the license contained in the file LICENSE. 5 * terms of the license contained in the file LICENSE.
6 */ 6 */
7 7
8#include "blobbuilder.h"
9
10/////
11// BlobBuilderCore::Chunk
12//
13
14Bu::BlobBuilderCore::Chunk::Chunk() :
15 iFill( 0 ),
16 iLength( 0 ),
17 pData( 0 ),
18 pNext( 0 )
19{
20}
21
22Bu::BlobBuilderCore::Chunk::~Chunk()
23{
24 delete[] pData;
25 pData = 0;
26 delete pNext;
27 pNext = 0;
28}
29
30/////
31// BlobBuilderCore
32//
33
34Bu::BlobBuilderCore::BlobBuilderCore() :
35 pFirst( 0 ),
36 pLast( 0 ),
37 iLength( 0 )
38{
39}
40
41Bu::BlobBuilderCore::BlobBuilderCore( const Bu::BlobBuilderCore &rSrc ) :
42 iLength( rSrc.iLength ),
43 pFirst( 0 ),
44 pLast( 0 )
45{
46
47}
48
49Bu::BlobBuilderCore::~BlobBuilderCore()
50{
51 delete pFirst;
52 pFirst = pLast = 0;
53}
54
55//////
56// BlobBuilder
57//
58
59Bu::BlobBuilder::BlobBuilder()
60{
61}
62
63Bu::BlobBuilder::BlobBuilder( const Bu::BlobBuilder &rSrc ) :
64 Bu::SharedCore<Bu::BlobBuilder, Bu::BlobBuilderCore>( rSrc )
65{
66}
67
68Bu::BlobBuilder::~BlobBuilder()
69{
70}
8 71
diff --git a/src/unstable/blobbuilder.h b/src/unstable/blobbuilder.h
index 73271f8..8cc2a24 100644
--- a/src/unstable/blobbuilder.h
+++ b/src/unstable/blobbuilder.h
@@ -5,4 +5,57 @@
5 * terms of the license contained in the file LICENSE. 5 * terms of the license contained in the file LICENSE.
6 */ 6 */
7 7
8#ifndef BU_BLOB_BUILDER_H
9#define BU_BLOB_BUILDER_H
8 10
11#include "bu/config.h"
12#include "bu/sharedcore.h"
13
14namespace Bu
15{
16 class BlobBuilder;
17
18 class BlobBuilderCore
19 {
20 friend class BlobBuilder;
21 friend class SharedCore<BlobBuilder, BlobBuilderCore>;
22 private:
23 class Chunk
24 {
25 public:
26 Chunk();
27 ~Chunk();
28
29 int16_t iFill;
30 int16_t iLength;
31 char *pData;
32 Chunk *pNext;
33 };
34
35 BlobBuilderCore();
36 BlobBuilderCore( const BlobBuilderCore &rSrc );
37 virtual ~BlobBuilderCore();
38
39 void clear();
40
41 Chunk *pFirst;
42 Chunk *pLast;
43 int32_t iLength;
44 };
45
46 class BlobBuilder : public Bu::SharedCore<BlobBuilder, BlobBuilderCore>
47 {
48 protected:
49 using SharedCore<BlobBuilder, BlobBuilderCore>::core;
50 using SharedCore<BlobBuilder, BlobBuilderCore>::_hardCopy;
51
52 public:
53 BlobBuilder();
54 BlobBuilder( const BlobBuilder &rSrc );
55 virtual ~BlobBuilder();
56
57 private:
58 };
59};
60
61#endif