|
fastdo
0.6.16
|
多项匹配/替换 更多...
#include <strings.hpp>
类 | |
| struct | MatchResult |
| struct | MatchState |
Public 类型 | |
| typedef std::vector< short > | KmpNextValueArray |
| NEXT值数组类型 更多... | |
| typedef std::vector< MatchState > | MatchStates |
| 匹配状态数组类型 更多... | |
| typedef String(* | ReplaceFuncType) (MultiMatch const *matchObj, ssize_t item, void *extra) |
| 替换函数的类型 更多... | |
| typedef MatchResult(MultiMatch::* | SearchFuncType) (String const &str, ssize_t offset) const |
| 搜索算法函数类型 更多... | |
Public 成员函数 | |
| MultiMatch () | |
| 构造函数0 更多... | |
| MultiMatch (StringArray const &matches, StringArray const &replaces) | |
| 构造函数1,要求匹配项和替换项 更多... | |
| MultiMatch (StringArray const &matches, ReplaceFuncType replaceFunc, void *extra=NULL) | |
| 构造函数2,要求匹配项和替换函数,若不进行替换,则replaceFunc可为NULL 更多... | |
| template<size_t _Count> | |
| MultiMatch (String(&matches)[_Count], String(&replaces)[_Count]) | |
| 构造函数3,要求匹配项和替换项 更多... | |
| template<size_t _Count> | |
| MultiMatch (String(&matches)[_Count], ReplaceFuncType replaceFunc, void *extra=NULL) | |
| 构造函数4,要求匹配项和替换函数,若不进行替换,则replaceFunc可为NULL 更多... | |
| void | init (StringArray const &matches, StringArray const &replaces) |
| 初始化(匹配项,替换项) 更多... | |
| void | init (StringArray const &matches, ReplaceFuncType replaceFunc, void *extra=NULL) |
| 初始化(匹配项,替换项回调函数) 更多... | |
| ssize_t | addMatchReplacePair (String const &match, String const &replace) |
| 添加一对匹配替换项,返回要匹配的项数 更多... | |
| ssize_t | addMatch (String const &match) |
| 添加要匹配项 更多... | |
| String const & | getMatchItem (ssize_t item) const |
| 获取指定匹配项 更多... | |
| void | setMatchItem (ssize_t item, String const &match) |
| 设置指定匹配项 更多... | |
| String | getReplaceItem (ssize_t item) const |
| 获取指定替换项 更多... | |
| void | setReplaceItem (ssize_t item, String const &replace) |
| 设置指定替换项 更多... | |
| void | setReplaceItems (StringArray const &replaces) |
| 设置替换项 更多... | |
| ReplaceFuncType | setReplaceFunc (ReplaceFuncType newReplaceFunc, void *extra=NULL) |
| 设置新的替换项回调函数,返回旧的替换项回调函数 更多... | |
| void | clear () |
| 清空匹配项和替换项数据 更多... | |
| MatchResult | search (String const &str, ssize_t offset=0) const |
| 搜索任意一项匹配(KMP) 更多... | |
| MatchResult | greedSearch (String const &str, ssize_t offset=0) const |
| 搜索任意一项匹配(KMP贪婪模式,尽可能匹配长的项) 更多... | |
| MatchResult | commonSearch (String const &str, ssize_t offset=0) const |
| 搜索任意一项匹配(贪婪模式,非KMP算法) 更多... | |
| String | replace (String const &str, ssize_t offset=0, SearchFuncType fnSearch=&MultiMatch::commonSearch) const |
| 替换。搜索str中的matches,并替换成replaces 更多... | |
多项匹配/替换
在文件 strings.hpp 第 790 行定义.
| typedef std::vector<short> winux::MultiMatch::KmpNextValueArray |
NEXT值数组类型
在文件 strings.hpp 第 816 行定义.
| typedef std::vector<MatchState> winux::MultiMatch::MatchStates |
匹配状态数组类型
在文件 strings.hpp 第 819 行定义.
| typedef String(* winux::MultiMatch::ReplaceFuncType) (MultiMatch const *matchObj, ssize_t item, void *extra) |
替换函数的类型
在文件 strings.hpp 第 822 行定义.
| typedef MatchResult( MultiMatch:: * winux::MultiMatch::SearchFuncType) (String const &str, ssize_t offset) const |
搜索算法函数类型
在文件 strings.hpp 第 825 行定义.
| winux::MultiMatch::MultiMatch | ( | ) |
构造函数0
之后需要自己调用addMatchReplacePair()、addMatch()、setReplaceFunc()设置相关参数
| winux::MultiMatch::MultiMatch | ( | StringArray const & | matches, |
| StringArray const & | replaces | ||
| ) |
构造函数1,要求匹配项和替换项
| winux::MultiMatch::MultiMatch | ( | StringArray const & | matches, |
| ReplaceFuncType | replaceFunc, | ||
| void * | extra = NULL |
||
| ) |
构造函数2,要求匹配项和替换函数,若不进行替换,则replaceFunc可为NULL
|
inline |
构造函数3,要求匹配项和替换项
在文件 strings.hpp 第 840 行定义.
|
inline |
构造函数4,要求匹配项和替换函数,若不进行替换,则replaceFunc可为NULL
在文件 strings.hpp 第 847 行定义.
| void winux::MultiMatch::init | ( | StringArray const & | matches, |
| StringArray const & | replaces | ||
| ) |
初始化(匹配项,替换项)
| void winux::MultiMatch::init | ( | StringArray const & | matches, |
| ReplaceFuncType | replaceFunc, | ||
| void * | extra = NULL |
||
| ) |
初始化(匹配项,替换项回调函数)
添加一对匹配替换项,返回要匹配的项数
| void winux::MultiMatch::setReplaceItems | ( | StringArray const & | replaces | ) |
设置替换项
| ReplaceFuncType winux::MultiMatch::setReplaceFunc | ( | ReplaceFuncType | newReplaceFunc, |
| void * | extra = NULL |
||
| ) |
设置新的替换项回调函数,返回旧的替换项回调函数
| void winux::MultiMatch::clear | ( | ) |
清空匹配项和替换项数据
| MatchResult winux::MultiMatch::search | ( | String const & | str, |
| ssize_t | offset = 0 |
||
| ) | const |
搜索任意一项匹配(KMP)
| str | 字符串 |
| offset | 偏移,表示从哪个位置开始搜 |
| MatchResult winux::MultiMatch::greedSearch | ( | String const & | str, |
| ssize_t | offset = 0 |
||
| ) | const |
搜索任意一项匹配(KMP贪婪模式,尽可能匹配长的项)
| str | 字符串 |
| offset | 偏移,表示从哪个位置开始搜 |
| MatchResult winux::MultiMatch::commonSearch | ( | String const & | str, |
| ssize_t | offset = 0 |
||
| ) | const |
搜索任意一项匹配(贪婪模式,非KMP算法)
| str | 字符串 |
| offset | 偏移,表示从哪个位置开始搜 |
| String winux::MultiMatch::replace | ( | String const & | str, |
| ssize_t | offset = 0, |
||
| SearchFuncType | fnSearch = &MultiMatch::commonSearch |
||
| ) | const |
替换。搜索str中的matches,并替换成replaces
| str | 目标字符串 |
| offset | 偏移,表示从哪个位置开始搜 |
| fnSearch | 算法选择,请指定函数(search,greedSearch,commonSearch) |