old_regex.qbk

来自「Boost provides free peer-reviewed portab」· QBK 代码 · 共 284 行 · 第 1/2 页

QBK
284
字号
[/   Copyright 2006-2007 John Maddock.  Distributed under the Boost Software License, Version 1.0.  (See accompanying file LICENSE_1_0.txt or copy at  http://www.boost.org/LICENSE_1_0.txt).][section:old_regex High Level Class RegEx (Deprecated)]The high level wrapper class RegEx is now deprecated and does not form part of the regular expression standardization proposal.  This type still exists, and existing code will continue to compile, however the following documentation is unlikely to be further updated.   #include <boost/cregex.hpp>The class RegEx provides a high level simplified interface to the regular expression library, this class only handles narrow character strings, and regular expressions always follow the "normal" syntax - that is the same as the perl / ECMAScript synatx.   typedef bool (*GrepCallback)(const RegEx& expression);   typedef bool (*GrepFileCallback)(const char* file, const RegEx& expression);   typedef bool (*FindFilesCallback)(const char* file);   class  RegEx   {   public:      RegEx();      RegEx(const RegEx& o);      ~RegEx();      RegEx(const char* c, bool icase = false);      explicit RegEx(const std::string& s, bool icase = false);      RegEx& operator=(const RegEx& o);      RegEx& operator=(const char* p);      RegEx& operator=(const std::string& s);      unsigned int SetExpression(const char* p, bool icase = false);      unsigned int SetExpression(const std::string& s, bool icase = false);      std::string Expression()const;      //      // now matching operators:       //       bool Match(const char* p, boost::match_flag_type flags = match_default);      bool Match(const std::string& s, boost::match_flag_type flags = match_default);       bool Search(const char* p, boost::match_flag_type flags = match_default);       bool Search(const std::string& s, boost::match_flag_type flags = match_default);       unsigned int Grep(GrepCallback cb, const char* p,                         boost::match_flag_type flags = match_default);       unsigned int Grep(GrepCallback cb, const std::string& s,                         boost::match_flag_type flags = match_default);       unsigned int Grep(std::vector<std::string>& v, const char* p,                         boost::match_flag_type flags = match_default);       unsigned int Grep(std::vector<std::string>& v, const std::string& s,                         boost::match_flag_type flags = match_default);       unsigned int Grep(std::vector<unsigned int>& v, const char* p,                         boost::match_flag_type flags = match_default);       unsigned int Grep(std::vector<unsigned int>& v, const std::string& s,                         boost::match_flag_type flags = match_default);       unsigned int GrepFiles(GrepFileCallback cb, const char* files, bool recurse = false,                              boost::match_flag_type flags = match_default);       unsigned int GrepFiles(GrepFileCallback cb, const std::string& files,                              bool recurse = false,                              boost::match_flag_type flags = match_default);       unsigned int FindFiles(FindFilesCallback cb, const char* files,                              bool recurse = false,                              boost::match_flag_type flags = match_default);       unsigned int FindFiles(FindFilesCallback cb, const std::string& files,                              bool recurse = false,                              boost::match_flag_type flags = match_default);       std::string Merge(const std::string& in, const std::string& fmt,                         bool copy = true, boost::match_flag_type flags = match_default);       std::string Merge(const char* in, const char* fmt, bool copy = true,                         boost::match_flag_type flags = match_default);       unsigned Split(std::vector<std::string>& v, std::string& s,                      boost::match_flag_type flags = match_default,                      unsigned max_count = ~0);       //       // now operators for returning what matched in more detail:       //       unsigned int Position(int i = 0)const;       unsigned int Length(int i = 0)const;       bool Matched(int i = 0)const;      unsigned int Line()const;       unsigned int Marks() const;       std::string What(int i)const;       std::string operator[](int i)const ;       static const unsigned int npos;   };    Member functions for class RegEx are defined as follows: [table[[Member][Description]][[`RegEx();`][Default constructor, constructs an instance of RegEx without any valid expression. 	 ]][[`RegEx(const RegEx& o);`][Copy constructor, all the properties of parameter /o/          are copied. 	 ]][[`RegEx(const char* c, bool icase = false);`][Constructs an instance of RegEx,          setting the expression to /c/, if /icase/ is true then matching is          insensitive to case, otherwise it is sensitive to case. Throws          [bad_expression] on failure. 	 ]][[`RegEx(const std::string& s, bool icase = false);`][Constructs an instance of          RegEx, setting the expression to /s/, if /icase/ is true then matching          is insensitive to case, otherwise it is sensitive to case. Throws          [bad_expression] on failure. 	 ]][[`RegEx& operator=(const RegEx& o);`][Default assignment operator. 	 ]][[`RegEx& operator=(const char* p);`][Assignment operator, equivalent to calling          `SetExpression(p, false)`. Throws [bad_expression] on failure. 	 ]][[`RegEx& operator=(const std::string& s);`][Assignment operator, equivalent to          calling `SetExpression(s, false)`. Throws [bad_expression] on failure. 	 ]][[`unsigned int SetExpression(constchar* p, bool icase = false);`][Sets the          current expression to /p/, if /icase/ is true then matching is          insensitive to case, otherwise it is sensitive to case.          Throws [bad_expression] on failure. 	 ]][[`unsigned int SetExpression(const std::string& s, bool icase = false);`]         [Sets the current expression to /s/, if /icase/ is true then matching is          insensitive to case, otherwise it is sensitive to case. Throws          [bad_expression] on failure. 	 ]][[`std::string Expression()const;`][Returns a copy of the current regular expression. 	 ]][[`bool Match(const char* p, boost::match_flag_type flags = match_default);`]         [Attempts to match the current expression against the text /p/ using          the match flags /flags/ - see [match_flag_type]. Returns /true/ if the          expression matches the whole of the input string. 	 ]][[`bool Match(const std::string& s, boost::match_flag_type flags = match_default);`]         [Attempts to match the current expression against the text /s/ using          the [match_flag_type] /flags/. Returns /true/ if the expression matches          the whole of the input string. 	 ]][[`bool Search(const char* p, boost::match_flag_type flags = match_default);`]         [Attempts to find a match for the current expression somewhere in          the text /p/ using the [match_flag_type] /flags/. Returns /true/          if the match succeeds. 	 ]][[`bool Search(const std::string& s, boost::match_flag_type flags = match_default);`]         [Attempts to find a match for the current expression somewhere in the          text /s/ using the [match_flag_type] flags. Returns /true/ if the          match succeeds. 	 ]][[`unsigned int Grep(GrepCallback cb, const char* p, boost::match_flag_type flags = match_default);`]         [Finds all matches of the current expression in the text /p/ using the          [match_flag_type] /flags/. For each match found calls the call-back          function cb as: `cb(*this);`         If at any stage the call-back function returns /false/ then the grep          operation terminates, otherwise continues until no further matches 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?