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

C:/temp/src/j2k/Fred/String/StrAdd.cpp File Reference

#include <j2k/Fred/String/String.hpp>

Go to the source code of this file.

Functions

JString operator+ (const JString &S1, const JString &S2)
JString operator+ (const JString &S1, const char *s2)
JString operator+ (const char *s1, const JString &S2)
JString operator+ (const JString &S1, char c)
JString operator+ (char c, const JString &S2)


Function Documentation

JString operator+ char    c,
const JString   S2
 

Definition at line 268 of file StrAdd.cpp.

00268                                               {
00269   JString* s = new JString();            // JStringData = &strNull
00270   char s1[2] = { c, '\0' };
00271   
00272   if ( c == '\0'  || c == (char)NULL ) { // No addition needed
00273      s->pData = S2.pData;                // s1 is NULL, assign S2  
00274   } else if ( S2.pData == strNull ) {
00275      s->pData = new JStringData( c );    // Only s1 is not NULL
00276   } else {                               // Normal Addition, None are NULL
00277      s->Add( s1, S2.pData->data, 1, S2.pData->length );
00278   }
00279   
00280   assert( s->pData->data[s->pData->length] == '\0');
00281  
00282   return *s;
00283 }

JString operator+ const JString   S1,
char    c
 

Definition at line 251 of file StrAdd.cpp.

00251                                              {
00252   JString* s = new JString();             // JStringData = &strNull
00253   char s2[2] = { c, '\0' };
00254 
00255   if ( c == '\0'  || c == (char)NULL ) { // No addition needed
00256      s->pData = S1.pData;
00257   } else if ( S1.pData == strNull ) {
00258      s->pData = new JStringData( c );    // Only s2 is not NULL
00259   } else {                               // Normal Addition, None are NULL
00260      S1.pData->data[ S1.pData->length ] = '\0';   // Safety feature   
00261      s->Add( S1.pData->data, s2, S1.pData->length, 1 );
00262   }
00263  
00264   assert( s->pData->data[s->pData->length] == '\0');
00265   return *s;
00266 }

JString operator+ const char *    s1,
const JString   S2
 

Definition at line 234 of file StrAdd.cpp.

00234                                                      {
00235   JString* s = new JString();            // JStringData = &strNull
00236 
00237   if ( s1 == NULL  ||  *s1 == (char)NULL ) {   // No addition needed
00238      s->pData = S2.pData;                // s1 is NULL, assign S2
00239   } else if ( S2.pData == strNull ) {
00240      s->pData = new JStringData( s1 );   // Only s1 is not NULL
00241   } else {                               // Normal Addition, None are NULL
00242      size_t Len = strlen( s1 );
00243      s->Add( s1, S2.pData->data, Len, S2.pData->length );
00244   }
00245 
00246   assert( s->pData->data[s->pData->length] == '\0');
00247 
00248   return *s;
00249 }

JString operator+ const JString   S1,
const char *    s2
 

Definition at line 216 of file StrAdd.cpp.

00216                                                      {
00217   JString* s = new JString();            // JStringData = &strNull
00218 
00219   if ( s2 == NULL || *s2 == (char)NULL ) {     // No addition needed
00220      s->pData = S1.pData;
00221   } else if ( S1.pData == strNull ) {
00222      s->pData = new JStringData( s2 );   // Only s2 is not NULL
00223   } else {                               // Normal Addition, None are NULL
00224      S1.pData->data[ S1.pData->length ] = '\0';   // Safety feature
00225 
00226      size_t Len = strlen( s2 );
00227      s->Add( S1.pData->data, s2, S1.pData->length, Len );
00228   }
00229 
00230   assert( s->pData->data[s->pData->length] == '\0');
00231   return *s;
00232 }

JString operator+ const JString   S1,
const JString   S2
 

Definition at line 186 of file StrAdd.cpp.

00186                                                         {
00187   JString* s = new JString();         // JStringData = &strNull
00188 
00189   if ( S1.pData == strNull ) {
00190      // S1.pData->Dec();            // Not Needed, NO decrement on Null
00191      s->pData = S2.pData;           // S1 is NULL, assign S2.
00192 
00193      S2.pData->Inc();
00194 
00195      // Inc() & Dec() checks for strNull and don't increase or decrease it
00196 
00197   } else if ( S2.pData == strNull ) {
00198      // S2.pData->Dec();            // Not Needed, NO decrement on Null
00199      s->pData = S1.pData;           // S2 is NULL, assign S1.
00200      S1.pData->Inc();              
00201   } else {                          // Normal Addition, None are NULL
00202 
00203      // Will change this == 's', 
00204      // it works since 's' call it's own function !
00205      S1.pData->data[ S1.pData->length ] = '\0';   // Safety feature
00206      S2.pData->data[ S2.pData->length ] = '\0';   // Safety feature
00207 
00208      s->Add( S1.pData->data,   S2.pData->data,
00209              S1.pData->length, S2.pData->length );
00210   }
00211 
00212   assert( s->pData->data[s->pData->length] == '\0');
00213   return *s;
00214 }


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