regbase.hpp 5.4 KB

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