Defines | Functions
core/vul/vul_string.cxx File Reference
#include "vul_string.h"
#include <vcl_cassert.h>
#include <vcl_cstdlib.h>
#include <vcl_cstring.h>
#include <vcl_cctype.h>
#include <vcl_algorithm.h>
#include <vcl_sstream.h>
#include <vcl_cmath.h>
#include <vul/vul_reg_exp.h>
#include <vul/vul_sprintf.h>

Go to the source code of this file.

Defines

#define END_OF_STRING   (0)
#define REGEXP_INTEGER   "\\-?[0123456789]+"

Functions

char * vul_string_c_upcase (char *s)
 Converts all alphabetical characters to uppercase.
char * vul_string_c_downcase (char *s)
 Converts all alphabetical characters to lowercase.
char * vul_string_c_capitalize (char *s)
 Capitalizes all words in a string.
char * vul_string_c_trim (char *str, const char *rem)
 Removes any occurrences of rem from str, and returns the modified string.
char * vul_string_c_left_trim (char *str, const char *rem)
 Removes any prefix occurrence of rem from str and returns modified string.
char * vul_string_c_right_trim (char *str, const char *rem)
 Removes any suffix occurrence of rem from str and returns modified string.
char * vul_string_c_reverse (char *c)
 Reverses the order of the characters in string.
vcl_string & vul_string_reverse (vcl_string &s)
 Reverses the order of the characters in string.
vcl_string & vul_string_upcase (vcl_string &s)
 Converts all alphabetical characters to uppercase.
vcl_string & vul_string_downcase (vcl_string &s)
 Converts all alphabetical characters to lowercase.
vcl_string & vul_string_capitalize (vcl_string &s)
 Capitalizes all words in string.
vcl_string & vul_string_trim (vcl_string &sr, const char *rem)
 Removes any occurrences of rem from str and returns modified string.
vcl_string & vul_string_left_trim (vcl_string &sr, const char *rem)
 Removes any prefix occurrence of rem from str and returns modified string.
vcl_string & vul_string_right_trim (vcl_string &sr, const char *rem)
 Removes any suffix occurrence of rem from str and returns modified string.
int vul_string_atoi (vcl_string const &s)
 Reads an integer from a string.
double vul_string_atof (vcl_string const &s)
 Reads a double from a string.
double vul_string_atof_withsuffix (vcl_string const &s)
 Reads a double from a string, with k, kb, M, etc suffix.
bool vul_string_to_bool (const vcl_string &str)
 Convert a string to a boolean.
vcl_vector< int > vul_string_to_int_list (vcl_string str)
 Convert a string to a list of ints, using the matlab index format.
bool vul_string_expand_var (vcl_string &str)
 Expand any environment variables in the string.
bool vul_string_replace (vcl_string &full_str, const vcl_string &find_str, const vcl_string &replace_str, int num_times)
 replaces instances "find_str" in "full_str" with "replace_str" a given "num_times".
vcl_string vul_string_escape_ctrl_chars (const vcl_string &in)
 Replace control chars with escaped representations.

Detailed Description

Definition in file vul_string.cxx.


Define Documentation

#define END_OF_STRING   (0)

Definition at line 17 of file vul_string.cxx.

#define REGEXP_INTEGER   "\\-?[0123456789]+"

Function Documentation

double vul_string_atof ( vcl_string const &  s)

Reads a double from a string.

Definition at line 219 of file vul_string.cxx.

double vul_string_atof_withsuffix ( vcl_string const &  s)

Reads a double from a string, with k, kb, M, etc suffix.

No space is allowed between the number and the suffix. k=10^3, kb=2^10, M=10^6, Mb=2^20, G=10^9, Gb=2^30, T=10^12, Tb=2^40 If parse fails, return 0.0;

Definition at line 229 of file vul_string.cxx.

int vul_string_atoi ( vcl_string const &  s)

Reads an integer from a string.

Definition at line 214 of file vul_string.cxx.

char* vul_string_c_capitalize ( char *  )

Capitalizes all words in a string.

A word is defined as a sequence of characters separated by non-alphanumerics.

