tools
読み取り中…
検索中…
一致する文字列を見つけられません
string.h ファイル

文字列操作ユーティリティ [詳解]

#include <string>
#include <vector>
#include <sstream>
#include <unordered_map>
#include <algorithm>
string.h の依存先関係図:
被依存関係図:

[ソースコード]

名前空間

namespace  st
 文字列ユーティリティ用名前空間

型定義

typedef std::unordered_map< std::string, std::vector< std::string > > st::splits
 split() の複数デリミタ対応版の戻り値型: デリミタ → 部分文字列リスト
typedef std::unordered_map< std::string, std::vector< int > > st::splitsi
 spliti() の複数デリミタ対応版の戻り値型: デリミタ → 整数リスト

関数

template<typename... Args>
bool is_or (const std::string &value, Args... args)
 文字列が複数の候補値のいずれかと等しいか判定する
void st::replace_r (std::string &str, const std::string from, const std::string to)
 文字列中のすべての from を to に置換する(参照渡し、インプレース版)
std::string st::replace (std::string str, const std::string from, const std::string to)
 文字列中のすべての from を to に置換した新しい文字列を返す(値返し版)
std::vector< std::string > st::find (const std::string &input, std::string start, std::string end)
 文字列中から start〜end に囲まれた部分文字列をすべて取り出す
int st::toi (const std::string &str)
 文字列中の数字のみを抽出して整数に変換する
std::vector< int > st::toi (const std::vector< std::string > &input)
 文字列ベクタの各要素を toi で整数に変換する
std::vector< std::string > st::split (const std::string &str, const std::string &delimiter)
 文字列を単一のデリミタで分割する(文字列ベクタを返す)
std::vector< int > st::spliti (const std::string &str, const std::string &delimiter)
 文字列を単一のデリミタで分割し、各要素を整数に変換する
splits st::split (const std::string &input, const std::vector< std::string > &targets)
 文字列を複数のデリミタで分割し、どのデリミタで区切られたかを記録する
splitsi st::spliti (const std::string &input, const std::vector< std::string > &targets)
 複数デリミタ版 split の結果を整数に変換する
std::vector< std::string > st::charV (const int i_argc, const char *const i_argv[])
 char 配列 (argc/argv 形式) を文字列ベクタに変換する
std::vector< int > st::charVi (const int i_argc, const char *i_argv[])
 char 配列 (argc/argv 形式) を整数ベクタに変換する
size_t st::size (const std::string &input)
 UTF-8 文字列のマルチバイト文字数(文字単位の長さ)を返す

詳解

文字列操作ユーティリティ

文字列の置換・検索・分割・変換など、よく使う文字列操作関数を st 名前空間および汎用関数として提供します。 UNICODE ビルド時は Boost.Locale による UTF-8/wstring 変換も利用できます。

string.h に定義があります。

関数詳解

◆ is_or()

template<typename... Args>
bool is_or ( const std::string & value,
Args... args )
inline

文字列が複数の候補値のいずれかと等しいか判定する

テンプレート引数
Args可変テンプレート引数(std::string に変換可能な型)
引数
value判定する文字列
args比較する候補値(可変長)
戻り値
value が args のいずれかと等しい場合 true
if (is_or(cmd, "quit", "exit", "q")) return;
bool is_or(const std::string &value, Args... args)
文字列が複数の候補値のいずれかと等しいか判定する
Definition string.h:31

string.h31 行目に定義があります。