Common Library  0.9.5
CmpStr 構造体

文字列比較用関数オブジェクト [詳解]

std::binary_function< std::string, std::string, int >を継承しています。

公開メンバ関数

 CmpStr (bool nCase=false)
 大文字・小文字を無視するかを指定して構築 [詳解]
 
int operator() (const std::string &s1, const std::string &s2) const
 二つの文字列を比較する [詳解]
 

フィールド

bool ignoreCase
 大文字・小文字を無視するなら true にする
 

詳解

文字列比較用関数オブジェクト

構築子と解体子

◆ CmpStr()

CmpStr::CmpStr ( bool  nCase = false)
inlineexplicit

大文字・小文字を無視するかを指定して構築

引数
nCase大文字・小文字を無視するなら true にする

関数詳解

◆ operator()()

int CmpStr::operator() ( const std::string &  s1,
const std::string &  s2 
) const
inline

二つの文字列を比較する

二つの文字列を先頭から順に比較し、不一致を見つけたら、s1 の文字コードの方が s2 より小さければ -1、 逆の場合は 1 を返す。もしどちらかが末尾まで達した場合、文字列長が等しければ 0、s1 の方が短ければ -1、 逆の場合は 1 を返す。ignoreCase が true なら、大文字と小文字の違いは無視される。

引数
s1比較対象文字列 1
s2比較対象文字列 2
戻り値
s1< s2 ... -1
s1> s2 ... 1
s1= s2 ... 0

この構造体詳解は次のファイルから抽出されました: