#include <string>
#include <vector>
#include <sstream>
関数 | |
int | getlinePortable (std::istream &istr, std::string &line) |
入力ストリームから1行読み込む | |
bool | isEscaped (const std::string &str, std::string::size_type pos) |
文字列がエスケープされているか判断する | |
std::string | escape (const std::string str) |
文字列をエスケープする | |
std::string | unescape (const std::string str) |
文字列のエスケープを戻す | |
void | eraseHeadBlank (std::string &str) |
文字列の先頭の空白文字を削除する | |
void | eraseTailBlank (std::string &str) |
文字列の末尾の空白文字を削除する | |
void | replaceString (std::string &str, const std::string from, const std::string to) |
文字列を置き換える | |
std::vector < std::string > | split (const std::string &input, const std::string &delimiter) |
文字列を分割文字で分割する | |
bool | toBool (std::string str, std::string yes, std::string no, bool default_value=true) |
与えられた文字列をbool値に変換する | |
bool | isAbsolutePath (const std::string &str) |
与えられた文字列が絶対パスかどうかを判断する | |
bool | isURL (const std::string &str) |
与えられた文字列がURLかどうかを判断する | |
template<class Printable> | |
std::string | otos (Printable n) |
与えられたオブジェクトをstdstringに変換 | |
template<typename To> | |
bool | stringTo (To &val, const char *str) |
与えられたstdstringをオブジェクトに変換 | |
std::vector < std::string > | unique_sv (std::vector< std::string > sv) |
与えられた文字列リストから重複を削除 | |
std::string | flatten (std::vector< std::string > sv) |
与えられた文字列リストからCSVを生成 | |
char ** | toArgv (const std::vector< std::string > &args) |
与えられた文字列リストを引数リストに変換 |
void eraseHeadBlank | ( | std::string & | str | ) |
文字列の先頭の空白文字を削除する
与えられた文字列の先頭に存在する空白文字を削除する。 空白文字として扱うのは' '(スペース)と'\t'(タブ)。
str | 先頭空白文字削除処理文字列 |
void eraseTailBlank | ( | std::string & | str | ) |
文字列の末尾の空白文字を削除する
与えられた文字列の末尾に存在する空白文字を削除する。 空白文字として扱うのは' '(スペース)と'\t'(タブ)。
str | 末尾空白文字削除処理文字列 |
std::string escape | ( | const std::string | str | ) |
文字列をエスケープする
次の文字をエスケープシーケンスに変換する。
HT -> "\t"
LF -> "\n"
CR -> "\r"
FF -> "\f"
シングルクオート、ダブルクオートについてはとくに処理はしない。
str | エスケープ処理対象文字列 |
std::string flatten | ( | std::vector< std::string > | sv | ) |
与えられた文字列リストからCSVを生成
引数で与えられた文字列リストの各要素を並べたCSVを生成する。 文字列リストが空の場合には空白文字を返す。
sv | CSV変換対象文字列リスト |
int getlinePortable | ( | std::istream & | istr, | |
std::string & | line | |||
) |
入力ストリームから1行読み込む
入力ストリームから1行読み込む。 入力ストリームはの改行コードはUNIX, Windowsの改行コードのいずれか、 もしくは混在していてもよい。
istr | 入力ストリーム | |
line | 読み込んだ文字列を格納する変数 |
bool isAbsolutePath | ( | const std::string & | str | ) |
与えられた文字列が絶対パスかどうかを判断する
与えられた文字列が絶対パス表現であるかどうかを判断する。 文字列が以下の場合には絶対パスとして判断する。
str | 判定対象文字列 |
bool isEscaped | ( | const std::string & | str, | |
std::string::size_type | pos | |||
) |
文字列がエスケープされているか判断する
指定された文字がエスケープされているかどうかを判断する。
str | エスケープされているかどうか判断する文字を含む文字列 | |
pos | エスケープされているかどうか判断する文字の位置 |
bool isURL | ( | const std::string & | str | ) |
与えられた文字列がURLかどうかを判断する
与えられた文字列がURL表現かどうかを判断する。 与えられた文字列中に、'://'という文字列が含まれている場合には URL表現として判断する。
str | 判定対象文字列 |
std::string otos | ( | Printable | n | ) | [inline] |
与えられたオブジェクトをstdstringに変換
引数で指定されたオブジェクトを文字列に変換する。
n | 変換対象オブジェクト |
void replaceString | ( | std::string & | str, | |
const std::string | from, | |||
const std::string | to | |||
) |
文字列を置き換える
与えられた文字列に対して、指定した文字の置き換えを行う。
str | 置き換え処理対象文字列 | |
from | 置換元文字 | |
to | 置換先文字 |
std::vector<std::string> split | ( | const std::string & | input, | |
const std::string & | delimiter | |||
) |
文字列を分割文字で分割する
設定された文字列を与えられたデリミタで分割する。
input | 分割対象文字列 | |
delimiter | 分割文字列(デリミタ) |
bool stringTo | ( | To & | val, | |
const char * | str | |||
) | [inline] |
与えられたstdstringをオブジェクトに変換
引数で与えられた文字列を指定されたオブジェクトに変換する。
val | 変換先オブジェクト | |
str | 変換元文字列 |
char** toArgv | ( | const std::vector< std::string > & | args | ) |
与えられた文字列リストを引数リストに変換
引数で与えられた文字列リストの各要素末尾に'\0'を加え、引数リストに変換する。
args | 変換対象文字列リスト |
bool toBool | ( | std::string | str, | |
std::string | yes, | |||
std::string | no, | |||
bool | default_value = true | |||
) |
与えられた文字列をbool値に変換する
指定された文字列を、true表現文字列、false表現文字列と比較し、その結果を bool値として返す。 比較の結果、true表現文字列、false表現文字列のどちらとも一致しない場合は、 与えられたデフォルト値を返す。
str | 判断対象文字列 | |
yes | true表現文字列 | |
no | false表現文字列 | |
default_value | デフォルト値(デフォルト値:true) |
std::string unescape | ( | const std::string | str | ) |
文字列のエスケープを戻す
次のエスケープシーケンスを文字に変換する。
"\t" -> HT
"\n" -> LF
"\r" -> CR
"\f" -> FF
"\"" -> "
"\'" -> '
※エスケープ処理の完全な逆変換にはなっていないため、注意が必要。
str | アンエスケープ処理対象文字列 |
std::vector<std::string> unique_sv | ( | std::vector< std::string > | sv | ) |
与えられた文字列リストから重複を削除
引数で与えられた文字列リストから重複を削除したリストを作成する。
sv | 確認元文字列リスト |