205
214
m_pctype = &BOOST_USE_FACET(std::ctype<charT>, l);
206
215
#ifndef BOOST_NO_STD_MESSAGES
207
m_pmessages = &BOOST_USE_FACET(std::messages<charT>, l);
216
m_pmessages = BOOST_HAS_FACET(std::messages<charT>, l) ? &BOOST_USE_FACET(std::messages<charT>, l) : 0;
209
218
m_pcollate = &BOOST_USE_FACET(std::collate<charT>, l);
401
417
BOOST_STATIC_CONSTANT(char_class_type, mask_blank = 1u << 24);
402
418
BOOST_STATIC_CONSTANT(char_class_type, mask_word = 1u << 25);
403
419
BOOST_STATIC_CONSTANT(char_class_type, mask_unicode = 1u << 26);
420
BOOST_STATIC_CONSTANT(char_class_type, mask_horizontal = 1u << 27);
421
BOOST_STATIC_CONSTANT(char_class_type, mask_vertical = 1u << 28);
406
424
typedef std::basic_string<charT> string_type;
407
425
typedef charT char_type;
408
426
//cpp_regex_traits_implementation();
409
427
cpp_regex_traits_implementation(const std::locale& l)
410
: cpp_regex_traits_char_layer<charT>(l), m_is(&m_sbuf)
428
: cpp_regex_traits_char_layer<charT>(l)
414
432
cpp_regex_traits_implementation(const cpp_regex_traits_base<charT>& l)
415
: cpp_regex_traits_char_layer<charT>(l), m_is(&m_sbuf)
433
: cpp_regex_traits_char_layer<charT>(l)
439
457
string_type lookup_collatename(const charT* p1, const charT* p2) const;
440
458
string_type transform_primary(const charT* p1, const charT* p2) const;
441
459
string_type transform(const charT* p1, const charT* p2) const;
442
re_detail::parser_buf<charT> m_sbuf; // buffer for parsing numbers.
443
std::basic_istream<charT> m_is; // stream for parsing numbers.
445
461
std::map<int, std::string> m_error_strings; // error messages indexed by numberic ID
446
462
std::map<string_type, char_class_type> m_custom_class_names; // character class names
564
584
// std::collate<wchar_t>::transform returns a different string!
565
585
// So as a workaround, we'll truncate the string at the first NULL
566
586
// which _seems_ to work....
567
#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
587
#if BOOST_WORKAROUND(__BORLANDC__, < 0x580)
568
588
result.erase(result.find(charT(0)));
678
698
// Custom class names:
680
700
#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET
681
static const char_class_type masks[14] =
701
static const char_class_type masks[16] =
683
703
std::ctype<charT>::alnum,
684
704
std::ctype<charT>::alpha,
685
705
std::ctype<charT>::cntrl,
686
706
std::ctype<charT>::digit,
687
707
std::ctype<charT>::graph,
708
cpp_regex_traits_implementation<charT>::mask_horizontal,
688
709
std::ctype<charT>::lower,
689
710
std::ctype<charT>::print,
690
711
std::ctype<charT>::punct,
691
712
std::ctype<charT>::space,
692
713
std::ctype<charT>::upper,
714
cpp_regex_traits_implementation<charT>::mask_vertical,
693
715
std::ctype<charT>::xdigit,
694
716
cpp_regex_traits_implementation<charT>::mask_blank,
695
717
cpp_regex_traits_implementation<charT>::mask_word,
696
718
cpp_regex_traits_implementation<charT>::mask_unicode,
699
static const char_class_type masks[14] =
721
static const char_class_type masks[16] =
701
723
::boost::re_detail::char_class_alnum,
702
724
::boost::re_detail::char_class_alpha,
703
725
::boost::re_detail::char_class_cntrl,
704
726
::boost::re_detail::char_class_digit,
705
727
::boost::re_detail::char_class_graph,
728
::boost::re_detail::char_class_horizontal_space,
706
729
::boost::re_detail::char_class_lower,
707
730
::boost::re_detail::char_class_print,
708
731
::boost::re_detail::char_class_punct,
709
732
::boost::re_detail::char_class_space,
710
733
::boost::re_detail::char_class_upper,
734
::boost::re_detail::char_class_vertical_space,
711
735
::boost::re_detail::char_class_xdigit,
712
736
::boost::re_detail::char_class_blank,
713
737
::boost::re_detail::char_class_word,
753
778
std::ctype<char>::upper,
754
779
cpp_regex_traits_implementation<charT>::mask_unicode,
755
780
std::ctype<char>::upper,
781
cpp_regex_traits_implementation<charT>::mask_vertical,
756
782
std::ctype<char>::alnum | cpp_regex_traits_implementation<charT>::mask_word,
757
783
std::ctype<char>::alnum | cpp_regex_traits_implementation<charT>::mask_word,
758
784
std::ctype<char>::xdigit,
761
static const char_class_type masks[20] =
787
static const char_class_type masks[22] =
764
790
::boost::re_detail::char_class_alnum,
768
794
::boost::re_detail::char_class_digit,
769
795
::boost::re_detail::char_class_digit,
770
796
::boost::re_detail::char_class_graph,
797
::boost::re_detail::char_class_horizontal_space,
771
798
::boost::re_detail::char_class_lower,
772
799
::boost::re_detail::char_class_lower,
773
800
::boost::re_detail::char_class_print,
777
804
::boost::re_detail::char_class_upper,
778
805
::boost::re_detail::char_class_unicode,
779
806
::boost::re_detail::char_class_upper,
807
::boost::re_detail::char_class_vertical_space,
780
808
::boost::re_detail::char_class_alnum | ::boost::re_detail::char_class_word,
781
809
::boost::re_detail::char_class_alnum | ::boost::re_detail::char_class_word,
782
810
::boost::re_detail::char_class_xdigit,
789
817
if(pos != m_custom_class_names.end())
790
818
return pos->second;
792
std::size_t id = 1 + re_detail::get_default_class_id(p1, p2);
793
BOOST_ASSERT(id < sizeof(masks) / sizeof(masks[0]));
820
std::size_t state_id = 1 + re_detail::get_default_class_id(p1, p2);
821
BOOST_ASSERT(state_id < sizeof(masks) / sizeof(masks[0]));
822
return masks[state_id];
797
825
#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET
810
838
|| ((mask & ::boost::re_detail::char_class_xdigit) && (m_pctype->is(std::ctype<charT>::xdigit, c)))
811
839
|| ((mask & ::boost::re_detail::char_class_blank) && (m_pctype->is(std::ctype<charT>::space, c)) && !::boost::re_detail::is_separator(c))
812
840
|| ((mask & ::boost::re_detail::char_class_word) && (c == '_'))
813
|| ((mask & ::boost::re_detail::char_class_unicode) && ::boost::re_detail::is_extended(c));
841
|| ((mask & ::boost::re_detail::char_class_unicode) && ::boost::re_detail::is_extended(c))
842
|| ((mask & ::boost::re_detail::char_class_vertical_space) && (is_separator(c) || (c == '\v')))
843
|| ((mask & ::boost::re_detail::char_class_horizontal_space) && m_pctype->is(std::ctype<charT>::space, c) && !(is_separator(c) || (c == '\v')));
818
848
template <class charT>
819
inline boost::shared_ptr<cpp_regex_traits_implementation<charT> > create_cpp_regex_traits(const std::locale& l BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(charT))
849
inline boost::shared_ptr<const cpp_regex_traits_implementation<charT> > create_cpp_regex_traits(const std::locale& l BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(charT))
821
851
cpp_regex_traits_base<charT> key(l);
822
852
return ::boost::object_cache<cpp_regex_traits_base<charT>, cpp_regex_traits_implementation<charT> >::get(key, 5);
920
950
&& m_pimpl->m_pctype->is(std::ctype<charT>::space, c)
921
951
&& !re_detail::is_separator(c))
953
else if((f & re_detail::cpp_regex_traits_implementation<charT>::mask_vertical)
954
&& (::boost::re_detail::is_separator(c) || (c == '\v')))
956
else if((f & re_detail::cpp_regex_traits_implementation<charT>::mask_horizontal)
957
&& this->isctype(c, std::ctype<charT>::space) && !this->isctype(c, re_detail::cpp_regex_traits_implementation<charT>::mask_vertical))
925
961
return m_pimpl->isctype(c, f);
969
1005
template <class charT>
970
1006
int cpp_regex_traits<charT>::toi(const charT*& first, const charT* last, int radix)const
1008
re_detail::parser_buf<charT> sbuf; // buffer for parsing numbers.
1009
std::basic_istream<charT> is(&sbuf); // stream for parsing numbers.
972
1011
// we do NOT want to parse any thousands separators inside the stream:
973
last = std::find(first, last, BOOST_USE_FACET(std::numpunct<charT>, m_pimpl->m_is.getloc()).thousands_sep());
974
m_pimpl->m_sbuf.pubsetbuf(const_cast<charT*>(static_cast<const charT*>(first)), static_cast<std::streamsize>(last-first));
975
m_pimpl->m_is.clear();
976
if(std::abs(radix) == 16) m_pimpl->m_is >> std::hex;
977
else if(std::abs(radix) == 8) m_pimpl->m_is >> std::oct;
978
else m_pimpl->m_is >> std::dec;
1012
last = std::find(first, last, BOOST_USE_FACET(std::numpunct<charT>, is.getloc()).thousands_sep());
1014
sbuf.pubsetbuf(const_cast<charT*>(static_cast<const charT*>(first)), static_cast<std::streamsize>(last-first));
1016
if(std::abs(radix) == 16) is >> std::hex;
1017
else if(std::abs(radix) == 8) is >> std::oct;
1018
else is >> std::dec;
980
if(m_pimpl->m_is >> val)
982
first = first + ((last - first) - m_pimpl->m_sbuf.in_avail());
1022
first = first + ((last - first) - sbuf.in_avail());