regbase.hpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. *
  3. * Copyright (c) 1998-2002
  4. * John Maddock
  5. *
  6. * Use, modification and distribution are subject to the
  7. * Boost Software License, Version 1.0. (See accompanying file
  8. * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. *
  10. */
  11. /*
  12. * LOCATION: see http://www.boost.org for most recent version.
  13. * FILE regbase.cpp
  14. * VERSION see <boost/version.hpp>
  15. * DESCRIPTION: Declares class regbase.
  16. */
  17. #ifndef BOOST_REGEX_V5_REGBASE_HPP
  18. #define BOOST_REGEX_V5_REGBASE_HPP
  19. #include <boost/regex/config.hpp>
  20. namespace boost{
  21. //
  22. // class regbase
  23. // handles error codes and flags
  24. //
  25. class regbase
  26. {
  27. public:
  28. enum flag_type_
  29. {
  30. //
  31. // Divide the flags up into logical groups:
  32. // bits 0-7 indicate main synatx type.
  33. // bits 8-15 indicate syntax subtype.
  34. // bits 16-31 indicate options that are common to all
  35. // regex syntaxes.
  36. // In all cases the default is 0.
  37. //
  38. // Main synatx group:
  39. //
  40. perl_syntax_group = 0, // default
  41. basic_syntax_group = 1, // POSIX basic
  42. literal = 2, // all characters are literals
  43. main_option_type = literal | basic_syntax_group | perl_syntax_group, // everything!
  44. //
  45. // options specific to perl group:
  46. //
  47. no_bk_refs = 1 << 8, // \d not allowed
  48. no_perl_ex = 1 << 9, // disable perl extensions
  49. no_mod_m = 1 << 10, // disable Perl m modifier
  50. mod_x = 1 << 11, // Perl x modifier
  51. mod_s = 1 << 12, // force s modifier on (overrides match_not_dot_newline)
  52. no_mod_s = 1 << 13, // force s modifier off (overrides match_not_dot_newline)
  53. //
  54. // options specific to basic group:
  55. //
  56. no_char_classes = 1 << 8, // [[:CLASS:]] not allowed
  57. no_intervals = 1 << 9, // {x,y} not allowed
  58. bk_plus_qm = 1 << 10, // uses \+ and \?
  59. bk_vbar = 1 << 11, // use \| for alternatives
  60. emacs_ex = 1 << 12, // enables emacs extensions
  61. //
  62. // options common to all groups:
  63. //
  64. no_escape_in_lists = 1 << 16, // '\' not special inside [...]
  65. newline_alt = 1 << 17, // \n is the same as |
  66. no_except = 1 << 18, // no exception on error
  67. failbit = 1 << 19, // error flag
  68. icase = 1 << 20, // characters are matched regardless of case
  69. nocollate = 0, // don't use locale specific collation (deprecated)
  70. collate = 1 << 21, // use locale specific collation
  71. nosubs = 1 << 22, // don't mark sub-expressions
  72. save_subexpression_location = 1 << 23, // save subexpression locations
  73. no_empty_expressions = 1 << 24, // no empty expressions allowed
  74. optimize = 0, // not really supported
  75. basic = basic_syntax_group | collate | no_escape_in_lists,
  76. extended = no_bk_refs | collate | no_perl_ex | no_escape_in_lists,
  77. normal = 0,
  78. emacs = basic_syntax_group | collate | emacs_ex | bk_vbar,
  79. awk = no_bk_refs | collate | no_perl_ex,
  80. grep = basic | newline_alt,
  81. egrep = extended | newline_alt,
  82. sed = basic,
  83. perl = normal,
  84. ECMAScript = normal,
  85. JavaScript = normal,
  86. JScript = normal
  87. };
  88. typedef unsigned int flag_type;
  89. enum restart_info
  90. {
  91. restart_any = 0,
  92. restart_word = 1,
  93. restart_line = 2,
  94. restart_buf = 3,
  95. restart_continue = 4,
  96. restart_lit = 5,
  97. restart_fixed_lit = 6,
  98. restart_count = 7
  99. };
  100. };
  101. //
  102. // provide std lib proposal compatible constants:
  103. //
  104. namespace regex_constants{
  105. BOOST_REGEX_MODULE_EXPORT enum flag_type_
  106. {
  107. no_except = ::boost::regbase::no_except,
  108. failbit = ::boost::regbase::failbit,
  109. literal = ::boost::regbase::literal,
  110. icase = ::boost::regbase::icase,
  111. nocollate = ::boost::regbase::nocollate,
  112. collate = ::boost::regbase::collate,
  113. nosubs = ::boost::regbase::nosubs,
  114. optimize = ::boost::regbase::optimize,
  115. bk_plus_qm = ::boost::regbase::bk_plus_qm,
  116. bk_vbar = ::boost::regbase::bk_vbar,
  117. no_intervals = ::boost::regbase::no_intervals,
  118. no_char_classes = ::boost::regbase::no_char_classes,
  119. no_escape_in_lists = ::boost::regbase::no_escape_in_lists,
  120. no_mod_m = ::boost::regbase::no_mod_m,
  121. mod_x = ::boost::regbase::mod_x,
  122. mod_s = ::boost::regbase::mod_s,
  123. no_mod_s = ::boost::regbase::no_mod_s,
  124. save_subexpression_location = ::boost::regbase::save_subexpression_location,
  125. no_empty_expressions = ::boost::regbase::no_empty_expressions,
  126. basic = ::boost::regbase::basic,
  127. extended = ::boost::regbase::extended,
  128. normal = ::boost::regbase::normal,
  129. emacs = ::boost::regbase::emacs,
  130. awk = ::boost::regbase::awk,
  131. grep = ::boost::regbase::grep,
  132. egrep = ::boost::regbase::egrep,
  133. sed = basic,
  134. perl = normal,
  135. ECMAScript = normal,
  136. JavaScript = normal,
  137. JScript = normal
  138. };
  139. BOOST_REGEX_MODULE_EXPORT typedef ::boost::regbase::flag_type syntax_option_type;
  140. } // namespace regex_constants
  141. } // namespace boost
  142. #endif