strsplit.hpp

文字列を指定されたデリミタで分解する [詳細]

#include "langedge/win_support.hpp"
#include <string>
#include <vector>

strsplit.hppのインクルード依存関係図

このグラフは、どのファイルから直接、間接的にインクルードされているかを示しています。

ソースコードを見る。

ネームスペース

namespace  langedge

関数

void strSplit_stripSpaces (std::string &str, const std::string &spaces)
void strSplit_copySubstr (std::vector< std::string > &sv, const std::string &str, const std::string &spaces)
std::vector< std::string > strSplit (const std::string &str, const std::string &delims, const std::string &spaces=" \t\r\n")
 文字列をデリミタで分解する.
std::string findToken (char **strPtr, const std::string &delims, const std::string &spaces=" \t\r\n")
 文字列からトークンを取り出す.


説明

文字列を指定されたデリミタで分解する

作者:
OKA Toshiyuki (LangEdge, Inc.) <oka@langedge.com>
日付:
2000-12-6
バージョン:
Id
strsplit.hpp,v 1.1.1.1 2005/03/30 11:33:30 exoka Exp
Copyright (C) 2000-2002 LangEdge, Inc. All rights reserved.

関数

void langedge::strSplit_stripSpaces std::string &  str,
const std::string &  spaces
[inline]
 

void langedge::strSplit_copySubstr std::vector< std::string > &  sv,
const std::string &  str,
const std::string &  spaces
[inline]
 

std::vector<std::string> langedge::strSplit const std::string &  str,
const std::string &  delims,
const std::string &  spaces = " \t\r\n"
[inline]
 

文字列をデリミタで分解する.

std::stringを指定されたデリミタで分解し、トークンの列を得る。 strtok() の一括版ともいえるが、strtok() と異なり元の文字列は破壊されない。

デリミタ指定にスペース(0x20)が含まれている場合は、(別種も含め)連続したデリミタを 1つのものとして扱う。たとえば、デリミタが " \t" (空白とタブ) だとして、 入力文字列が "foo \t\t bar" ("foo"、 空白、タブ、タブ、空白、"bar") だった場合、 トークン列としては、"foo", "bar" が得られる。
デリミタ指定にスペースが含まれていない場合は、デリミタが連続しても間に空文字列が あるものとして別々に扱う。たとえば、デリミタが "\t" (タブ) だったら、 上の入力文字列は、"foo", "" (空文字列), "bar" というトークン列になる。

トークンの先頭または末尾に空白文字がある場合、それが spaces で指定される文字種に 含まれるならば、除去される。

引数:
str 対象文字列
delims デリミタ文字の列。
spaces 分解されたトークンの先頭・末尾において除去される空白文字類の列
戻り値:
分解されたトークンの配列

std::string langedge::findToken char **  strPtr,
const std::string &  delims,
const std::string &  spaces = " \t\r\n"
[inline]
 

文字列からトークンを取り出す.

strtok() の安全版。指定されたデリミタに従い、与えられた文字列の最初のトークンを見つける。 見つけたトークンは戻値として返し、次の解析開始位置を引数で返す。

引数:
strPtr [入力] 解析対象となる C-like 文字列へのポインタ。
[出力] 次の解析開始位置。
delims デリミタ文字の列。(strSplit() の説明を見よ)
spaces 分解されたトークンの先頭・末尾において除去される空白文字類の列
戻り値:
先頭のトークン文字列


LangEdge ライブラリに対してFri May 6 22:42:59 2005に生成されました。  doxygen 1.4.2