Definition at line 46 of file vul_string.cxx.

char* vul_string_c_downcase ( char *  s)

Converts all alphabetical characters to lowercase.

Definition at line 33 of file vul_string.cxx.

char* vul_string_c_left_trim ( char *  str,
const char *  rem 
)

Removes any prefix occurrence of rem from str and returns modified string.

Definition at line 78 of file vul_string.cxx.

char* vul_string_c_reverse ( char *  c)

Reverses the order of the characters in string.

Definition at line 113 of file vul_string.cxx.

char* vul_string_c_right_trim ( char *  str,
const char *  rem 
)

Removes any suffix occurrence of rem from str and returns modified string.

Definition at line 97 of file vul_string.cxx.

char* vul_string_c_trim ( char *  str,
const char *  rem 
)

Removes any occurrences of rem from str, and returns the modified string.

Definition at line 60 of file vul_string.cxx.

char* vul_string_c_upcase ( char *  s)

Converts all alphabetical characters to uppercase.

Definition at line 21 of file vul_string.cxx.

vcl_string& vul_string_capitalize ( vcl_string &  s)

Capitalizes all words in string.

Definition at line 160 of file vul_string.cxx.

vcl_string& vul_string_downcase ( vcl_string &  s)

Converts all alphabetical characters to lowercase.

Definition at line 152 of file vul_string.cxx.

vcl_string vul_string_escape_ctrl_chars ( const vcl_string &  in)

Replace control chars with escaped representations.

Space and "\n" are preserved, but tabs, CR, etc are escaped. This is not aimed and is not suitable for any particular input-validation security problem, such as sql-injection.

Definition at line 508 of file vul_string.cxx.

bool vul_string_expand_var ( vcl_string &  str)

Expand any environment variables in the string.

Expands "foo\f$VARfoo" to "foobarfoo" when $VAR=bar. If both $VAR and $VARfoo exist, an arbitrary choice will be made of which variable to use. This problem can be avoided by using the syntax "foo${VAR}foo." " $(VAR)" and "$[VAR]" can also be used. There are no inbuilt variables like in shell scripting, and variable names cannot contain whitespace or "$"s. "$$" can be used to insert a literal "

Definition at line 384 of file vul_string.cxx.

vcl_string& vul_string_left_trim ( vcl_string &  sr,
const char *  rem 
)

Removes any prefix occurrence of rem from str and returns modified string.

Definition at line 195 of file vul_string.cxx.

bool vul_string_replace ( vcl_string &  full_str,
const vcl_string &  find_str,
const vcl_string &  replace_str,
int  num_times 
)

replaces instances "find_str" in "full_str" with "replace_str" a given "num_times".

Returns:
true iff at least one replacement took place.

Definition at line 481 of file vul_string.cxx.

vcl_string& vul_string_reverse ( vcl_string &  s)

Reverses the order of the characters in string.

Definition at line 129 of file vul_string.cxx.

vcl_string& vul_string_right_trim ( vcl_string &  sr,
const char *  rem 
)

Removes any suffix occurrence of rem from str and returns modified string.

Definition at line 205 of file vul_string.cxx.

bool vul_string_to_bool ( const vcl_string &  str)

Convert a string to a boolean.

Looks for On, true, yes, 1 to mean true. everything else is false. It ignores leading and trailing whitespace and capitalisation.

Definition at line 278 of file vul_string.cxx.

vcl_vector<int> vul_string_to_int_list ( vcl_string  str)

Convert a string to a list of ints, using the matlab index format.

Convert a string to a list of ints.

e.g. "0,1,10:14,20:-2:10" results in 0,1,10,11,12,13,14,20,18,16,14,12,10 No spaces are allowed.

Returns:
empty on error.

Definition at line 298 of file vul_string.cxx.

vcl_string& vul_string_trim ( vcl_string &  sr,
const char *  rem 
)

Removes any occurrences of rem from str and returns modified string.

Definition at line 181 of file vul_string.cxx.

vcl_string& vul_string_upcase ( vcl_string &  s)

Converts all alphabetical characters to uppercase.

Definition at line 144 of file vul_string.cxx.