diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-12-08 17:00:27 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-12-08 17:00:27 -0300 |
commit | afb895f197795857a68a40cc22e605bdd53bf254 (patch) | |
tree | 2914f848944ff5574ec300b318113c694ae6a1d1 /drivers/nrex/nrex.hpp | |
parent | 1bcdea0804a2cf943eaa9f9bfd77e6a4ed68b471 (diff) | |
parent | d957749179f7310995e994b45df72291a57bd0d7 (diff) |
Merge pull request #2993 from leezh/nrex-v0.1
updated the RegEx library nrex to v0.1
Diffstat (limited to 'drivers/nrex/nrex.hpp')
-rw-r--r-- | drivers/nrex/nrex.hpp | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/drivers/nrex/nrex.hpp b/drivers/nrex/nrex.hpp index e26a61c39a..44e950c517 100644 --- a/drivers/nrex/nrex.hpp +++ b/drivers/nrex/nrex.hpp @@ -1,4 +1,5 @@ // NREX: Node RegEx +// Version 0.1 // // Copyright (c) 2015, Zher Huei Lee // All rights reserved. @@ -59,7 +60,32 @@ class nrex int _capturing; nrex_node* _root; public: + + /*! + * \brief Initialises an empty regex container + */ nrex(); + + /*! + * \brief Initialises and compiles the regex pattern + * + * This calls nrex::compile() with the same arguments. To check whether + * the compilation was successfull, use nrex::valid(). + * + * If the NREX_THROW_ERROR was defined it would automatically throw a + * runtime error nrex_compile_error if it encounters a problem when + * parsing the pattern. + * + * \param pattern The regex pattern + * \param captures The maximum number of capture groups to allow. Any + * extra would be converted to non-capturing groups. + * If negative, no limit would be imposed. Defaults + * to 9. + * + * \see nrex::compile() + */ + nrex(const nrex_char* pattern, int captures = 9); + ~nrex(); /*! @@ -78,9 +104,9 @@ class nrex * * This is used to provide the array size of the captures needed for * nrex::match() to work. The size is actually the number of capture - * groups + one for the matching of the entire pattern. The result is - * always capped at 10 or 100, depending on the extend option given in - * nrex::compile() (default 10). + * groups + one for the matching of the entire pattern. This can be + * capped using the extra argument given in nrex::compile() + * (default 10). * * \return The number of captures */ @@ -97,12 +123,13 @@ class nrex * parsing the pattern. * * \param pattern The regex pattern - * \param extended If true, raises the limit on number of capture - * groups and back-references to 99. Otherwise limited - * to 9. Defaults to false. + * \param captures The maximum number of capture groups to allow. Any + * extra would be converted to non-capturing groups. + * If negative, no limit would be imposed. Defaults + * to 9. * \return True if the pattern was succesfully compiled */ - bool compile(const nrex_char* pattern, bool extended = false); + bool compile(const nrex_char* pattern, int captures = 9); /*! * \brief Uses the pattern to search through the provided string |