123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
-
-
- #ifndef BOOST_REGEX_PRIMARY_TRANSFORM
- #define BOOST_REGEX_PRIMARY_TRANSFORM
- #ifdef BOOST_MSVC
- #pragma warning(push)
- #pragma warning(disable: 4103)
- #endif
- #ifdef BOOST_HAS_ABI_HEADERS
- # include BOOST_ABI_PREFIX
- #endif
- #ifdef BOOST_MSVC
- #pragma warning(pop)
- #endif
- namespace boost{
- namespace BOOST_REGEX_DETAIL_NS{
- enum{
- sort_C,
- sort_fixed,
- sort_delim,
- sort_unknown
- };
- template <class S, class charT>
- unsigned count_chars(const S& s, charT c)
- {
-
-
-
-
-
-
- unsigned int count = 0;
- for(unsigned pos = 0; pos < s.size(); ++pos)
- {
- if(s[pos] == c) ++count;
- }
- return count;
- }
- template <class traits, class charT>
- unsigned find_sort_syntax(const traits* pt, charT* delim)
- {
-
-
-
-
- typedef typename traits::string_type string_type;
- typedef typename traits::char_type char_type;
-
- (void)pt;
- char_type a[2] = {'a', '\0', };
- string_type sa(pt->transform(a, a+1));
- if(sa == a)
- {
- *delim = 0;
- return sort_C;
- }
- char_type A[2] = { 'A', '\0', };
- string_type sA(pt->transform(A, A+1));
- char_type c[2] = { ';', '\0', };
- string_type sc(pt->transform(c, c+1));
- int pos = 0;
- while((pos <= static_cast<int>(sa.size())) && (pos <= static_cast<int>(sA.size())) && (sa[pos] == sA[pos])) ++pos;
- --pos;
- if(pos < 0)
- {
- *delim = 0;
- return sort_unknown;
- }
-
-
-
-
- charT maybe_delim = sa[pos];
- if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(sc, maybe_delim)))
- {
- *delim = maybe_delim;
- return sort_delim;
- }
-
-
-
- if((sa.size() == sA.size()) && (sa.size() == sc.size()))
- {
-
-
-
- *delim = static_cast<charT>(++pos);
- return sort_fixed;
- }
-
-
-
- *delim = 0;
- return sort_unknown;
- }
- }
- }
- #ifdef BOOST_MSVC
- #pragma warning(push)
- #pragma warning(disable: 4103)
- #endif
- #ifdef BOOST_HAS_ABI_HEADERS
- # include BOOST_ABI_SUFFIX
- #endif
- #ifdef BOOST_MSVC
- #pragma warning(pop)
- #endif
- #endif
|