首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Poco:StringTokenizer & String

2012-09-02 
Poco::StringTokenizer & String// Library: Foundation// Package: Core// Module:StringTokenizer功能:S

Poco::StringTokenizer & String
// Library: Foundation
// Package: Core
// Module:  StringTokenizer

功能:String.h 文件中声明了几个静态函数,用于去除string 的开头和结尾的空白字符,大小写转换,字符串比较,字符映射,字符串替换,字符串连接。StringTokenizer 用于从一个字符串中解析出单词(如果以空白字符作分割符)。

方法:

template <class S> S trimLeft(const S& str)   // 都可以在后面加上InPlace,例如trimLeftInPlace,用于直接对传入的字符串进行操作
template <class S> S trimRight(const S& str)template <class S> S trim(const S& str)template <class S> S toUpper(const S& str)template <class S> S toLower(const S& str)template <class S> S trim(const S& str)icomparetranslatereplacecatinline const std::string& StringTokenizer::operator [] (std::size_t index) const

StringTokenizer st("a/bc,def,,ghi // jk,  l ", ",/", StringTokenizer::TOK_TRIM | StringTokenizer::TOK_IGNORE_EMPTY);StringTokenizer::Iterator it = st.begin();assert (it != st.end());assert (*it++ == "a");assert (it != st.end());assert (*it++ == "bc");assert (it != st.end());assert (*it++ == "def");assert (it != st.end());assert (*it++ == "ghi");assert (it != st.end());assert (*it++ == "jk");assert (it != st.end());assert (*it++ == "l");assert (it == st.end());




热点排行