Functions
vul_string.h File Reference

Utility functions for C strings and std::strings. More...

#include <string>
#include <vector>

Go to the source code of this file.

Functions

char * vul_string_c_upcase (char *)
 Converts all alphabetical characters to uppercase. More...
 
char * vul_string_c_downcase (char *)
 Converts all alphabetical characters to lowercase. More...
 
char * vul_string_c_capitalize (char *)
 Capitalizes all words in a string. More...
 
char * vul_string_c_trim (char *str, const char *rem)
 Removes any occurrences of rem from str, and returns the modified string. More...
 
char * vul_string_c_left_trim (char *str, const char *rem)
 Removes any prefix occurrence of rem from str and returns modified string. More...
 
char * vul_string_c_right_trim (char *str, const char *rem)
 Removes any suffix occurrence of rem from str and returns modified string. More...
 
char * vul_string_c_reverse (char *)
 Reverses the order of the characters in string. More...
 
std::string & vul_string_upcase (std::string &)
 Converts all alphabetical characters to uppercase. More...
 
std::string & vul_string_downcase (std::string &)
 Converts all alphabetical characters to lowercase. More...
 
std::string & vul_string_capitalize (std::string &)
 Capitalizes all words in string. More...
 
std::string & vul_string_trim (std::string &, const char *)
 Removes any occurrences of rem from str and returns modified string. More...
 
std::string & vul_string_left_trim (std::string &, const char *)
 Removes any prefix occurrence of rem from str and returns modified string. More...
 
std::string & vul_string_right_trim (std::string &, const char *)
 Removes any suffix occurrence of rem from str and returns modified string. More...
 
std::string & vul_string_reverse (std::string &)
 Reverses the order of the characters in string. More...
 
int vul_string_atoi (std::string const &)
 Reads an integer from a string. More...
 
double vul_string_atof (std::string const &s)
 Reads a double from a string. More...
 
double vul_string_atof_withsuffix (std::string const &s)
 Reads a double from a string, with k, kb, M, etc suffix. More...
 
bool vul_string_to_bool (const std::string &str)
 Convert a string to a boolean. More...
 
std::vector< int > vul_string_to_int_list (std::string str)
 Convert a string to a list of ints. More...
 

Detailed Description

Utility functions for C strings and std::strings.

Definition in file vul_string.h.

Function Documentation

◆ vul_string_atof()

double vul_string_atof ( std::string const &  s)

Reads a double from a string.

Definition at line 222 of file vul_string.cxx.

◆ vul_string_atof_withsuffix()

double vul_string_atof_withsuffix ( std::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, ki=2^10, M=10^6, Mi=2^20, G=10^9, Gi=2^30, T=10^12, Ti=2^40 The i suffix is from the IEC 60027 standard.

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 232 of file vul_string.cxx.

◆ vul_string_atoi()

int vul_string_atoi ( std::string const &  )

Reads an integer from a string.

Definition at line 217 of file vul_string.cxx.

◆ vul_string_c_capitalize()

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 49 of file vul_string.cxx.

◆ vul_string_c_downcase()

char* vul_string_c_downcase ( char *  )

Converts all alphabetical characters to lowercase.

Definition at line 36 of file vul_string.cxx.

◆ vul_string_c_left_trim()

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 81 of file vul_string.cxx.

◆ vul_string_c_reverse()

char* vul_string_c_reverse ( char *  )

Reverses the order of the characters in string.

Definition at line 116 of file vul_string.cxx.

◆ vul_string_c_right_trim()

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 100 of file vul_string.cxx.

◆ vul_string_c_trim()

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 63 of file vul_string.cxx.

◆ vul_string_c_upcase()

char* vul_string_c_upcase ( char *  )

Converts all alphabetical characters to uppercase.

Definition at line 24 of file vul_string.cxx.

◆ vul_string_capitalize()

std::string& vul_string_capitalize ( std::string &  )

Capitalizes all words in string.

Definition at line 163 of file vul_string.cxx.

◆ vul_string_downcase()

std::string& vul_string_downcase ( std::string &  )

Converts all alphabetical characters to lowercase.

Definition at line 155 of file vul_string.cxx.

◆ vul_string_left_trim()

std::string& vul_string_left_trim ( std::string &  ,
const char *   
)

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

Definition at line 198 of file vul_string.cxx.

◆ vul_string_reverse()

std::string& vul_string_reverse ( std::string &  )

Reverses the order of the characters in string.

Definition at line 132 of file vul_string.cxx.

◆ vul_string_right_trim()

std::string& vul_string_right_trim ( std::string &  ,
const char *   
)

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

Definition at line 208 of file vul_string.cxx.

◆ vul_string_to_bool()

bool vul_string_to_bool ( const std::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 281 of file vul_string.cxx.

◆ vul_string_to_int_list()

std::vector<int> vul_string_to_int_list ( std::string  str)

Convert a string to a list of ints.

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 301 of file vul_string.cxx.

◆ vul_string_trim()

std::string& vul_string_trim ( std::string &  ,
const char *   
)

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

Definition at line 184 of file vul_string.cxx.

◆ vul_string_upcase()

std::string& vul_string_upcase ( std::string &  )

Converts all alphabetical characters to uppercase.

Definition at line 147 of file vul_string.cxx.