/* * Copyright (C) 2007-2019 Xagasoft, All rights reserved. * * This file is part of the libbu++ library and is released under the * terms of the license contained in the file LICENSE. */ #ifndef BU_BLOB_BUILDER_H #define BU_BLOB_BUILDER_H #include "bu/config.h" #include "bu/sharedcore.h" namespace Bu { class Blob; class BlobBuilder; class BlobBuilderCore { friend class BlobBuilder; friend class SharedCore; private: class Chunk { public: Chunk(); ~Chunk(); int32_t iLength; char *pData; Chunk *pNext; }; BlobBuilderCore(); BlobBuilderCore( const BlobBuilderCore &rSrc ); virtual ~BlobBuilderCore(); void clear(); Chunk *pFirst; Chunk *pLast; int32_t iLength; }; class BlobBuilder : public Bu::SharedCore { protected: using SharedCore::core; using SharedCore::_hardCopy; public: BlobBuilder(); BlobBuilder( const Blob &rSrc ); BlobBuilder( const BlobBuilder &rSrc ); virtual ~BlobBuilder(); void set( const Blob &rSrc ); void set( const char *pSrc, int32_t iLength ); void append( const Blob &rSrc ); void append( const char *pSrc, int32_t iLength ); void prepend( const Blob &rSrc ); void prepend( const char *pSrc, int32_t iLength ); void insert( int32_t iBefore, const Blob &rSrc ); void insert( int32_t iBefore, const char *pSrc, const Blob &rSrc ); void clear(); int32_t getSize() const; BlobBuilder &operator=( const Blob &rSrc ); BlobBuilder &operator=( const char *pSrc ); BlobBuilder &operator+=( const Blob &rSrc ); BlobBuilder &operator+=( const char *pSrc ); private: }; }; #endif