match_flags.hpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 match_flags.hpp
  14. * VERSION see <boost/version.hpp>
  15. * DESCRIPTION: Declares match_flags type.
  16. */
  17. #ifndef BOOST_REGEX_V4_MATCH_FLAGS
  18. #define BOOST_REGEX_V4_MATCH_FLAGS
  19. #ifdef __cplusplus
  20. # include <boost/cstdint.hpp>
  21. #endif
  22. #ifdef __cplusplus
  23. namespace boost{
  24. namespace regex_constants{
  25. #endif
  26. typedef enum _match_flags
  27. {
  28. match_default = 0,
  29. match_not_bol = 1, /* first is not start of line */
  30. match_not_eol = match_not_bol << 1, /* last is not end of line */
  31. match_not_bob = match_not_eol << 1, /* first is not start of buffer */
  32. match_not_eob = match_not_bob << 1, /* last is not end of buffer */
  33. match_not_bow = match_not_eob << 1, /* first is not start of word */
  34. match_not_eow = match_not_bow << 1, /* last is not end of word */
  35. match_not_dot_newline = match_not_eow << 1, /* \n is not matched by '.' */
  36. match_not_dot_null = match_not_dot_newline << 1, /* '\0' is not matched by '.' */
  37. match_prev_avail = match_not_dot_null << 1, /* *--first is a valid expression */
  38. match_init = match_prev_avail << 1, /* internal use */
  39. match_any = match_init << 1, /* don't care what we match */
  40. match_not_null = match_any << 1, /* string can't be null */
  41. match_continuous = match_not_null << 1, /* each grep match must continue from */
  42. /* uninterupted from the previous one */
  43. match_partial = match_continuous << 1, /* find partial matches */
  44. match_stop = match_partial << 1, /* stop after first match (grep) V3 only */
  45. match_not_initial_null = match_stop, /* don't match initial null, V4 only */
  46. match_all = match_stop << 1, /* must find the whole of input even if match_any is set */
  47. match_perl = match_all << 1, /* Use perl matching rules */
  48. match_posix = match_perl << 1, /* Use POSIX matching rules */
  49. match_nosubs = match_posix << 1, /* don't trap marked subs */
  50. match_extra = match_nosubs << 1, /* include full capture information for repeated captures */
  51. match_single_line = match_extra << 1, /* treat text as single line and ignor any \n's when matching ^ and $. */
  52. match_unused1 = match_single_line << 1, /* unused */
  53. match_unused2 = match_unused1 << 1, /* unused */
  54. match_unused3 = match_unused2 << 1, /* unused */
  55. match_max = match_unused3,
  56. format_perl = 0, /* perl style replacement */
  57. format_default = 0, /* ditto. */
  58. format_sed = match_max << 1, /* sed style replacement. */
  59. format_all = format_sed << 1, /* enable all extentions to sytax. */
  60. format_no_copy = format_all << 1, /* don't copy non-matching segments. */
  61. format_first_only = format_no_copy << 1, /* Only replace first occurance. */
  62. format_is_if = format_first_only << 1, /* internal use only. */
  63. format_literal = format_is_if << 1, /* treat string as a literal */
  64. match_not_any = match_not_bol | match_not_eol | match_not_bob
  65. | match_not_eob | match_not_bow | match_not_eow | match_not_dot_newline
  66. | match_not_dot_null | match_prev_avail | match_init | match_not_null
  67. | match_continuous | match_partial | match_stop | match_not_initial_null
  68. | match_stop | match_all | match_perl | match_posix | match_nosubs
  69. | match_extra | match_single_line | match_unused1 | match_unused2
  70. | match_unused3 | match_max | format_perl | format_default | format_sed
  71. | format_all | format_no_copy | format_first_only | format_is_if
  72. | format_literal
  73. } match_flags;
  74. #if defined(__BORLANDC__) || (defined(_MSC_VER) && (_MSC_VER <= 1310))
  75. typedef unsigned long match_flag_type;
  76. #else
  77. typedef match_flags match_flag_type;
  78. #ifdef __cplusplus
  79. inline match_flags operator&(match_flags m1, match_flags m2)
  80. { return static_cast<match_flags>(static_cast<boost::int32_t>(m1) & static_cast<boost::int32_t>(m2)); }
  81. inline match_flags operator|(match_flags m1, match_flags m2)
  82. { return static_cast<match_flags>(static_cast<boost::int32_t>(m1) | static_cast<boost::int32_t>(m2)); }
  83. inline match_flags operator^(match_flags m1, match_flags m2)
  84. { return static_cast<match_flags>(static_cast<boost::int32_t>(m1) ^ static_cast<boost::int32_t>(m2)); }
  85. inline match_flags operator~(match_flags m1)
  86. { return static_cast<match_flags>(~static_cast<boost::int32_t>(m1)); }
  87. inline match_flags& operator&=(match_flags& m1, match_flags m2)
  88. { m1 = m1&m2; return m1; }
  89. inline match_flags& operator|=(match_flags& m1, match_flags m2)
  90. { m1 = m1|m2; return m1; }
  91. inline match_flags& operator^=(match_flags& m1, match_flags m2)
  92. { m1 = m1^m2; return m1; }
  93. #endif
  94. #endif
  95. #ifdef __cplusplus
  96. } /* namespace regex_constants */
  97. /*
  98. * import names into boost for backwards compatiblity:
  99. */
  100. using regex_constants::match_flag_type;
  101. using regex_constants::match_default;
  102. using regex_constants::match_not_bol;
  103. using regex_constants::match_not_eol;
  104. using regex_constants::match_not_bob;
  105. using regex_constants::match_not_eob;
  106. using regex_constants::match_not_bow;
  107. using regex_constants::match_not_eow;
  108. using regex_constants::match_not_dot_newline;
  109. using regex_constants::match_not_dot_null;
  110. using regex_constants::match_prev_avail;
  111. /* using regex_constants::match_init; */
  112. using regex_constants::match_any;
  113. using regex_constants::match_not_null;
  114. using regex_constants::match_continuous;
  115. using regex_constants::match_partial;
  116. /*using regex_constants::match_stop; */
  117. using regex_constants::match_all;
  118. using regex_constants::match_perl;
  119. using regex_constants::match_posix;
  120. using regex_constants::match_nosubs;
  121. using regex_constants::match_extra;
  122. using regex_constants::match_single_line;
  123. /*using regex_constants::match_max; */
  124. using regex_constants::format_all;
  125. using regex_constants::format_sed;
  126. using regex_constants::format_perl;
  127. using regex_constants::format_default;
  128. using regex_constants::format_no_copy;
  129. using regex_constants::format_first_only;
  130. /*using regex_constants::format_is_if;*/
  131. } /* namespace boost */
  132. #endif /* __cplusplus */
  133. #endif /* include guard */