File indexing completed on 2025-01-18 09:51:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef BOOST_REGEX_PRIMARY_TRANSFORM
0021 #define BOOST_REGEX_PRIMARY_TRANSFORM
0022
0023 #ifdef BOOST_MSVC
0024 #pragma warning(push)
0025 #pragma warning(disable: 4103)
0026 #endif
0027 #ifdef BOOST_HAS_ABI_HEADERS
0028 # include BOOST_ABI_PREFIX
0029 #endif
0030 #ifdef BOOST_MSVC
0031 #pragma warning(pop)
0032 #endif
0033
0034 namespace boost{
0035 namespace BOOST_REGEX_DETAIL_NS{
0036
0037
0038 enum{
0039 sort_C,
0040 sort_fixed,
0041 sort_delim,
0042 sort_unknown
0043 };
0044
0045 template <class S, class charT>
0046 unsigned count_chars(const S& s, charT c)
0047 {
0048
0049
0050
0051
0052
0053
0054 unsigned int count = 0;
0055 for(unsigned pos = 0; pos < s.size(); ++pos)
0056 {
0057 if(s[pos] == c) ++count;
0058 }
0059 return count;
0060 }
0061
0062
0063 template <class traits, class charT>
0064 unsigned find_sort_syntax(const traits* pt, charT* delim)
0065 {
0066
0067
0068
0069
0070 typedef typename traits::string_type string_type;
0071 typedef typename traits::char_type char_type;
0072
0073
0074 (void)pt;
0075
0076 char_type a[2] = {'a', '\0', };
0077 string_type sa(pt->transform(a, a+1));
0078 if(sa == a)
0079 {
0080 *delim = 0;
0081 return sort_C;
0082 }
0083 char_type A[2] = { 'A', '\0', };
0084 string_type sA(pt->transform(A, A+1));
0085 char_type c[2] = { ';', '\0', };
0086 string_type sc(pt->transform(c, c+1));
0087
0088 int pos = 0;
0089 while((pos <= static_cast<int>(sa.size())) && (pos <= static_cast<int>(sA.size())) && (sa[pos] == sA[pos])) ++pos;
0090 --pos;
0091 if(pos < 0)
0092 {
0093 *delim = 0;
0094 return sort_unknown;
0095 }
0096
0097
0098
0099
0100 charT maybe_delim = sa[pos];
0101 if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(sc, maybe_delim)))
0102 {
0103 *delim = maybe_delim;
0104 return sort_delim;
0105 }
0106
0107
0108
0109 if((sa.size() == sA.size()) && (sa.size() == sc.size()))
0110 {
0111
0112
0113
0114 *delim = static_cast<charT>(++pos);
0115 return sort_fixed;
0116 }
0117
0118
0119
0120 *delim = 0;
0121 return sort_unknown;
0122 }
0123
0124
0125 }
0126 }
0127
0128 #ifdef BOOST_MSVC
0129 #pragma warning(push)
0130 #pragma warning(disable: 4103)
0131 #endif
0132 #ifdef BOOST_HAS_ABI_HEADERS
0133 # include BOOST_ABI_SUFFIX
0134 #endif
0135 #ifdef BOOST_MSVC
0136 #pragma warning(pop)
0137 #endif
0138
0139 #endif
0140
0141
0142
0143
0144
0145
0146