Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/putil/string_utils.cxx File Reference

#include "string_utils.h"
#include <ctype.h>

Go to the source code of this file.

Functions

int cmp_nocase (const string &s, const string &s2)
int toupper_uh (int ch)
int cmp_nocase_uh (const string &s, const string &s2)
string downcase (const string &s)
 Returns the input string with all uppercase letters converted to lowercase.

string upcase (const string &s)
 Returns the input string with all lowercase letters converted to uppercase.

int extract_words (const string &str, vector_string &words)
 Divides the string into a number of words according to whitespace.

void tokenize (const string &str, vector_string &words, const string &delimiters)
 Chops the source string up into pieces delimited by any of the characters specified in delimiters.

string trim_left (const string &str)
 Returns a new string representing the contents of the given string with the leading whitespace removed.

string trim_right (const string &str)
 Returns a new string representing the contents of the given string with the trailing whitespace removed.

int string_to_int (const string &str, string &tail)
 A string-interface wrapper around the C library strtol().

bool string_to_int (const string &str, int &result)
 Another flavor of string_to_int(), this one returns true if the string is a perfectly valid integer (and sets result to that value), or false otherwise.

double string_to_double (const string &str, string &tail)
 A string-interface wrapper around the C library strtol().

bool string_to_double (const string &str, double &result)
 Another flavor of string_to_double(), this one returns true if the string is a perfectly valid number (and sets result to that value), or false otherwise.

bool string_to_float (const string &str, float &result)
 Another flavor of string_to_float(), this one returns true if the string is a perfectly valid number (and sets result to that value), or false otherwise.


Detailed Description

Definition in file string_utils.cxx.


Function Documentation

int cmp_nocase const string &  s,
const string &  s2
 

Definition at line 29 of file string_utils.cxx.

int cmp_nocase_uh const string &  s,
const string &  s2
 

Definition at line 52 of file string_utils.cxx.

References toupper_uh().

Referenced by EggGroup::get_vertex_membership(), EggGroup::has_object_type(), EggGroup::set_group_type(), EggTexture::string_format(), EggGroup::test_vref_integrity(), and EggGroup::unref_vertex().

string downcase const string &  s  ) 
 

Returns the input string with all uppercase letters converted to lowercase.

Definition at line 80 of file string_utils.cxx.

Referenced by LoaderFileTypeRegistry::get_num_types().

int extract_words const string &  str,
vector_string &  words
 

Divides the string into a number of words according to whitespace.

The words vector should be cleared by the user before calling; otherwise, the list of words in the string will be appended to the end of whatever was there before.

The return value is the number of words extracted.

Definition at line 131 of file string_utils.cxx.

bool string_to_double const string &  str,
double &  result
 

Another flavor of string_to_double(), this one returns true if the string is a perfectly valid number (and sets result to that value), or false otherwise.

Definition at line 327 of file string_utils.cxx.

Referenced by string_to_int().

double string_to_double const string &  str,
string &  tail
 

A string-interface wrapper around the C library strtol().

This parses the ASCII representation of an floating-point number, and then sets tail to everything that follows the first valid integer read. If, on exit, str == tail, there was no valid integer in the source string; if !tail.empty(), there was garbage after the number.

It is legal if str and tail refer to the same string.

Definition at line 305 of file string_utils.cxx.

bool string_to_float const string &  str,
float &  result
 

Another flavor of string_to_float(), this one returns true if the string is a perfectly valid number (and sets result to that value), or false otherwise.

Definition at line 347 of file string_utils.cxx.

bool string_to_int const string &  str,
int &  result
 

Another flavor of string_to_int(), this one returns true if the string is a perfectly valid integer (and sets result to that value), or false otherwise.

Definition at line 275 of file string_utils.cxx.

Referenced by VrpnClient::do_poll(), get_command_line_filenames(), and main().

int string_to_int const string &  str,
string &  tail
 

A string-interface wrapper around the C library strtol().

This parses the ASCII representation of an integer, and then sets tail to everything that follows the first valid integer read. If, on exit, str == tail, there was no valid integer in the source string; if !tail.empty(), there was garbage after the integer.

It is legal if str and tail refer to the same string.

Definition at line 255 of file string_utils.cxx.

void tokenize const string &  str,
vector_string &  words,
const string &  delimiters
 

Chops the source string up into pieces delimited by any of the characters specified in delimiters.

Repeated delimiter characters represent zero-length tokens.

It is the user's responsibility to ensure the output vector is cleared before calling this function; the results will simply be appended to the end of the vector.

Definition at line 178 of file string_utils.cxx.

References size_t.

int toupper_uh int  ch  )  [inline]
 

Definition at line 46 of file string_utils.cxx.

Referenced by cmp_nocase_uh().

string trim_left const string &  str  ) 
 

Returns a new string representing the contents of the given string with the leading whitespace removed.

Definition at line 202 of file string_utils.cxx.

string trim_right const string &  str  ) 
 

Returns a new string representing the contents of the given string with the trailing whitespace removed.

Definition at line 221 of file string_utils.cxx.

string upcase const string &  s  ) 
 

Returns the input string with all lowercase letters converted to uppercase.

Definition at line 100 of file string_utils.cxx.

References size_t.


Generated on Fri May 2 00:46:12 2003 for Panda by doxygen1.3