#include <string>
#include <vector>
#include <sstream>
Go to the source code of this file.
Functions | |
int | getlinePortable (std::istream &istr, std::string &line) |
Read a line from input stream. | |
bool | isEscaped (const std::string &str, std::string::size_type pos) |
Check whether the character is escaped or not. | |
std::string | escape (const std::string str) |
Escape string. | |
std::string | unescape (const std::string str) |
Unescape string. | |
void | eraseHeadBlank (std::string &str) |
Erase the head blank characters of string. | |
void | eraseTailBlank (std::string &str) |
Erase the tail blank characters of string. | |
void | replaceString (std::string &str, const std::string from, const std::string to) |
Replace string. | |
std::vector < std::string > | split (const std::string &input, const std::string &delimiter) |
Split string by delimiter. | |
bool | toBool (std::string str, std::string yes, std::string no, bool default_value=true) |
Convert given string into bool value. | |
bool | isAbsolutePath (const std::string &str) |
Investigate whether the given string is absolute path or not. | |
bool | isURL (const std::string &str) |
Investigate whether the given string is URL or not. | |
template<class Printable> | |
std::string | otos (Printable n) |
Convert the given object to std::string. | |
template<typename To> | |
bool | stringTo (To &val, const char *str) |
Convert the given std::string to object. | |
std::vector < std::string > | unique_sv (std::vector< std::string > sv) |
Eliminate duplication from the given string list. | |
std::string | flatten (std::vector< std::string > sv) |
Create CSV file from the given string list. | |
char ** | toArgv (const std::vector< std::string > &args) |
Convert the given string list into the argument list. |
void eraseHeadBlank | ( | std::string & | str | ) |
Erase the head blank characters of string.
Erase the blank characters that exist at the head of the given string. Space ' 'and tab '\t' are supported as the blank character.
str | The target head blank characters of string for the erase |
void eraseTailBlank | ( | std::string & | str | ) |
Erase the tail blank characters of string.
Erase the blank characters that exist at the tail of the given string. Space ' 'and tab '\t' are supported as the blank character.
str | The target tail blank characters of string for the erase |
std::string escape | ( | const std::string | str | ) |
Escape string.
The following characters are converted.
HT -> "\t"
LF -> "\n"
CR -> "\r"
FF -> "\f"
Single quote and double quote are not processed.
str | The target string for the escape |
std::string flatten | ( | std::vector< std::string > | sv | ) |
Create CSV file from the given string list.
Create CSV that arranged each element of the character string list given by the argument. If the string list is empty, the null will be returned.
sv | The target string list for creating CSV |
int getlinePortable | ( | std::istream & | istr, | |
std::string & | line | |||
) |
Read a line from input stream.
This function reads a line from input stream. UNIX, Windows or mixed line feed code is acceptable.
istr | The input stream. | |
line | The output variable to store string to be read. |
bool isAbsolutePath | ( | const std::string & | str | ) |
Investigate whether the given string is absolute path or not.
Investigate whether the given string is absolute path or not. Investigate it as an absolute path, if the string is as follows:
str | The target string for the investigation |
bool isEscaped | ( | const std::string & | str, | |
std::string::size_type | pos | |||
) |
Check whether the character is escaped or not.
Check whether the specified character is escaped or not
str | The string that includes the character to be investigated. | |
pos | The position of the character to be investigated. |
bool isURL | ( | const std::string & | str | ) |
Investigate whether the given string is URL or not.
Investigate whether the given string is URL or not. When the string '://' is included in the given character string, make it of URL representation.
str | The target string for investigation |
std::string otos | ( | Printable | n | ) | [inline] |
Convert the given object to std::string.
Convert the object specified by the argument to string.
n | The target object for conversion |
void replaceString | ( | std::string & | str, | |
const std::string | from, | |||
const std::string | to | |||
) |
Replace string.
Replace the given string with the specified characters.
str | The target characters of string for replacement processing | |
from | Characters of replacement source | |
to | Characters of replacement destination |
std::vector<std::string> split | ( | const std::string & | input, | |
const std::string & | delimiter | |||
) |
Split string by delimiter.
Split the set string by the given delimiter
input | The target characters of string for split | |
delimiter | Split string (delimiter) |
bool stringTo | ( | To & | val, | |
const char * | str | |||
) | [inline] |
Convert the given std::string to object.
Convert string given by the argument to specified object.
val | The object of conversion destination | |
str | String of conversion source |
char** toArgv | ( | const std::vector< std::string > & | args | ) |
Convert the given string list into the argument list.
Convert the string list into the argument list by adding '\0' to each element at the end of the string list given by the argument
args | The target string list for conversion |
bool toBool | ( | std::string | str, | |
std::string | yes, | |||
std::string | no, | |||
bool | default_value = true | |||
) |
Convert given string into bool value.
Compare the specified string with the true representation string and the false representation string, and return the result as bool value. If it matches neither the true representation string nor the false representation string as a result of the comparison, the given default value will be return.
str | The target string for investigation | |
yes | The true representation string | |
no | The false representation string | |
default_value | The default value (The default value:true) |
std::string unescape | ( | const std::string | str | ) |
Unescape string.
The following characters are converted.
"\t" -> HT
"\n" -> LF
"\r" -> CR
"\f" -> FF
"\"" -> "
"\'" -> '
Note: This is not complete inversion of the escape processing.
str | The target string for the unescape |
std::vector<std::string> unique_sv | ( | std::vector< std::string > | sv | ) |
Eliminate duplication from the given string list.
Create a list of eliminating duplication from the string list given by the argument.
sv | The string list for confirmation source |