The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

strings.h File Reference

#include <stddef.h>

Include dependency graph for strings.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Classes

struct  string

Typedefs

typedef string string

Functions

void string_append (string *, char *)
void string_append_range (string *, char *, char *)
char string_back (string *)
void string_copy (string *, char *)
void string_free (string *)
void string_new (string *)
void string_pop_back (string *)
void string_push_back (string *s, char x)
void string_reserve (string *, size_t)
void string_truncate (string *, size_t)
void string_unit_test ()


Typedef Documentation

typedef struct string string
 

Referenced by cmp_literal(), execcmd(), CommThread::GetClientIP(), list_new(), MPConfiguration::load(), main(), newstr(), MPConfiguration::record(), regexec(), MPConfiguration::stringval(), and yyparse().


Function Documentation

void string_append string ,
char * 
 

Definition at line 90 of file strings.c.

References assert_invariants(), string::capacity, end, extend_full(), p, string::size, and string::value.

Referenced by bindmodule(), builtin_normalize_path(), class_module_name(), import_base_rule(), new_module_str(), string_copy(), and var_expand().

00091 {
00092     char* p = self->value + self->size;
00093     char* end = self->value + self->capacity;
00094     assert_invariants( self );
00095     
00096     while ( *rhs && p != end)
00097         *p++ = *rhs++;
00098     
00099     if ( p != end )
00100     {
00101         *p = 0;
00102         self->size = p - self->value;
00103     }
00104     else
00105     {
00106         extend_full( self, rhs, rhs + strlen(rhs) );
00107     }
00108     assert_invariants( self );
00109 }

Here is the call graph for this function:

void string_append_range string ,
char *  ,
char * 
 

Definition at line 111 of file strings.c.

References assert_invariants(), string::capacity, end, extend_full(), p, string::size, and string::value.

Referenced by builtin_match(), file_build1(), path_build(), string_push_back(), var_defines(), and var_expand().

00112 {
00113     char* p = self->value + self->size;
00114     char* end = self->value + self->capacity;
00115     assert_invariants( self );
00116     
00117     while ( p != end && start != finish )
00118         *p++ = *start++;
00119     
00120     if ( p != end )
00121     {
00122         *p = 0;
00123         self->size = p - self->value;
00124     }
00125     else
00126     {
00127         extend_full( self, start, finish );
00128     }
00129     assert_invariants( self );
00130 }

Here is the call graph for this function:

char string_back string  ) 
 

Definition at line 156 of file strings.c.

References assert_invariants(), and string::value.

00157 {
00158     assert_invariants( self );
00159     return self->value[self->size - 1];
00160 }

Here is the call graph for this function:

void string_copy string ,
char * 
 

Definition at line 132 of file strings.c.

References s, string_append(), and string_new().

Referenced by builtin_caller_module(), builtin_normalize_path(), downcase_list(), new_module_str(), timestamp(), var_edit_shift(), and var_expand().

00133 {
00134     string_new( s );
00135     string_append( s, rhs );
00136 }

Here is the call graph for this function:

void string_free string  ) 
 

Definition at line 42 of file strings.c.

References assert_invariants(), string::opt, s, and string::value.

Referenced by bindmodule(), builtin_caller_module(), builtin_glob_back(), builtin_match(), builtin_normalize_path(), class_module_name(), downcase_list(), file_dirscan(), if(), import_base_rule(), new_module_str(), search(), search_for_target(), string_unit_test(), timestamp(), var_defines(), var_edit_shift(), and var_expand().

00043 {
00044     assert_invariants( s );
00045     if ( s->value != s->opt )
00046         free( s->value );
00047 }

Here is the call graph for this function:

void string_new string  ) 
 

Definition at line 30 of file strings.c.

References assert_invariants(), string::capacity, JAM_STRING_MAGIC, string::magic, string::opt, s, string::size, and string::value.

Referenced by bindmodule(), builtin_glob_back(), builtin_match(), builtin_normalize_path(), class_module_name(), downcase_list(), file_dirscan(), import_base_rule(), search(), search_for_target(), string_copy(), string_unit_test(), timestamp(), var_defines(), and var_expand().

00031 {
00032     s->value = s->opt;
00033     s->size = 0;
00034     s->capacity = sizeof(s->opt);
00035     s->opt[0] = 0;
00036 #ifndef NDEBUG
00037     memset(s->magic, JAM_STRING_MAGIC, sizeof(s->magic));
00038 #endif
00039     assert_invariants( s );
00040 }

Here is the call graph for this function:

void string_pop_back string  ) 
 

Definition at line 146 of file strings.c.

References string::size, and string_truncate().

Referenced by builtin_caller_module().

00147 {
00148     string_truncate( self, self->size - 1 );
00149 }

Here is the call graph for this function:

void string_push_back string s,
char  x
 

Definition at line 151 of file strings.c.

References string_append_range().

Referenced by bindmodule(), builtin_normalize_path(), file_build1(), import_base_rule(), path_build(), and string_unit_test().

00152 {
00153     string_append_range( self, &x, &x + 1 );
00154 }

Here is the call graph for this function:

void string_reserve string ,
size_t 
 

Definition at line 68 of file strings.c.

References assert_invariants(), and string_reserve_internal().

00069 {
00070     assert_invariants( self );
00071     if ( capacity <= self->capacity )
00072         return;
00073     string_reserve_internal( self, capacity );
00074     assert_invariants( self );
00075 }

Here is the call graph for this function:

void string_truncate string ,
size_t 
 

Definition at line 138 of file strings.c.

References assert_invariants(), and string::value.

Referenced by builtin_match(), file_dirscan(), search(), search_for_target(), string_pop_back(), timestamp(), var_defines(), var_expand(), and while().

00139 {
00140     assert_invariants( self );
00141     assert( n <= self->capacity );
00142     self->value[self->size = n] = 0;
00143     assert_invariants( self );
00144 }

Here is the call graph for this function:

void string_unit_test  ) 
 

Definition at line 163 of file strings.c.

References i, string::opt, s, string_free(), string_new(), string_push_back(), and string::value.

Referenced by run_unit_tests().

00164 {
00165     string s[1];
00166     int i;
00167     char buffer[sizeof(s->opt) * 2 + 2];
00168     int limit = sizeof(buffer) > 254 ? 254 : sizeof(buffer);
00169 
00170     string_new(s);
00171     
00172     for (i = 0; i < limit; ++i)
00173     {
00174         string_push_back( s, (char)(i + 1) );
00175     };
00176 
00177     for (i = 0; i < limit; ++i)
00178     {
00179         assert( i < s->size );
00180         assert( s->value[i] == (char)(i + 1));
00181     }
00182 
00183     string_free(s);
00184     
00185 }

Here is the call graph for this function:


Generated on Mon Nov 8 17:08:25 2004 for MPT by  doxygen 1.3.9.1