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

C:/temp/src/j2k/Fred/String/StrBuild.inl

Go to the documentation of this file.
00001 #ifndef __J2K__JString_Build_INL__
00002 #define __J2K__JString_Build_INL__
00003 
00004 #include <j2k/Fred/String/String.hpp>
00005 
00006 ////////////////////////////////////////////////////////////////////////////
00007 /// Constructor, Copy Constructor and Destructor                         ///
00008 ////////////////////////////////////////////////////////////////////////////
00009 
00010 inline JString::JString() 
00011   : pData( strNull ) { }
00012 
00013 inline JString::JString( JStringData* sd )
00014   : pData( sd ) { }
00015 
00016 inline JString::JString( const char* s ) 
00017 {
00018   if ( s != NULL  &&  *s != (char)NULL ) {
00019     pData = new JStringData( s );
00020   } else {
00021     pData = strNull;
00022   }
00023 }
00024 
00025 // Deprecated due to NULL problems
00026 #if 0
00027 // Why not doing it in a single shot, since it's possible ! =)
00028 /*
00029 JString::JString( size_t nBuffer ) {
00030   if ( nBuffer < 1 ) {
00031     pData = strNull; 
00032   } else {
00033     pData = new JStringData( nBuffer );
00034   }
00035 }
00036 */
00037 #endif
00038 
00039 // Gentle and expand as appropriate.
00040 // WARNING: The JString version is strict and rip-off anything after the specified
00041 // buffer size for efficiency and to make it easier to implement at() functions.
00042 inline JString::JString( const char* s, size_t nBuffer ) 
00043 {
00044   if ( s != NULL  &&  *s != (char)NULL ) {
00045   
00046     register size_t len = strlen( s );
00047 
00048     if ( len > nBuffer ) {
00049       pData = new JStringData( s, len );
00050     } else {
00051       pData = new JStringData( s, nBuffer );
00052     }  
00053 
00054   } else {
00055 
00056     if ( nBuffer < 1 ) {               // No Buffer 
00057       pData = strNull;
00058     } else {                           // With Buffer
00059       pData = new JStringData( nBuffer );  
00060     }     
00061 
00062   }
00063 }
00064 
00065 inline JString::JString( char ch )
00066   : pData( new JStringData( ch, 1 ) ) { }
00067 
00068 inline JString::JString( char ch, size_t nRepeat )
00069   : pData( new JStringData( ch, nRepeat ) ) { }
00070 
00071 // There should be no copy done, the optimize way for that one,
00072 // unless it's lock or something like that...
00073 inline JString::JString( const JString& src )
00074   : pData( src.pData )
00075 {
00076   pData->Inc();
00077 }
00078 
00079 // Free any attached data
00080 inline JString::~JString() {
00081 
00082 #ifdef __J2K__DEBUG
00083   printf("\nDelete JString[%s]\n", pData->data );
00084 #endif
00085 
00086   pData->Dec();
00087 }
00088 
00089 #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