Go to the documentation of this file.00001 #ifndef __BINARY_DATA_H__
00002 #define __BINARY_DATA_H__
00003
00004 #include <vector>
00005
00006 #include <utilities/exception.h>
00007 #include <utilities/testing_utilities.h>
00008
00009 #if !defined( WIN32_PLATFORM ) && !defined( NIX_PLATFORM ) && !defined( MINGW_PLATFORM ) && !defined( CYGWIN_PLATFORM )
00010 #define WIN32_PLATFORM
00011 #endif
00012
00013 #ifdef WIN32_PLATFORM
00014
00015
00016 #pragma warning( disable : 4251 )
00017 #endif
00018
00019 #ifdef BINARY_DATA
00020 #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM ) || defined( CYGWIN_PLATFORM )
00021 #define BINARY_DATA_DLL_ENTITY __declspec( dllexport )
00022 #endif
00023
00024 #if defined( NIX_PLATFORM )
00025 #define BINARY_DATA_DLL_ENTITY
00026 #endif
00027 #else
00028 #ifdef WIN32_PLATFORM
00029 #define BINARY_DATA_DLL_ENTITY __declspec( dllimport )
00030 #pragma comment( lib , "binary_data.lib" )
00031 #endif
00032
00033 #if defined( CYGWIN_PLATFORM ) || defined( MINGW_PLATFORM )
00034 #define BINARY_DATA_DLL_ENTITY __declspec( dllimport )
00035 #endif
00036
00037 #if defined( NIX_PLATFORM )
00038 #define BINARY_DATA_DLL_ENTITY
00039 #endif
00040 #endif
00041
00042 namespace nitro
00043 {
00056 class BINARY_DATA_DLL_ENTITY BinaryData{
00057
00058 public:
00059
00074 BinaryData( void );
00075
00094 BinaryData( const char & Ch );
00095
00114 BinaryData( const char * Buffer );
00115
00138 BinaryData( const char * Buffer , const std::size_t & Length );
00139
00158 BinaryData( const BinaryData & Data );
00159
00178 operator const char * () const;
00179
00198 BinaryData operator=( const BinaryData & Data );
00199
00218 void AppendData( const char & Ch );
00219
00238 void AppendData( const char * Buffer );
00239
00240 ALIAS_FUNCTION_1( AppendData , AppendData1 , const char * )
00241
00242
00260 void AppendData( const std::string & Buffer );
00261
00284 void AppendData( const char * Buffer , const std::size_t & Length );
00285
00286 ALIAS_FUNCTION_2( AppendData , tstAppendData , const char * , std::size_t )
00287
00288
00306 std::size_t GetBufferLength( void ) const;
00307
00326 const char * GetBuffer( void ) const;
00327
00350 void SetByte( std::size_t BytePos , char ByteValue );
00351
00366 void Release( void );
00367
00386 void Reserve( const std::size_t & theLength );
00387
00398 virtual ~BinaryData();
00399
00438 static int GetFirstOccurance( const char * OriginalBuffer , const std::size_t OriginalBufferLength , const char * Buffer , const std::size_t BufferLength , const std::size_t StartFrom = 0 );
00439
00474 static int GetFirstOccurance( const BinaryData & c , const char * Buffer , const std::size_t BufferLength , const std::size_t StartFrom = 0 );
00475
00510 static int GetOccuranceCount( const char * OriginalBuffer , const std::size_t OriginalBufferLength , const char * Buffer , const std::size_t BufferLength );
00511
00542 static int GetOccuranceCount( const BinaryData & c , const char * Buffer , const std::size_t BufferLength );
00543
00578 static void ReplaceBuffer( BinaryData & c , const std::size_t StartPos , const std::size_t ReplaceLength , const char * Buffer , const std::size_t BufferLength );
00579
00614 static void ReplaceBuffer( BinaryData & c , const char * NeedleBuffer , const std::size_t NeedleBufferLength , const char * Buffer , const std::size_t BufferLength );
00615
00616 private:
00617
00628 std::vector< char > Data;
00629 };
00630 }
00631
00632 #endif