regbase.hpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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_V4_REGBASE_HPP
  18. #define BOOST_REGEX_V4_REGBASE_HPP
  19. #ifdef BOOST_MSVC
  20. #pragma warning(push)
  21. #pragma warning(disable: 4103)
  22. #endif
  23. #ifdef BOOST_HAS_ABI_HEADERS
  24. # include BOOST_ABI_PREFIX
  25. #endif
  26. #ifdef BOOST_MSVC
  27. #pragma warning(pop)
  28. #endif
  29. namespace boost{
  30. //
  31. // class regbase
  32. // handles error codes and flags
  33. //
  34. class BOOST_REGEX_DECL regbase
  35. {
  36. public:
  37. enum flag_type_
  38. {
  39. //
  40. // Divide the flags up into logical groups:
  41. // bits 0-7 indicate main synatx type.
  42. // bits 8-15 indicate syntax subtype.
  43. // bits 16-31 indicate options that are common to all
  44. // regex syntaxes.
  45. // In all cases the default is 0.
  46. //
  47. // Main synatx group:
  48. //
  49. perl_syntax_group = 0, // default
  50. basic_syntax_group = 1, // POSIX basic
  51. literal = 2, // all characters are literals
  52. main_option_type = literal | basic_syntax_group | perl_syntax_group, // everything!
  53. //
  54. // options specific to perl group:
  55. //
  56. no_bk_refs = 1 << 8, // \d not allowed
  57. no_perl_ex = 1 << 9, // disable perl extensions
  58. no_mod_m = 1 << 10, // disable Perl m modifier
  59. mod_x = 1 << 11, // Perl x modifier
  60. mod_s = 1 << 12, // force s modifier on (overrides match_not_dot_newline)
  61. no_mod_s = 1 << 13, // force s modifier off (overrides match_not_dot_newline)
  62. //
  63. // options specific to basic group:
  64. //
  65. no_char_classes = 1 << 8, // [[:CLASS:]] not allowed
  66. no_intervals = 1 << 9, // {x,y} not allowed
  67. bk_plus_qm = 1 << 10, // uses \+ and \?
  68. bk_vbar = 1 << 11, // use \| for alternatives
  69. emacs_ex = 1 << 12, // enables emacs extensions
  70. //
  71. // options common to all groups:
  72. //
  73. no_escape_in_lists = 1 << 16, // '\' not special inside [...]
  74. newline_alt = 1 << 17, // \n is the same as |
  75. no_except = 1 << 18, // no exception on error
  76. failbit = 1 << 19, // error flag
  77. icase = 1 << 20, // characters are matched regardless of case
  78. nocollate = 0, // don't use locale specific collation (deprecated)
  79. collate = 1 << 21, // use locale specific collation
  80. nosubs = 1 << 22, // don't mark sub-expressions
  81. save_subexpression_location = 1 << 23, // save subexpression locations
  82. no_empty_expressions = 1 << 24, // no empty expressions allowed
  83. optimize = 0, // not really supported
  84. basic = basic_syntax_group | collate | no_escape_in_lists,
  85. extended = no_bk_refs | collate | no_perl_ex | no_escape_in_lists,
  86. normal = 0,
  87. emacs = basic_syntax_group | collate | emacs_ex | bk_vbar,
  88. awk = no_bk_refs | collate | no_perl_ex,
  89. grep = basic | newline_alt,
  90. egrep = extended | newline_alt,
  91. sed = basic,
  92. perl = normal,
  93. ECMAScript = normal,
  94. JavaScript = normal,
  95. JScript = normal
  96. };
  97. typedef unsigned int flag_type;
  98. enum restart_info
  99. {
  100. restart_any = 0,
  101. restart_word = 1,
  102. restart_line = 2,
  103. restart_buf = 3,
  104. restart_continue = 4,
  105. restart_lit = 5,
  106. restart_fixed_lit = 6,
  107. restart_count = 7
  108. };
  109. };
  110. //
  111. // provide std lib proposal compatible constants:
  112. //
  113. namespace regex_constants{
  114. enum flag_type_
  115. {
  116. no_except = ::boost::regbase::no_except,
  117. failbit = ::boost::regbase::failbit,
  118. literal = ::boost::regbase::literal,
  119. icase = ::boost::regbase::icase,
  120. nocollate = ::boost::regbase::nocollate,
  121. collate = ::boost::regbase::collate,
  122. nosubs = ::boost::regbase::nosubs,
  123. optimize = ::boost::regbase::optimize,
  124. bk_plus_qm = ::boost::regbase::bk_plus_qm,
  125. bk_vbar = ::boost::regbase::bk_vbar,
  126. no_intervals = ::boost::regbase::no_intervals,
  127. no_char_classes = ::boost::regbase::no_char_classes,
  128. no_escape_in_lists = ::boost::regbase::no_escape_in_lists,
  129. no_mod_m = ::boost::regbase::no_mod_m,
  130. mod_x = ::boost::regbase::mod_x,
  131. mod_s = ::boost::regbase::mod_s,
  132. no_mod_s = ::boost::regbase::no_mod_s,
  133. save_subexpression_location = ::boost::regbase::save_subexpression_location,
  134. no_empty_expressions = ::boost::regbase::no_empty_expressions,
  135. basic = ::boost::regbase::basic,
  136. extended = ::boost::regbase::extended,
  137. normal = ::boost::regbase::normal,
  138. emacs = ::boost::regbase::emacs,
  139. awk = ::boost::regbase::awk,
  140. grep = ::boost::regbase::grep,
  141. egrep = ::boost::regbase::egrep,
  142. sed = basic,
  143. perl = normal,
  144. ECMAScript = normal,
  145. JavaScript = normal,
  146. JScript = normal
  147. };
  148. typedef ::boost::regbase::flag_type syntax_option_type;
  149. } // namespace regex_constants
  150. } // namespace boost
  151. #ifdef BOOST_MSVC
  152. #pragma warning(push)
  153. #pragma warning(disable: 4103)
  154. #endif
  155. #ifdef BOOST_HAS_ABI_HEADERS
  156. # include BOOST_ABI_SUFFIX
  157. #endif
  158. #ifdef BOOST_MSVC
  159. #pragma warning(pop)
  160. #endif
  161. #endif