国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

c++ 字符串分割函數(shù)stringsplit

2019-11-14 11:59:22
字體:
供稿:網(wǎng)友
/* stringsplit.hpp sdragonx 2006-06-16 00:43:16 revise  2016.07.18 19:04*/#ifndef STRINGSPLIT_HPP_200606161656#define STRINGSPLIT_HPP_200606161656#include <algorithm>namespace cgl{template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(	container< string_type<char_type> >& ls,	typename string_type<char_type>::const_iterator begin,	typename string_type<char_type>::const_iterator end,	char_type spliter,	bool repeat = true){    if(end <= begin)	{    	return 0;	}    typename string_type<char_type>::const_iterator first = begin;    typename string_type<char_type>::const_iterator second;        for( ; first<end; )    {        second = std::find<string_type<char_type>::const_iterator>(first, end, spliter);        if(first == second){            if(repeat)ls.push_back(string_type<char_type>());        }        else{            ls.push_back(string_type<char_type>(first, second));    	}        first = second+1;    }    if(repeat)    {        if(second == end-1){        	ls.push_back(string_type<char_type>());        }    }    return ls.size();}template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(	container< string_type<char_type> >& ls,    typename string_type<char_type>::const_iterator begin,    typename string_type<char_type>::const_iterator end,    typename string_type<char_type>::const_iterator spliter_begin,    typename string_type<char_type>::const_iterator spliter_end,    bool repeat = true){    if(end <= begin || spliter_end<=spliter_begin)	{    	return 0;    }    typename string_type<char_type>::const_iterator first = begin;    typename string_type<char_type>::const_iterator second;        for( ; first<end; )    {        second = std::find_first_of<string_type<char_type>::const_iterator>(first, end, spliter_begin, spliter_end);        if(first == second){            if(repeat)ls.push_back(string_type<char_type>());        }        else{        	ls.push_back(string_type<char_type>(first, second));        }        first = second+1;    }    if(repeat)    {        if(second == end-1){        	ls.push_back(string_type<char_type>());        }    }    return ls.size();}template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(container< string_type<char_type> > &strs,	const string_type<char_type>& str, char_type spliter, bool repeat = true){    return stringsplit(strs, str.begin(), str.end(), spliter, repeat);}template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(container< string_type<char_type> > &strs,	const char_type* str, size_t length, char_type spliter, bool repeat = true){    return stringsplit(strs, str, str+length, spliter, repeat);}template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(container< string_type<char_type> > &strs,	const string_type<char_type>& str, const string_type<char_type>& spliter, bool repeat = true){    return stringsplit(strs, str.begin(), str.end(), spliter.begin(), spliter.end(), repeat);}template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(container< string_type<char_type> > &strs,	const char_type* str, size_t length, const char_type* spliter, size_t splength, bool repeat = true){    return stringsplit(strs, str, str+length, spliter, spliter+splength, repeat);}}; // end namespace cgl;#endif //STRINGSPLIT_HPP_200606161656
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 赤水市| 广昌县| 抚顺县| 石家庄市| 定日县| 安多县| 涞水县| 都匀市| 武邑县| 南宫市| 贺州市| 阆中市| 高清| 铜川市| 滦南县| 蕲春县| 金沙县| 翁牛特旗| 苗栗县| 乌恰县| 万宁市| 思南县| 白朗县| 教育| 玉山县| 建始县| 固原市| 德安县| 鹤峰县| 庄河市| 阿尔山市| 甘德县| 涪陵区| 桂东县| 吉林市| 富宁县| 宁蒗| 荔浦县| 屏边| 华宁县| 伽师县|