aboutsummaryrefslogtreecommitdiff
path: root/src/fbasicstring.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-10-14 23:26:25 +0000
committerMike Buland <eichlan@xagasoft.com>2010-10-14 23:26:25 +0000
commit867dae89929a11a421ec21af71d494ad0ecc1963 (patch)
tree85d4330d5cdc0567194f1bfb2f9b1bda4e95b444 /src/fbasicstring.h
parent13fa07280dd9ed2c62ad2be0848f88b0d85fe322 (diff)
downloadlibbu++-867dae89929a11a421ec21af71d494ad0ecc1963.tar.gz
libbu++-867dae89929a11a421ec21af71d494ad0ecc1963.tar.bz2
libbu++-867dae89929a11a421ec21af71d494ad0ecc1963.tar.xz
libbu++-867dae89929a11a421ec21af71d494ad0ecc1963.zip
SharedCore has more features now, which is cool, including a test to see if
another object of the parent type has the same core, and another to clone the parent object. That one is pretty cool, it means you can now get a real copy when you want to, great for multi-threaded stuff. Also, two more classes are now SharedCore: Hash and Heap!
Diffstat (limited to '')
-rw-r--r--src/fbasicstring.h23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/fbasicstring.h b/src/fbasicstring.h
index 19853f5..82c5137 100644
--- a/src/fbasicstring.h
+++ b/src/fbasicstring.h
@@ -34,10 +34,19 @@ namespace Bu
34 }; 34 };
35 35
36#define cpy( dest, src, size ) Bu::memcpy( dest, src, size*sizeof(chr) ) 36#define cpy( dest, src, size ) Bu::memcpy( dest, src, size*sizeof(chr) )
37
38 template< typename chr, int nMinSize, typename chralloc,
39 typename chunkalloc> class FBasicString;
37 40
38 template<typename chr, int nMinSize, typename chralloc, typename chunkalloc> 41 template<typename chr, int nMinSize, typename chralloc, typename chunkalloc>
39 struct FStringCore 42 struct FStringCore
40 { 43 {
44 friend class FBasicString<chr, nMinSize, chralloc, chunkalloc>;
45 friend class SharedCore<
46 FBasicString<chr, nMinSize, chralloc, chunkalloc>,
47 FStringCore<chr, nMinSize, chralloc, chunkalloc>
48 >;
49 private:
41 typedef struct FStringCore<chr, nMinSize, chralloc, chunkalloc> MyType; 50 typedef struct FStringCore<chr, nMinSize, chralloc, chunkalloc> MyType;
42 typedef struct FStringChunk<chr> Chunk; 51 typedef struct FStringChunk<chr> Chunk;
43 FStringCore() : 52 FStringCore() :
@@ -174,16 +183,20 @@ namespace Bu
174 *@param chralloc (typename) Memory Allocator for chr 183 *@param chralloc (typename) Memory Allocator for chr
175 *@param chunkalloc (typename) Memory Allocator for chr chunks 184 *@param chunkalloc (typename) Memory Allocator for chr chunks
176 */ 185 */
177 template< typename chr, int nMinSize=256, typename chralloc=std::allocator<chr>, typename chunkalloc=std::allocator<struct FStringChunk<chr> > > 186 template< typename chr, int nMinSize=256,
178 class FBasicString : public SharedCore< FStringCore<chr, nMinSize, chralloc, chunkalloc> > 187 typename chralloc=std::allocator<chr>,
188 typename chunkalloc=std::allocator<struct FStringChunk<chr> > >
189 class FBasicString : public SharedCore<
190 FBasicString<chr, nMinSize, chralloc, chunkalloc>,
191 FStringCore<chr, nMinSize, chralloc, chunkalloc> >
179 { 192 {
180 protected: 193 protected:
181 typedef struct FStringChunk<chr> Chunk; 194 typedef struct FStringChunk<chr> Chunk;
182 typedef struct FBasicString<chr, nMinSize, chralloc, chunkalloc> MyType; 195 typedef struct FBasicString<chr, nMinSize, chralloc, chunkalloc> MyType;
183 typedef struct FStringCore<chr, nMinSize, chralloc, chunkalloc> Core; 196 typedef struct FStringCore<chr, nMinSize, chralloc, chunkalloc> Core;
184 197
185 using SharedCore< Core >::core; 198 using SharedCore<MyType, Core >::core;
186 using SharedCore< Core >::_hardCopy; 199 using SharedCore<MyType, Core >::_hardCopy;
187 200
188 public: 201 public:
189 FBasicString() 202 FBasicString()
@@ -201,7 +214,7 @@ namespace Bu
201 } 214 }
202 215
203 FBasicString( const MyType &rSrc ) : 216 FBasicString( const MyType &rSrc ) :
204 SharedCore<Core>( rSrc ) 217 SharedCore<MyType, Core>( rSrc )
205 { 218 {
206 } 219 }
207 220