Main Page | Namespace List | Class List | File List | Namespace Members | Class Members | Related Pages

str Namespace Reference

Functions for handling strings. More...


[NOHEADER]

long str2long (const char *str, bool *ok)
 Convert a string to numeric value.

double str2float (const char *str, bool *ok)
long str2long (std::string *str, bool *ok)
double str2float (std::string *str, bool *ok)

Functions

bool read_line (std::string *str, FILE *file, bool do_chomp)
 Read a line from a file.

bool read_string (std::string *str, size_t length, FILE *file)
 Read a string of given length from a file.

void chomp (std::string *str)
 Remove the possible trailing newline from a string.

void clean (std::string *str, const char *chars)
 Remove leading and trailing characters from a string.

void split (const std::string *str, const char *delims, bool group, std::vector< std::string > *strings, int fields)
 Split a string to fields.


Detailed Description

Functions for handling strings.

Function Documentation

void str::clean std::string *  str,
const char *  chars
 

Remove leading and trailing characters from a string.

Parameters:
str = the string to be cleaned
chars = the characters to clean from the string

bool str::read_line std::string *  str,
FILE *  file = stdin,
bool  do_chomp = false
 

Read a line from a file.

Parameters:
str = the string to read to
file = the file to read from
do_chomp = should we chomp the possible newline at the end
Returns:
false if no more lines in the file

bool str::read_string std::string *  str,
size_t  length,
FILE *  file = stdin
 

Read a string of given length from a file.

Parameters:
str = the string to read to
length = the bytes to read
file = the file to read from
Returns:
false if could not read length bytes

void str::split const std::string *  str,
const char *  chars,
bool  group,
std::vector< std::string > *  strings,
int  fields = 0
 

Split a string to fields.

If fields is positive, it specifies the maximum number of fields. If the line contains more fields, they are included in the last field as such (also possible delimiters without processing).

Parameters:
str = the string to be splitted
chars = the delimiter characters
group = group subsequent delimiters as one delimeter
strings = the vector containing the resulting fields
fields = the maximum number of fields to return


Generated on Sat Feb 26 22:54:39 2005 for GoCam by doxygen 1.3.4