Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

util_str.cpp File Reference

#include "util_str.h"
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>

Include dependency graph for util_str.cpp:

Include dependency graph

Go to the source code of this file.

Functions

idStr operator+ (const idStr &a, const unsigned b)
idStr operator+ (const idStr &a, const int b)
idStr operator+ (const idStr &a, const float b)
void TestStringClass (void)

Variables

const int STR_ALLOC_GRAN = 20


Function Documentation

idStr operator+ const idStr a,
const unsigned  b
 

Definition at line 316 of file util_str.cpp.

References a, idStr::append(), b, and sprintf().

00321    {
00322    char text[ 20 ];
00323 
00324     idStr result( a );
00325 
00326    sprintf( text, "%u", b );
00327     result.append( text );
00328 
00329     return result;
00330    }

Here is the call graph for this function:

idStr operator+ const idStr a,
const int  b
 

Definition at line 299 of file util_str.cpp.

References a, idStr::append(), b, and sprintf().

00304    {
00305    char text[ 20 ];
00306 
00307     idStr result( a );
00308 
00309    sprintf( text, "%d", b );
00310     result.append( text );
00311 
00312     return result;
00313    }

Here is the call graph for this function:

idStr operator+ const idStr a,
const float  b
 

Definition at line 282 of file util_str.cpp.

References a, idStr::append(), b, and sprintf().

00287    {
00288    char text[ 20 ];
00289 
00290     idStr result( a );
00291 
00292    sprintf( text, "%f", b );
00293     result.append( text );
00294 
00295     return result;
00296    }

Here is the call graph for this function:

void TestStringClass void   ) 
 

Definition at line 512 of file util_str.cpp.

References a, b, c, idStr::c_str(), ch, d, e, i, idStr::length(), NULL, and t.

00516     {
00517     char    ch;                         // ch == ?
00518     idStr   *t;                         // t == ?
00519     idStr   a;                              // a.len == 0, a.data == "\0"
00520     idStr   b;                              // b.len == 0, b.data == "\0"
00521     idStr   c( "test" );                // c.len == 4, c.data == "test\0"
00522     idStr   d( c );                     // d.len == 4, d.data == "test\0"
00523     idStr   e( reinterpret_cast<const char *>(NULL) );                  
00524                                  // e.len == 0, e.data == "\0"                  ASSERT!
00525     int i;                              // i == ?
00526 
00527     i = a.length();                 // i == 0
00528     i = c.length();                 // i == 4
00529 
00530     const char *s1 = a.c_str(); // s1 == "\0"
00531     const char *s2 = c.c_str(); // s2 == "test\0"
00532 
00533     t = new idStr();                        // t->len == 0, t->data == "\0"
00534     delete t;                           // t == ?
00535 
00536     b = "test";                         // b.len == 4, b.data == "test\0"
00537     t = new idStr( "test" );            // t->len == 4, t->data == "test\0"
00538     delete t;                           // t == ?
00539 
00540     a = c;                              // a.len == 4, a.data == "test\0"
00541 //   a = "";
00542    a = NULL;                            // a.len == 0, a.data == "\0"                   ASSERT!
00543     a = c + d;                          // a.len == 8, a.data == "testtest\0"
00544     a = c + "wow";                      // a.len == 7, a.data == "testwow\0"
00545     a = c + reinterpret_cast<const char *>(NULL);
00546                                  // a.len == 4, a.data == "test\0"          ASSERT!
00547     a = "this" + d;                 // a.len == 8, a.data == "thistest\0"
00548     a = reinterpret_cast<const char *>(NULL) + d;
00549                                  // a.len == 4, a.data == "test\0"          ASSERT!
00550     a += c;                             // a.len == 8, a.data == "testtest\0"
00551     a += "wow";                         // a.len == 11, a.data == "testtestwow\0"
00552     a += reinterpret_cast<const char *>(NULL);
00553                                  // a.len == 11, a.data == "testtestwow\0"  ASSERT!
00554 
00555     a = "test";                         // a.len == 4, a.data == "test\0"
00556     ch = a[ 0 ];                        // ch == 't'
00557     ch = a[ -1 ];                       // ch == 0                                          ASSERT!
00558     ch = a[ 1000 ];                 // ch == 0                                          ASSERT!
00559     ch = a[ 0 ];                        // ch == 't'
00560     ch = a[ 1 ];                        // ch == 'e'
00561     ch = a[ 2 ];                        // ch == 's'
00562     ch = a[ 3 ];                        // ch == 't'
00563     ch = a[ 4 ];                        // ch == '\0'                                       ASSERT!
00564     ch = a[ 5 ];                        // ch == '\0'                                       ASSERT!
00565 
00566     a[ 1 ] = 'b';                       // a.len == 4, a.data == "tbst\0"
00567     a[ -1 ] = 'b';                      // a.len == 4, a.data == "tbst\0"           ASSERT!
00568     a[ 0 ] = '0';                       // a.len == 4, a.data == "0bst\0"
00569     a[ 1 ] = '1';                       // a.len == 4, a.data == "01st\0"
00570     a[ 2 ] = '2';                       // a.len == 4, a.data == "012t\0"
00571     a[ 3 ] = '3';                       // a.len == 4, a.data == "0123\0"
00572     a[ 4 ] = '4';                       // a.len == 4, a.data == "0123\0"           ASSERT!
00573     a[ 5 ] = '5';                       // a.len == 4, a.data == "0123\0"           ASSERT!
00574     a[ 7 ] = '7';                       // a.len == 4, a.data == "0123\0"           ASSERT!
00575 
00576     a = "test";                         // a.len == 4, a.data == "test\0"
00577     b = "no";                           // b.len == 2, b.data == "no\0"
00578 
00579     i = ( a == b );                 // i == 0
00580     i = ( a == c );                 // i == 1
00581 
00582     i = ( a == "blow" );                // i == 0
00583     i = ( a == "test" );                // i == 1
00584     i = ( a == NULL );              // i == 0                                           ASSERT!
00585 
00586     i = ( "test" == b );                // i == 0
00587     i = ( "test" == a );                // i == 1
00588     i = ( NULL == a );              // i == 0                                           ASSERT!
00589 
00590     i = ( a != b );                 // i == 1
00591     i = ( a != c );                 // i == 0
00592 
00593     i = ( a != "blow" );                // i == 1
00594     i = ( a != "test" );                // i == 0
00595     i = ( a != NULL );              // i == 1                                           ASSERT!
00596 
00597     i = ( "test" != b );                // i == 1
00598     i = ( "test" != a );                // i == 0
00599     i = ( NULL != a );              // i == 1                                           ASSERT!
00600 
00601    a = "test";                   // a.data == "test"
00602    b = a;                        // b.data == "test"
00603 
00604    a = "not";                   // a.data == "not", b.data == "test"
00605 
00606    a = b;                        // a.data == b.data == "test"
00607 
00608    a += b;                       // a.data == "testtest", b.data = "test"
00609 
00610    a = b;
00611 
00612    a[1] = '1';                   // a.data = "t1st", b.data = "test"
00613     }

Here is the call graph for this function:


Variable Documentation

const int STR_ALLOC_GRAN = 20 [static]
 

Definition at line 35 of file util_str.cpp.


Generated on Thu Aug 25 15:34:52 2005 for Quake III Arena by  doxygen 1.3.9.1