读书人

Poco:StringTokenizer amp; String

发布时间: 2012-09-02 21:00:34 作者: rapoo

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());




读书人网 >编程

热点推荐