Poco c++框架中,有自己一套字符串处理函数,因为由标准的C++构成,效率很高;原来使用的Qt中的Qstirng,也非常好用的,为了得到服务器处理的效率,服务器模块中全更换成标准C ++,比较好维护。
整个字符串的处理在Poco的Foundtion中的core里面。
常用的例子如下:(源码来自网络)
一 字符串分割
#include "Poco/StringTokenizer.h" #include <iostream> using Poco::StringTokenizer; int main(int argc, char** argv) { std::string tokens = "white; black; 中文, blue, green; yellow"; StringTokenizer tokenizer(tokens, ";,", StringTokenizer::TOK_TRIM); for (StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end(); ++it) { std::cout << *it << std::endl; } return 0; }
输出结果:
white black 中文 blue green yellow
本文出自 “LinuxQt济南高新区” 博客,请务必保留此出处http://qtlinux.blog.51cto.com/3052744/1702066
原文:http://qtlinux.blog.51cto.com/3052744/1702066