Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Deprecated/old_18mar_diff/String/StrData.inl

Go to the documentation of this file.
00001 #ifndef __J2K__JString_Data_INL__
00002 #define __J2K__JString_Data_INL__
00003 
00004 #include <j2k/Fred/String/StrData.hpp>
00005 
00006 ////////////////////////////////////////////////////////////////////////////
00007 /// Constructor, Copy Constructor and Destructor                         ///
00008 ////////////////////////////////////////////////////////////////////////////
00009 inline JStringData::JStringData()
00010   : nbRefs( 1 ), length( 0 ), lock( 0 ), bufferSize( 0 )
00011 {
00012   data = "";  
00013 }
00014 
00015 inline JStringData::JStringData( const char* s )
00016   : nbRefs( 1 ), lock( 0 ), length( 0 ), bufferSize( 0 )
00017 {
00018   Init( s, 0 );
00019 }
00020 
00021 inline JStringData::JStringData( const char* s, size_t nBuffer )
00022   : nbRefs( 1 ), lock( 0 ), length( 0 ), bufferSize( nBuffer )
00023 {
00024   Init( s, nBuffer );
00025 }
00026 
00027 inline JStringData::JStringData( const JStringData& sd )
00028   : nbRefs( 1 ), lock( 0 ), length( sd.length ), bufferSize( sd.bufferSize )
00029 {
00030   Init( sd.data, sd.bufferSize );
00031 }
00032 
00033 inline JStringData::JStringData( size_t nBuffer )
00034   : nbRefs( 1 ), length( 0 ), lock( 0 ), bufferSize( nBuffer )
00035 {
00036   InitBuffer( nBuffer, '\0' );
00037 }
00038 
00039 inline JStringData::JStringData( char fill, size_t nRepeat )
00040   : nbRefs( 1 ), length( nRepeat ), lock( 0 ), bufferSize( 0 )
00041 {
00042   InitBuffer( nRepeat, fill );
00043 }
00044 
00045 inline JStringData::JStringData( char fill, size_t nRepeat, size_t nBuffer )
00046   : nbRefs( 1 ), length( nRepeat ), lock( 0 ), bufferSize( nBuffer )
00047 {
00048   InitBuffer( nRepeat, fill );
00049 }
00050 
00051 inline JStringData::~JStringData()
00052 {
00053   if ( data != NULL  &&  *data != (char)NULL ) {
00054 
00055 #ifdef __J2K__DEBUG
00056      printf("\nDelete JStringData[%s]\n", data );
00057 #endif
00058 
00059 /** ANDREA ***************************************************
00060 JString();
00061   The previous remark means that here you may be calling
00062   delete[] on something that wasn't necessarely allocated
00063   with new[] and that wasn't owned by you anyway.
00064 
00065   I delete only if new[] was call no ?
00066 
00067 *************************************************************/
00068 
00069      delete[] data;
00070   }
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////////////
00074 /// Utilities and function helper                                        ///
00075 ////////////////////////////////////////////////////////////////////////////
00076 inline void JStringData::Dec() {
00077   if ( this == strNull  ||  lock != 0 ) return;
00078 
00079   if ( --nbRefs == 0 ) {   // If not used anymore,
00080 
00081 #ifdef __J2K__DEBUG
00082   printf("\nStringData[%s], Counter decrement[%d]\n", data, nbRefs );
00083 #endif
00084 
00085     delete this;       // then Suicide yourself ( Ahhhh... BANG! =) 
00086   }
00087 }
00088 
00089 inline void JStringData::Inc() {
00090   if ( this == strNull ) return;
00091 
00092 #ifdef __J2K__DEBUG
00093   printf("\nStringData[%s], Counter increment[%d]\n", data, nbRefs );
00094 #endif
00095 
00096   ++nbRefs;
00097 }
00098 
00099 #endif

Generated on Sun Oct 14 18:46:27 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001