File indexing completed on 2025-12-16 10:08:37
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 namespace boost{
0024 namespace BOOST_REGEX_DETAIL_NS{
0025
0026
0027 enum{
0028 sort_C,
0029 sort_fixed,
0030 sort_delim,
0031 sort_unknown
0032 };
0033
0034 template <class S, class charT>
0035 unsigned count_chars(const S& s, charT c)
0036 {
0037
0038
0039
0040
0041
0042
0043 unsigned int count = 0;
0044 for(unsigned pos = 0; pos < s.size(); ++pos)
0045 {
0046 if(s[pos] == c) ++count;
0047 }
0048 return count;
0049 }
0050
0051
0052 template <class traits, class charT>
0053 unsigned find_sort_syntax(const traits* pt, charT* delim)
0054 {
0055
0056
0057
0058
0059 typedef typename traits::string_type string_type;
0060 typedef typename traits::char_type char_type;
0061
0062
0063 (void)pt;
0064
0065 char_type a[2] = {'a', '\0', };
0066 string_type sa(pt->transform(a, a+1));
0067 if(sa == a)
0068 {
0069 *delim = 0;
0070 return sort_C;
0071 }
0072 char_type A[2] = { 'A', '\0', };
0073 string_type sA(pt->transform(A, A+1));
0074 char_type c[2] = { ';', '\0', };
0075 string_type sc(pt->transform(c, c+1));
0076
0077 int pos = 0;
0078 while((pos <= static_cast<int>(sa.size())) && (pos <= static_cast<int>(sA.size())) && (sa[pos] == sA[pos])) ++pos;
0079 --pos;
0080 if(pos < 0)
0081 {
0082 *delim = 0;
0083 return sort_unknown;
0084 }
0085
0086
0087
0088
0089 charT maybe_delim = sa[pos];
0090 if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(sc, maybe_delim)))
0091 {
0092 *delim = maybe_delim;
0093 return sort_delim;
0094 }
0095
0096
0097
0098 if((sa.size() == sA.size()) && (sa.size() == sc.size()))
0099 {
0100
0101
0102
0103 *delim = static_cast<charT>(++pos);
0104 return sort_fixed;
0105 }
0106
0107
0108
0109 *delim = 0;
0110 return sort_unknown;
0111 }
0112
0113
0114 }
0115 }
0116
0117 #endif
0118
0119
0120