diff options
author | thegeorg <thegeorg@yandex-team.com> | 2023-06-28 20:00:21 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2023-06-28 20:00:21 +0300 |
commit | 0abb29c131758b92583251c6051e12add7083c29 (patch) | |
tree | 0f02449b3164ca1144fa29b697139e1db92912ba /contrib/restricted/boost/regex | |
parent | c47dcb09adea44757e308fd4e8ce44fa17bb55b8 (diff) | |
download | ydb-0abb29c131758b92583251c6051e12add7083c29.tar.gz |
Add ydb to sandboxing autocheck
Stop copying entire boost/ into ydb project
Diffstat (limited to 'contrib/restricted/boost/regex')
15 files changed, 0 insertions, 7228 deletions
diff --git a/contrib/restricted/boost/regex/include/boost/regex.h b/contrib/restricted/boost/regex/include/boost/regex.h deleted file mode 100644 index 52af275cfa..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * - * Copyright (c) 1998-2000 - * Dr John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org/libs/regex for documentation. - * FILE regex.h - * VERSION 3.12 - * DESCRIPTION: Declares POSIX API functions - */ - -#ifndef BOOST_RE_REGEX_H -#define BOOST_RE_REGEX_H - -#include <boost/cregex.hpp> - -/* -* add using declarations to bring POSIX API functions into -* global scope, only if this is C++ (and not C). -*/ -#ifdef __cplusplus - -using boost::regoff_t; -using boost::regex_tA; -using boost::regmatch_t; -using boost::REG_BASIC; -using boost::REG_EXTENDED; -using boost::REG_ICASE; -using boost::REG_NOSUB; -using boost::REG_NEWLINE; -using boost::REG_NOSPEC; -using boost::REG_PEND; -using boost::REG_DUMP; -using boost::REG_NOCOLLATE; -using boost::REG_ESCAPE_IN_LISTS; -using boost::REG_NEWLINE_ALT; -using boost::REG_PERL; -using boost::REG_AWK; -using boost::REG_GREP; -using boost::REG_EGREP; -using boost::REG_ASSERT; -using boost::REG_INVARG; -using boost::REG_ATOI; -using boost::REG_ITOA; - -using boost::REG_NOTBOL; -using boost::REG_NOTEOL; -using boost::REG_STARTEND; - -using boost::reg_comp_flags; -using boost::reg_exec_flags; -using boost::regcompA; -using boost::regerrorA; -using boost::regexecA; -using boost::regfreeA; - -#ifndef BOOST_NO_WREGEX -using boost::regcompW; -using boost::regerrorW; -using boost::regexecW; -using boost::regfreeW; -using boost::regex_tW; -#endif - -using boost::REG_NOERROR; -using boost::REG_NOMATCH; -using boost::REG_BADPAT; -using boost::REG_ECOLLATE; -using boost::REG_ECTYPE; -using boost::REG_EESCAPE; -using boost::REG_ESUBREG; -using boost::REG_EBRACK; -using boost::REG_EPAREN; -using boost::REG_EBRACE; -using boost::REG_BADBR; -using boost::REG_ERANGE; -using boost::REG_ESPACE; -using boost::REG_BADRPT; -using boost::REG_EEND; -using boost::REG_ESIZE; -using boost::REG_ERPAREN; -using boost::REG_EMPTY; -using boost::REG_E_MEMORY; -using boost::REG_E_UNKNOWN; -using boost::reg_errcode_t; - -#endif /* __cplusplus */ - -#endif /* BOOST_RE_REGEX_H */ - - - - diff --git a/contrib/restricted/boost/regex/include/boost/regex/concepts.hpp b/contrib/restricted/boost/regex/include/boost/regex/concepts.hpp deleted file mode 100644 index 2eafac1b57..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/concepts.hpp +++ /dev/null @@ -1,1134 +0,0 @@ -/* - * - * Copyright (c) 2004 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE concepts.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Declares regular expression concepts. - */ - -#ifndef BOOST_REGEX_CONCEPTS_HPP_INCLUDED -#define BOOST_REGEX_CONCEPTS_HPP_INCLUDED - -#include <boost/concept_archetype.hpp> -#include <boost/concept_check.hpp> -#include <boost/type_traits/is_enum.hpp> -#include <boost/type_traits/is_base_and_derived.hpp> -#include <boost/static_assert.hpp> -#ifndef BOOST_TEST_TR1_REGEX -#include <boost/regex.hpp> -#endif -#include <bitset> -#include <vector> -#include <ostream> - -#ifdef BOOST_REGEX_CXX03 -#define RW_NS boost -#else -#define RW_NS std -#endif - -namespace boost{ - -// -// bitmask_archetype: -// this can be either an integer type, an enum, or a std::bitset, -// we use the latter as the architype as it offers the "strictest" -// of the possible interfaces: -// -typedef std::bitset<512> bitmask_archetype; -// -// char_architype: -// A strict model for the character type interface. -// -struct char_architype -{ - // default constructable: - char_architype(); - // copy constructable / assignable: - char_architype(const char_architype&); - char_architype& operator=(const char_architype&); - // constructable from an integral value: - char_architype(unsigned long val); - // comparable: - bool operator==(const char_architype&)const; - bool operator!=(const char_architype&)const; - bool operator<(const char_architype&)const; - bool operator<=(const char_architype&)const; - bool operator>=(const char_architype&)const; - bool operator>(const char_architype&)const; - // conversion to integral type: - operator long()const; -}; -inline long hash_value(char_architype val) -{ return val; } -// -// char_architype can not be used with basic_string: -// -} // namespace boost -namespace std{ - template<> struct char_traits<boost::char_architype> - { - // The intent is that this template is not instantiated, - // but this typedef gives us a chance of compilation in - // case it is: - typedef boost::char_architype char_type; - }; -} -// -// Allocator architype: -// -template <class T> -class allocator_architype -{ -public: - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef T value_type; - typedef unsigned size_type; - typedef int difference_type; - - template <class U> - struct rebind - { - typedef allocator_architype<U> other; - }; - - pointer address(reference r){ return &r; } - const_pointer address(const_reference r) { return &r; } - pointer allocate(size_type n) { return static_cast<pointer>(std::malloc(n)); } - pointer allocate(size_type n, pointer) { return static_cast<pointer>(std::malloc(n)); } - void deallocate(pointer p, size_type) { std::free(p); } - size_type max_size()const { return UINT_MAX; } - - allocator_architype(){} - allocator_architype(const allocator_architype&){} - - template <class Other> - allocator_architype(const allocator_architype<Other>&){} - - void construct(pointer p, const_reference r) { new (p)T(r); } - void destroy(pointer p) { p->~T(); } -}; - -template <class T> -bool operator == (const allocator_architype<T>&, const allocator_architype<T>&) {return true; } -template <class T> -bool operator != (const allocator_architype<T>&, const allocator_architype<T>&) { return false; } - -namespace boost{ -// -// regex_traits_architype: -// A strict interpretation of the regular expression traits class requirements. -// -template <class charT> -struct regex_traits_architype -{ -public: - regex_traits_architype(){} - typedef charT char_type; - // typedef std::size_t size_type; - typedef std::vector<char_type> string_type; - typedef copy_constructible_archetype<assignable_archetype<> > locale_type; - typedef bitmask_archetype char_class_type; - - static std::size_t length(const char_type* ) { return 0; } - - charT translate(charT ) const { return charT(); } - charT translate_nocase(charT ) const { return static_object<charT>::get(); } - - template <class ForwardIterator> - string_type transform(ForwardIterator , ForwardIterator ) const - { return static_object<string_type>::get(); } - template <class ForwardIterator> - string_type transform_primary(ForwardIterator , ForwardIterator ) const - { return static_object<string_type>::get(); } - - template <class ForwardIterator> - char_class_type lookup_classname(ForwardIterator , ForwardIterator ) const - { return static_object<char_class_type>::get(); } - template <class ForwardIterator> - string_type lookup_collatename(ForwardIterator , ForwardIterator ) const - { return static_object<string_type>::get(); } - - bool isctype(charT, char_class_type) const - { return false; } - int value(charT, int) const - { return 0; } - - locale_type imbue(locale_type l) - { return l; } - locale_type getloc()const - { return static_object<locale_type>::get(); } - -private: - // this type is not copyable: - regex_traits_architype(const regex_traits_architype&){} - regex_traits_architype& operator=(const regex_traits_architype&){ return *this; } -}; - -// -// alter this to std::tr1, to test a std implementation: -// -#ifndef BOOST_TEST_TR1_REGEX -namespace global_regex_namespace = ::boost; -#else -namespace global_regex_namespace = ::std::tr1; -#endif - -template <class Bitmask> -struct BitmaskConcept -{ - void constraints() - { - function_requires<CopyConstructibleConcept<Bitmask> >(); - function_requires<AssignableConcept<Bitmask> >(); - - m_mask1 = m_mask2 | m_mask3; - m_mask1 = m_mask2 & m_mask3; - m_mask1 = m_mask2 ^ m_mask3; - - m_mask1 = ~m_mask2; - - m_mask1 |= m_mask2; - m_mask1 &= m_mask2; - m_mask1 ^= m_mask2; - } - Bitmask m_mask1, m_mask2, m_mask3; -}; - -template <class traits> -struct RegexTraitsConcept -{ - RegexTraitsConcept(); - // required typedefs: - typedef typename traits::char_type char_type; - // typedef typename traits::size_type size_type; - typedef typename traits::string_type string_type; - typedef typename traits::locale_type locale_type; - typedef typename traits::char_class_type char_class_type; - - void constraints() - { - //function_requires<UnsignedIntegerConcept<size_type> >(); - function_requires<RandomAccessContainerConcept<string_type> >(); - function_requires<DefaultConstructibleConcept<locale_type> >(); - function_requires<CopyConstructibleConcept<locale_type> >(); - function_requires<AssignableConcept<locale_type> >(); - function_requires<BitmaskConcept<char_class_type> >(); - - std::size_t n = traits::length(m_pointer); - ignore_unused_variable_warning(n); - - char_type c = m_ctraits.translate(m_char); - ignore_unused_variable_warning(c); - c = m_ctraits.translate_nocase(m_char); - - //string_type::foobar bar; - string_type s1 = m_ctraits.transform(m_pointer, m_pointer); - ignore_unused_variable_warning(s1); - - string_type s2 = m_ctraits.transform_primary(m_pointer, m_pointer); - ignore_unused_variable_warning(s2); - - char_class_type cc = m_ctraits.lookup_classname(m_pointer, m_pointer); - ignore_unused_variable_warning(cc); - - string_type s3 = m_ctraits.lookup_collatename(m_pointer, m_pointer); - ignore_unused_variable_warning(s3); - - bool b = m_ctraits.isctype(m_char, cc); - ignore_unused_variable_warning(b); - - int v = m_ctraits.value(m_char, 16); - ignore_unused_variable_warning(v); - - locale_type l(m_ctraits.getloc()); - m_traits.imbue(l); - ignore_unused_variable_warning(l); - } - traits m_traits; - const traits m_ctraits; - const char_type* m_pointer; - char_type m_char; -private: - RegexTraitsConcept& operator=(RegexTraitsConcept&); -}; - -// -// helper class to compute what traits class a regular expression type is using: -// -template <class Regex> -struct regex_traits_computer; - -template <class charT, class traits> -struct regex_traits_computer< global_regex_namespace::basic_regex<charT, traits> > -{ - typedef traits type; -}; - -// -// BaseRegexConcept does not test anything dependent on basic_string, -// in case our charT does not have an associated char_traits: -// -template <class Regex> -struct BaseRegexConcept -{ - typedef typename Regex::value_type value_type; - //typedef typename Regex::size_type size_type; - typedef typename Regex::flag_type flag_type; - typedef typename Regex::locale_type locale_type; - typedef input_iterator_archetype<value_type> input_iterator_type; - - // derived test types: - typedef const value_type* pointer_type; - typedef bidirectional_iterator_archetype<value_type> BidiIterator; - typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type; - typedef global_regex_namespace::match_results<BidiIterator, allocator_architype<sub_match_type> > match_results_type; - typedef global_regex_namespace::match_results<BidiIterator> match_results_default_type; - typedef output_iterator_archetype<value_type> OutIterator; - typedef typename regex_traits_computer<Regex>::type traits_type; - typedef global_regex_namespace::regex_iterator<BidiIterator, value_type, traits_type> regex_iterator_type; - typedef global_regex_namespace::regex_token_iterator<BidiIterator, value_type, traits_type> regex_token_iterator_type; - - void global_constraints() - { - // - // test non-template components: - // - function_requires<BitmaskConcept<global_regex_namespace::regex_constants::syntax_option_type> >(); - global_regex_namespace::regex_constants::syntax_option_type opts - = global_regex_namespace::regex_constants::icase - | global_regex_namespace::regex_constants::nosubs - | global_regex_namespace::regex_constants::optimize - | global_regex_namespace::regex_constants::collate - | global_regex_namespace::regex_constants::ECMAScript - | global_regex_namespace::regex_constants::basic - | global_regex_namespace::regex_constants::extended - | global_regex_namespace::regex_constants::awk - | global_regex_namespace::regex_constants::grep - | global_regex_namespace::regex_constants::egrep; - ignore_unused_variable_warning(opts); - - function_requires<BitmaskConcept<global_regex_namespace::regex_constants::match_flag_type> >(); - global_regex_namespace::regex_constants::match_flag_type mopts - = global_regex_namespace::regex_constants::match_default - | global_regex_namespace::regex_constants::match_not_bol - | global_regex_namespace::regex_constants::match_not_eol - | global_regex_namespace::regex_constants::match_not_bow - | global_regex_namespace::regex_constants::match_not_eow - | global_regex_namespace::regex_constants::match_any - | global_regex_namespace::regex_constants::match_not_null - | global_regex_namespace::regex_constants::match_continuous - | global_regex_namespace::regex_constants::match_prev_avail - | global_regex_namespace::regex_constants::format_default - | global_regex_namespace::regex_constants::format_sed - | global_regex_namespace::regex_constants::format_no_copy - | global_regex_namespace::regex_constants::format_first_only; - ignore_unused_variable_warning(mopts); - - BOOST_STATIC_ASSERT((::boost::is_enum<global_regex_namespace::regex_constants::error_type>::value)); - global_regex_namespace::regex_constants::error_type e1 = global_regex_namespace::regex_constants::error_collate; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_ctype; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_escape; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_backref; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_brack; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_paren; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_brace; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_badbrace; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_range; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_space; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_badrepeat; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_complexity; - ignore_unused_variable_warning(e1); - e1 = global_regex_namespace::regex_constants::error_stack; - ignore_unused_variable_warning(e1); - - BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::runtime_error, global_regex_namespace::regex_error>::value )); - const global_regex_namespace::regex_error except(e1); - e1 = except.code(); - - typedef typename Regex::value_type regex_value_type; - function_requires< RegexTraitsConcept<global_regex_namespace::regex_traits<char> > >(); - function_requires< BaseRegexConcept<global_regex_namespace::basic_regex<char> > >(); - } - void constraints() - { - global_constraints(); - - BOOST_STATIC_ASSERT((::boost::is_same< flag_type, global_regex_namespace::regex_constants::syntax_option_type>::value)); - flag_type opts - = Regex::icase - | Regex::nosubs - | Regex::optimize - | Regex::collate - | Regex::ECMAScript - | Regex::basic - | Regex::extended - | Regex::awk - | Regex::grep - | Regex::egrep; - ignore_unused_variable_warning(opts); - - function_requires<DefaultConstructibleConcept<Regex> >(); - function_requires<CopyConstructibleConcept<Regex> >(); - - // Regex constructors: - Regex e1(m_pointer); - ignore_unused_variable_warning(e1); - Regex e2(m_pointer, m_flags); - ignore_unused_variable_warning(e2); - Regex e3(m_pointer, m_size, m_flags); - ignore_unused_variable_warning(e3); - Regex e4(in1, in2); - ignore_unused_variable_warning(e4); - Regex e5(in1, in2, m_flags); - ignore_unused_variable_warning(e5); - - // assign etc: - Regex e; - e = m_pointer; - e = e1; - e.assign(e1); - e.assign(m_pointer); - e.assign(m_pointer, m_flags); - e.assign(m_pointer, m_size, m_flags); - e.assign(in1, in2); - e.assign(in1, in2, m_flags); - - // access: - const Regex ce; - typename Regex::size_type i = ce.mark_count(); - ignore_unused_variable_warning(i); - m_flags = ce.flags(); - e.imbue(ce.getloc()); - e.swap(e1); - - global_regex_namespace::swap(e, e1); - - // sub_match: - BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::pair<BidiIterator, BidiIterator>, sub_match_type>::value)); - typedef typename sub_match_type::value_type sub_value_type; - typedef typename sub_match_type::difference_type sub_diff_type; - typedef typename sub_match_type::iterator sub_iter_type; - BOOST_STATIC_ASSERT((::boost::is_same<sub_value_type, value_type>::value)); - BOOST_STATIC_ASSERT((::boost::is_same<sub_iter_type, BidiIterator>::value)); - bool b = m_sub.matched; - ignore_unused_variable_warning(b); - BidiIterator bi = m_sub.first; - ignore_unused_variable_warning(bi); - bi = m_sub.second; - ignore_unused_variable_warning(bi); - sub_diff_type diff = m_sub.length(); - ignore_unused_variable_warning(diff); - // match_results tests - some typedefs are not used, however these - // guarante that they exist (some compilers may warn on non-usage) - typedef typename match_results_type::value_type mr_value_type; - typedef typename match_results_type::const_reference mr_const_reference; - typedef typename match_results_type::reference mr_reference; - typedef typename match_results_type::const_iterator mr_const_iterator; - typedef typename match_results_type::iterator mr_iterator; - typedef typename match_results_type::difference_type mr_difference_type; - typedef typename match_results_type::size_type mr_size_type; - typedef typename match_results_type::allocator_type mr_allocator_type; - typedef typename match_results_type::char_type mr_char_type; - typedef typename match_results_type::string_type mr_string_type; - - match_results_type m1; - mr_allocator_type at; - match_results_type m2(at); - match_results_type m3(m1); - m1 = m2; - - int ival = 0; - - mr_size_type mrs = m_cresults.size(); - ignore_unused_variable_warning(mrs); - mrs = m_cresults.max_size(); - ignore_unused_variable_warning(mrs); - b = m_cresults.empty(); - ignore_unused_variable_warning(b); - mr_difference_type mrd = m_cresults.length(); - ignore_unused_variable_warning(mrd); - mrd = m_cresults.length(ival); - ignore_unused_variable_warning(mrd); - mrd = m_cresults.position(); - ignore_unused_variable_warning(mrd); - mrd = m_cresults.position(mrs); - ignore_unused_variable_warning(mrd); - - mr_const_reference mrcr = m_cresults[ival]; - ignore_unused_variable_warning(mrcr); - mr_const_reference mrcr2 = m_cresults.prefix(); - ignore_unused_variable_warning(mrcr2); - mr_const_reference mrcr3 = m_cresults.suffix(); - ignore_unused_variable_warning(mrcr3); - mr_const_iterator mrci = m_cresults.begin(); - ignore_unused_variable_warning(mrci); - mrci = m_cresults.end(); - ignore_unused_variable_warning(mrci); - - (void) m_cresults.get_allocator(); - m_results.swap(m_results); - global_regex_namespace::swap(m_results, m_results); - - // regex_match: - b = global_regex_namespace::regex_match(m_in, m_in, m_results, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_match(m_in, m_in, m_results, e, m_mft); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_match(m_in, m_in, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_match(m_in, m_in, e, m_mft); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e, m_mft); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_match(m_pointer, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_match(m_pointer, e, m_mft); - ignore_unused_variable_warning(b); - // regex_search: - b = global_regex_namespace::regex_search(m_in, m_in, m_results, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_search(m_in, m_in, m_results, e, m_mft); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_search(m_in, m_in, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_search(m_in, m_in, e, m_mft); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e, m_mft); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_search(m_pointer, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_search(m_pointer, e, m_mft); - ignore_unused_variable_warning(b); - - // regex_iterator: - typedef typename regex_iterator_type::regex_type rit_regex_type; - typedef typename regex_iterator_type::value_type rit_value_type; - typedef typename regex_iterator_type::difference_type rit_difference_type; - typedef typename regex_iterator_type::pointer rit_pointer; - typedef typename regex_iterator_type::reference rit_reference; - typedef typename regex_iterator_type::iterator_category rit_iterator_category; - BOOST_STATIC_ASSERT((::boost::is_same<rit_regex_type, Regex>::value)); - BOOST_STATIC_ASSERT((::boost::is_same<rit_value_type, match_results_default_type>::value)); - BOOST_STATIC_ASSERT((::boost::is_same<rit_difference_type, std::ptrdiff_t>::value)); - BOOST_STATIC_ASSERT((::boost::is_same<rit_pointer, const match_results_default_type*>::value)); - BOOST_STATIC_ASSERT((::boost::is_same<rit_reference, const match_results_default_type&>::value)); - BOOST_STATIC_ASSERT((::boost::is_convertible<rit_iterator_category*, std::forward_iterator_tag*>::value)); - // this takes care of most of the checks needed: - function_requires<ForwardIteratorConcept<regex_iterator_type> >(); - regex_iterator_type iter1(m_in, m_in, e); - ignore_unused_variable_warning(iter1); - regex_iterator_type iter2(m_in, m_in, e, m_mft); - ignore_unused_variable_warning(iter2); - - // regex_token_iterator: - typedef typename regex_token_iterator_type::regex_type rtit_regex_type; - typedef typename regex_token_iterator_type::value_type rtit_value_type; - typedef typename regex_token_iterator_type::difference_type rtit_difference_type; - typedef typename regex_token_iterator_type::pointer rtit_pointer; - typedef typename regex_token_iterator_type::reference rtit_reference; - typedef typename regex_token_iterator_type::iterator_category rtit_iterator_category; - BOOST_STATIC_ASSERT((::boost::is_same<rtit_regex_type, Regex>::value)); - BOOST_STATIC_ASSERT((::boost::is_same<rtit_value_type, sub_match_type>::value)); - BOOST_STATIC_ASSERT((::boost::is_same<rtit_difference_type, std::ptrdiff_t>::value)); - BOOST_STATIC_ASSERT((::boost::is_same<rtit_pointer, const sub_match_type*>::value)); - BOOST_STATIC_ASSERT((::boost::is_same<rtit_reference, const sub_match_type&>::value)); - BOOST_STATIC_ASSERT((::boost::is_convertible<rtit_iterator_category*, std::forward_iterator_tag*>::value)); - // this takes care of most of the checks needed: - function_requires<ForwardIteratorConcept<regex_token_iterator_type> >(); - regex_token_iterator_type ti1(m_in, m_in, e); - ignore_unused_variable_warning(ti1); - regex_token_iterator_type ti2(m_in, m_in, e, 0); - ignore_unused_variable_warning(ti2); - regex_token_iterator_type ti3(m_in, m_in, e, 0, m_mft); - ignore_unused_variable_warning(ti3); - std::vector<int> subs; - regex_token_iterator_type ti4(m_in, m_in, e, subs); - ignore_unused_variable_warning(ti4); - regex_token_iterator_type ti5(m_in, m_in, e, subs, m_mft); - ignore_unused_variable_warning(ti5); - static const int i_array[3] = { 1, 2, 3, }; - regex_token_iterator_type ti6(m_in, m_in, e, i_array); - ignore_unused_variable_warning(ti6); - regex_token_iterator_type ti7(m_in, m_in, e, i_array, m_mft); - ignore_unused_variable_warning(ti7); - } - - pointer_type m_pointer; - flag_type m_flags; - std::size_t m_size; - input_iterator_type in1, in2; - const sub_match_type m_sub; - const value_type m_char; - match_results_type m_results; - const match_results_type m_cresults; - OutIterator m_out; - BidiIterator m_in; - global_regex_namespace::regex_constants::match_flag_type m_mft; - global_regex_namespace::match_results< - pointer_type, - allocator_architype<global_regex_namespace::sub_match<pointer_type> > > - m_pmatch; - - BaseRegexConcept(); - BaseRegexConcept(const BaseRegexConcept&); - BaseRegexConcept& operator=(const BaseRegexConcept&); -}; - -// -// RegexConcept: -// Test every interface in the std: -// -template <class Regex> -struct RegexConcept -{ - typedef typename Regex::value_type value_type; - //typedef typename Regex::size_type size_type; - typedef typename Regex::flag_type flag_type; - typedef typename Regex::locale_type locale_type; - - // derived test types: - typedef const value_type* pointer_type; - typedef std::basic_string<value_type> string_type; - typedef boost::bidirectional_iterator_archetype<value_type> BidiIterator; - typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type; - typedef global_regex_namespace::match_results<BidiIterator, allocator_architype<sub_match_type> > match_results_type; - typedef output_iterator_archetype<value_type> OutIterator; - - - void constraints() - { - function_requires<BaseRegexConcept<Regex> >(); - // string based construct: - Regex e1(m_string); - ignore_unused_variable_warning(e1); - Regex e2(m_string, m_flags); - ignore_unused_variable_warning(e2); - - // assign etc: - Regex e; - e = m_string; - e.assign(m_string); - e.assign(m_string, m_flags); - - // sub_match: - string_type s(m_sub); - ignore_unused_variable_warning(s); - s = m_sub.str(); - ignore_unused_variable_warning(s); - int i = m_sub.compare(m_string); - ignore_unused_variable_warning(i); - - int i2 = m_sub.compare(m_sub); - ignore_unused_variable_warning(i2); - i2 = m_sub.compare(m_pointer); - ignore_unused_variable_warning(i2); - - bool b = m_sub == m_sub; - ignore_unused_variable_warning(b); - b = m_sub != m_sub; - ignore_unused_variable_warning(b); - b = m_sub <= m_sub; - ignore_unused_variable_warning(b); - b = m_sub <= m_sub; - ignore_unused_variable_warning(b); - b = m_sub > m_sub; - ignore_unused_variable_warning(b); - b = m_sub >= m_sub; - ignore_unused_variable_warning(b); - - b = m_sub == m_pointer; - ignore_unused_variable_warning(b); - b = m_sub != m_pointer; - ignore_unused_variable_warning(b); - b = m_sub <= m_pointer; - ignore_unused_variable_warning(b); - b = m_sub <= m_pointer; - ignore_unused_variable_warning(b); - b = m_sub > m_pointer; - ignore_unused_variable_warning(b); - b = m_sub >= m_pointer; - ignore_unused_variable_warning(b); - - b = m_pointer == m_sub; - ignore_unused_variable_warning(b); - b = m_pointer != m_sub; - ignore_unused_variable_warning(b); - b = m_pointer <= m_sub; - ignore_unused_variable_warning(b); - b = m_pointer <= m_sub; - ignore_unused_variable_warning(b); - b = m_pointer > m_sub; - ignore_unused_variable_warning(b); - b = m_pointer >= m_sub; - ignore_unused_variable_warning(b); - - b = m_sub == m_char; - ignore_unused_variable_warning(b); - b = m_sub != m_char; - ignore_unused_variable_warning(b); - b = m_sub <= m_char; - ignore_unused_variable_warning(b); - b = m_sub <= m_char; - ignore_unused_variable_warning(b); - b = m_sub > m_char; - ignore_unused_variable_warning(b); - b = m_sub >= m_char; - ignore_unused_variable_warning(b); - - b = m_char == m_sub; - ignore_unused_variable_warning(b); - b = m_char != m_sub; - ignore_unused_variable_warning(b); - b = m_char <= m_sub; - ignore_unused_variable_warning(b); - b = m_char <= m_sub; - ignore_unused_variable_warning(b); - b = m_char > m_sub; - ignore_unused_variable_warning(b); - b = m_char >= m_sub; - ignore_unused_variable_warning(b); - - b = m_sub == m_string; - ignore_unused_variable_warning(b); - b = m_sub != m_string; - ignore_unused_variable_warning(b); - b = m_sub <= m_string; - ignore_unused_variable_warning(b); - b = m_sub <= m_string; - ignore_unused_variable_warning(b); - b = m_sub > m_string; - ignore_unused_variable_warning(b); - b = m_sub >= m_string; - ignore_unused_variable_warning(b); - - b = m_string == m_sub; - ignore_unused_variable_warning(b); - b = m_string != m_sub; - ignore_unused_variable_warning(b); - b = m_string <= m_sub; - ignore_unused_variable_warning(b); - b = m_string <= m_sub; - ignore_unused_variable_warning(b); - b = m_string > m_sub; - ignore_unused_variable_warning(b); - b = m_string >= m_sub; - ignore_unused_variable_warning(b); - - // match results: - m_string = m_results.str(); - ignore_unused_variable_warning(m_string); - m_string = m_results.str(0); - ignore_unused_variable_warning(m_string); - m_out = m_cresults.format(m_out, m_string); - m_out = m_cresults.format(m_out, m_string, m_mft); - m_string = m_cresults.format(m_string); - ignore_unused_variable_warning(m_string); - m_string = m_cresults.format(m_string, m_mft); - ignore_unused_variable_warning(m_string); - - // regex_match: - b = global_regex_namespace::regex_match(m_string, m_smatch, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_match(m_string, m_smatch, e, m_mft); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_match(m_string, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_match(m_string, e, m_mft); - ignore_unused_variable_warning(b); - - // regex_search: - b = global_regex_namespace::regex_search(m_string, m_smatch, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_search(m_string, m_smatch, e, m_mft); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_search(m_string, e); - ignore_unused_variable_warning(b); - b = global_regex_namespace::regex_search(m_string, e, m_mft); - ignore_unused_variable_warning(b); - - // regex_replace: - m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string, m_mft); - m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string); - m_string = global_regex_namespace::regex_replace(m_string, e, m_string, m_mft); - ignore_unused_variable_warning(m_string); - m_string = global_regex_namespace::regex_replace(m_string, e, m_string); - ignore_unused_variable_warning(m_string); - - } - - flag_type m_flags; - string_type m_string; - const sub_match_type m_sub; - match_results_type m_results; - pointer_type m_pointer; - value_type m_char; - const match_results_type m_cresults; - OutIterator m_out; - BidiIterator m_in; - global_regex_namespace::regex_constants::match_flag_type m_mft; - global_regex_namespace::match_results<typename string_type::const_iterator, allocator_architype<global_regex_namespace::sub_match<typename string_type::const_iterator> > > m_smatch; - - RegexConcept(); - RegexConcept(const RegexConcept&); - RegexConcept& operator=(const RegexConcept&); -}; - -#ifndef BOOST_REGEX_TEST_STD - -template <class M> -struct functor1 -{ - typedef typename M::char_type char_type; - const char_type* operator()(const M&)const - { - static const char_type c = static_cast<char_type>(0); - return &c; - } -}; -template <class M> -struct functor1b -{ - typedef typename M::char_type char_type; - std::vector<char_type> operator()(const M&)const - { - static const std::vector<char_type> c; - return c; - } -}; -template <class M> -struct functor2 -{ - template <class O> - O operator()(const M& /*m*/, O i)const - { - return i; - } -}; -template <class M> -struct functor3 -{ - template <class O> - O operator()(const M& /*m*/, O i, regex_constants::match_flag_type)const - { - return i; - } -}; - -// -// BoostRegexConcept: -// Test every interface in the Boost implementation: -// -template <class Regex> -struct BoostRegexConcept -{ - typedef typename Regex::value_type value_type; - typedef typename Regex::size_type size_type; - typedef typename Regex::flag_type flag_type; - typedef typename Regex::locale_type locale_type; - - // derived test types: - typedef const value_type* pointer_type; - typedef std::basic_string<value_type> string_type; - typedef typename Regex::const_iterator const_iterator; - typedef bidirectional_iterator_archetype<value_type> BidiIterator; - typedef output_iterator_archetype<value_type> OutputIterator; - typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type; - typedef global_regex_namespace::match_results<BidiIterator, allocator_architype<sub_match_type> > match_results_type; - typedef global_regex_namespace::match_results<BidiIterator> match_results_default_type; - - void constraints() - { - global_regex_namespace::regex_constants::match_flag_type mopts - = global_regex_namespace::regex_constants::match_default - | global_regex_namespace::regex_constants::match_not_bol - | global_regex_namespace::regex_constants::match_not_eol - | global_regex_namespace::regex_constants::match_not_bow - | global_regex_namespace::regex_constants::match_not_eow - | global_regex_namespace::regex_constants::match_any - | global_regex_namespace::regex_constants::match_not_null - | global_regex_namespace::regex_constants::match_continuous - | global_regex_namespace::regex_constants::match_partial - | global_regex_namespace::regex_constants::match_prev_avail - | global_regex_namespace::regex_constants::format_default - | global_regex_namespace::regex_constants::format_sed - | global_regex_namespace::regex_constants::format_perl - | global_regex_namespace::regex_constants::format_no_copy - | global_regex_namespace::regex_constants::format_first_only; - - (void)mopts; - - function_requires<RegexConcept<Regex> >(); - const global_regex_namespace::regex_error except(global_regex_namespace::regex_constants::error_collate); - std::ptrdiff_t pt = except.position(); - ignore_unused_variable_warning(pt); - const Regex ce, ce2; -#ifndef BOOST_NO_STD_LOCALE - m_stream << ce; -#endif - unsigned i = ce.error_code(); - ignore_unused_variable_warning(i); - pointer_type p = ce.expression(); - ignore_unused_variable_warning(p); - int i2 = ce.compare(ce2); - ignore_unused_variable_warning(i2); - bool b = ce == ce2; - ignore_unused_variable_warning(b); - b = ce.empty(); - ignore_unused_variable_warning(b); - b = ce != ce2; - ignore_unused_variable_warning(b); - b = ce < ce2; - ignore_unused_variable_warning(b); - b = ce > ce2; - ignore_unused_variable_warning(b); - b = ce <= ce2; - ignore_unused_variable_warning(b); - b = ce >= ce2; - ignore_unused_variable_warning(b); - i = ce.status(); - ignore_unused_variable_warning(i); - size_type s = ce.max_size(); - ignore_unused_variable_warning(s); - s = ce.size(); - ignore_unused_variable_warning(s); - const_iterator pi = ce.begin(); - ignore_unused_variable_warning(pi); - pi = ce.end(); - ignore_unused_variable_warning(pi); - string_type s2 = ce.str(); - ignore_unused_variable_warning(s2); - - m_string = m_sub + m_sub; - ignore_unused_variable_warning(m_string); - m_string = m_sub + m_pointer; - ignore_unused_variable_warning(m_string); - m_string = m_pointer + m_sub; - ignore_unused_variable_warning(m_string); - m_string = m_sub + m_string; - ignore_unused_variable_warning(m_string); - m_string = m_string + m_sub; - ignore_unused_variable_warning(m_string); - m_string = m_sub + m_char; - ignore_unused_variable_warning(m_string); - m_string = m_char + m_sub; - ignore_unused_variable_warning(m_string); - - // Named sub-expressions: - m_sub = m_cresults[&m_char]; - ignore_unused_variable_warning(m_sub); - m_sub = m_cresults[m_string]; - ignore_unused_variable_warning(m_sub); - m_sub = m_cresults[""]; - ignore_unused_variable_warning(m_sub); - m_sub = m_cresults[std::string("")]; - ignore_unused_variable_warning(m_sub); - m_string = m_cresults.str(&m_char); - ignore_unused_variable_warning(m_string); - m_string = m_cresults.str(m_string); - ignore_unused_variable_warning(m_string); - m_string = m_cresults.str(""); - ignore_unused_variable_warning(m_string); - m_string = m_cresults.str(std::string("")); - ignore_unused_variable_warning(m_string); - - typename match_results_type::difference_type diff; - diff = m_cresults.length(&m_char); - ignore_unused_variable_warning(diff); - diff = m_cresults.length(m_string); - ignore_unused_variable_warning(diff); - diff = m_cresults.length(""); - ignore_unused_variable_warning(diff); - diff = m_cresults.length(std::string("")); - ignore_unused_variable_warning(diff); - diff = m_cresults.position(&m_char); - ignore_unused_variable_warning(diff); - diff = m_cresults.position(m_string); - ignore_unused_variable_warning(diff); - diff = m_cresults.position(""); - ignore_unused_variable_warning(diff); - diff = m_cresults.position(std::string("")); - ignore_unused_variable_warning(diff); - -#ifndef BOOST_NO_STD_LOCALE - m_stream << m_sub; - m_stream << m_cresults; -#endif - // - // Extended formatting with a functor: - // - regex_constants::match_flag_type f = regex_constants::match_default; - OutputIterator out = static_object<OutputIterator>::get(); - - functor3<match_results_default_type> func3; - functor2<match_results_default_type> func2; - functor1<match_results_default_type> func1; - - functor3<match_results_type> func3b; - functor2<match_results_type> func2b; - functor1<match_results_type> func1b; - - out = regex_format(out, m_cresults, func3b, f); - out = regex_format(out, m_cresults, func3b); - out = regex_format(out, m_cresults, func2b, f); - out = regex_format(out, m_cresults, func2b); - out = regex_format(out, m_cresults, func1b, f); - out = regex_format(out, m_cresults, func1b); - out = regex_format(out, m_cresults, RW_NS::ref(func3b), f); - out = regex_format(out, m_cresults, RW_NS::ref(func3b)); - out = regex_format(out, m_cresults, RW_NS::ref(func2b), f); - out = regex_format(out, m_cresults, RW_NS::ref(func2b)); - out = regex_format(out, m_cresults, RW_NS::ref(func1b), f); - out = regex_format(out, m_cresults, RW_NS::ref(func1b)); - out = regex_format(out, m_cresults, RW_NS::cref(func3b), f); - out = regex_format(out, m_cresults, RW_NS::cref(func3b)); - out = regex_format(out, m_cresults, RW_NS::cref(func2b), f); - out = regex_format(out, m_cresults, RW_NS::cref(func2b)); - out = regex_format(out, m_cresults, RW_NS::cref(func1b), f); - out = regex_format(out, m_cresults, RW_NS::cref(func1b)); - m_string += regex_format(m_cresults, func3b, f); - m_string += regex_format(m_cresults, func3b); - m_string += regex_format(m_cresults, func2b, f); - m_string += regex_format(m_cresults, func2b); - m_string += regex_format(m_cresults, func1b, f); - m_string += regex_format(m_cresults, func1b); - m_string += regex_format(m_cresults, RW_NS::ref(func3b), f); - m_string += regex_format(m_cresults, RW_NS::ref(func3b)); - m_string += regex_format(m_cresults, RW_NS::ref(func2b), f); - m_string += regex_format(m_cresults, RW_NS::ref(func2b)); - m_string += regex_format(m_cresults, RW_NS::ref(func1b), f); - m_string += regex_format(m_cresults, RW_NS::ref(func1b)); - m_string += regex_format(m_cresults, RW_NS::cref(func3b), f); - m_string += regex_format(m_cresults, RW_NS::cref(func3b)); - m_string += regex_format(m_cresults, RW_NS::cref(func2b), f); - m_string += regex_format(m_cresults, RW_NS::cref(func2b)); - m_string += regex_format(m_cresults, RW_NS::cref(func1b), f); - m_string += regex_format(m_cresults, RW_NS::cref(func1b)); - - out = m_cresults.format(out, func3b, f); - out = m_cresults.format(out, func3b); - out = m_cresults.format(out, func2b, f); - out = m_cresults.format(out, func2b); - out = m_cresults.format(out, func1b, f); - out = m_cresults.format(out, func1b); - out = m_cresults.format(out, RW_NS::ref(func3b), f); - out = m_cresults.format(out, RW_NS::ref(func3b)); - out = m_cresults.format(out, RW_NS::ref(func2b), f); - out = m_cresults.format(out, RW_NS::ref(func2b)); - out = m_cresults.format(out, RW_NS::ref(func1b), f); - out = m_cresults.format(out, RW_NS::ref(func1b)); - out = m_cresults.format(out, RW_NS::cref(func3b), f); - out = m_cresults.format(out, RW_NS::cref(func3b)); - out = m_cresults.format(out, RW_NS::cref(func2b), f); - out = m_cresults.format(out, RW_NS::cref(func2b)); - out = m_cresults.format(out, RW_NS::cref(func1b), f); - out = m_cresults.format(out, RW_NS::cref(func1b)); - - m_string += m_cresults.format(func3b, f); - m_string += m_cresults.format(func3b); - m_string += m_cresults.format(func2b, f); - m_string += m_cresults.format(func2b); - m_string += m_cresults.format(func1b, f); - m_string += m_cresults.format(func1b); - m_string += m_cresults.format(RW_NS::ref(func3b), f); - m_string += m_cresults.format(RW_NS::ref(func3b)); - m_string += m_cresults.format(RW_NS::ref(func2b), f); - m_string += m_cresults.format(RW_NS::ref(func2b)); - m_string += m_cresults.format(RW_NS::ref(func1b), f); - m_string += m_cresults.format(RW_NS::ref(func1b)); - m_string += m_cresults.format(RW_NS::cref(func3b), f); - m_string += m_cresults.format(RW_NS::cref(func3b)); - m_string += m_cresults.format(RW_NS::cref(func2b), f); - m_string += m_cresults.format(RW_NS::cref(func2b)); - m_string += m_cresults.format(RW_NS::cref(func1b), f); - m_string += m_cresults.format(RW_NS::cref(func1b)); - - out = regex_replace(out, m_in, m_in, ce, func3, f); - out = regex_replace(out, m_in, m_in, ce, func3); - out = regex_replace(out, m_in, m_in, ce, func2, f); - out = regex_replace(out, m_in, m_in, ce, func2); - out = regex_replace(out, m_in, m_in, ce, func1, f); - out = regex_replace(out, m_in, m_in, ce, func1); - out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func3), f); - out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func3)); - out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func2), f); - out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func2)); - out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func1), f); - out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func1)); - out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func3), f); - out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func3)); - out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func2), f); - out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func2)); - out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func1), f); - out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func1)); - - functor3<match_results<typename string_type::const_iterator> > func3s; - functor2<match_results<typename string_type::const_iterator> > func2s; - functor1<match_results<typename string_type::const_iterator> > func1s; - m_string += regex_replace(m_string, ce, func3s, f); - m_string += regex_replace(m_string, ce, func3s); - m_string += regex_replace(m_string, ce, func2s, f); - m_string += regex_replace(m_string, ce, func2s); - m_string += regex_replace(m_string, ce, func1s, f); - m_string += regex_replace(m_string, ce, func1s); - m_string += regex_replace(m_string, ce, RW_NS::ref(func3s), f); - m_string += regex_replace(m_string, ce, RW_NS::ref(func3s)); - m_string += regex_replace(m_string, ce, RW_NS::ref(func2s), f); - m_string += regex_replace(m_string, ce, RW_NS::ref(func2s)); - m_string += regex_replace(m_string, ce, RW_NS::ref(func1s), f); - m_string += regex_replace(m_string, ce, RW_NS::ref(func1s)); - m_string += regex_replace(m_string, ce, RW_NS::cref(func3s), f); - m_string += regex_replace(m_string, ce, RW_NS::cref(func3s)); - m_string += regex_replace(m_string, ce, RW_NS::cref(func2s), f); - m_string += regex_replace(m_string, ce, RW_NS::cref(func2s)); - m_string += regex_replace(m_string, ce, RW_NS::cref(func1s), f); - m_string += regex_replace(m_string, ce, RW_NS::cref(func1s)); - } - - std::basic_ostream<value_type> m_stream; - sub_match_type m_sub; - pointer_type m_pointer; - string_type m_string; - const value_type m_char; - match_results_type m_results; - const match_results_type m_cresults; - BidiIterator m_in; - - BoostRegexConcept(); - BoostRegexConcept(const BoostRegexConcept&); - BoostRegexConcept& operator=(const BoostRegexConcept&); -}; - -#endif // BOOST_REGEX_TEST_STD - -} - -#endif diff --git a/contrib/restricted/boost/regex/include/boost/regex/icu.hpp b/contrib/restricted/boost/regex/include/boost/regex/icu.hpp deleted file mode 100644 index b312612d19..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/icu.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Copyright (c) 2020 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE icu.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Unicode regular expressions on top of the ICU Library. - */ - -#ifndef BOOST_REGEX_ICU_HPP -#define BOOST_REGEX_ICU_HPP - -#include <boost/regex/config.hpp> - -#ifdef BOOST_REGEX_CXX03 -#include <boost/regex/v4/icu.hpp> -#else -#include <boost/regex/v5/icu.hpp> -#endif - -#endif diff --git a/contrib/restricted/boost/regex/include/boost/regex/mfc.hpp b/contrib/restricted/boost/regex/include/boost/regex/mfc.hpp deleted file mode 100644 index d780673931..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/mfc.hpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - * - * Copyright (c) 2004 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE mfc.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Overloads and helpers for using MFC/ATL string types with Boost.Regex. - */ - -#ifndef BOOST_REGEX_MFC_HPP -#define BOOST_REGEX_MFC_HPP - -#include <atlsimpstr.h> -#include <boost/regex.hpp> - -namespace boost{ - -// -// define the types used for TCHAR's: -typedef basic_regex<TCHAR> tregex; -typedef match_results<TCHAR const*> tmatch; -typedef regex_iterator<TCHAR const*> tregex_iterator; -typedef regex_token_iterator<TCHAR const*> tregex_token_iterator; - -// Obsolete. Remove -#define SIMPLE_STRING_PARAM class B, bool b -#define SIMPLE_STRING_ARG_LIST B, b - -// -// define regex creation functions: -// -template <class B, bool b> -inline basic_regex<B> -make_regex(const ATL::CSimpleStringT<B, b>& s, ::boost::regex_constants::syntax_option_type f = boost::regex_constants::normal) -{ - basic_regex<B> result(s.GetString(), s.GetString() + s.GetLength(), f); - return result; -} -// -// regex_match overloads: -// -template <class B, bool b, class A, class T> -inline bool regex_match(const ATL::CSimpleStringT<B, b>& s, - match_results<const B*, A>& what, - const basic_regex<B, T>& e, - boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) -{ - return ::boost::regex_match(s.GetString(), - s.GetString() + s.GetLength(), - what, - e, - f); -} - -template <class B, bool b, class T> -inline bool regex_match(const ATL::CSimpleStringT<B, b>& s, - const basic_regex<B, T>& e, - boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) -{ - return ::boost::regex_match(s.GetString(), - s.GetString() + s.GetLength(), - e, - f); -} -// -// regex_search overloads: -// -template <class B, bool b, class A, class T> -inline bool regex_search(const ATL::CSimpleStringT<B, b>& s, - match_results<const B*, A>& what, - const basic_regex<B, T>& e, - boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) -{ - return ::boost::regex_search(s.GetString(), - s.GetString() + s.GetLength(), - what, - e, - f); -} - -template <class B, bool b, class T> -inline bool regex_search(const ATL::CSimpleStringT<B, b>& s, - const basic_regex<B, T>& e, - boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) -{ - return ::boost::regex_search(s.GetString(), - s.GetString() + s.GetLength(), - e, - f); -} -// -// regex_iterator creation: -// -template <class B, bool b> -inline regex_iterator<B const*> -make_regex_iterator(const ATL::CSimpleStringT<B, b>& s, const basic_regex<B>& e, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) -{ - regex_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, f); - return result; -} - -template <class B, bool b> -inline regex_token_iterator<B const*> - make_regex_token_iterator(const ATL::CSimpleStringT<B, b>& s, const basic_regex<B>& e, int sub = 0, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) -{ - regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, sub, f); - return result; -} - -template <class B, bool b> -inline regex_token_iterator<B const*> -make_regex_token_iterator(const ATL::CSimpleStringT<B, b>& s, const basic_regex<B>& e, const std::vector<int>& subs, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) -{ - regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f); - return result; -} - -template <class B, bool b, std::size_t N> -inline regex_token_iterator<B const*> -make_regex_token_iterator(const ATL::CSimpleStringT<B, b>& s, const basic_regex<B>& e, const int (& subs)[N], ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) -{ - regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f); - return result; -} - -template <class OutputIterator, class BidirectionalIterator, class traits, - class B, bool b> -OutputIterator regex_replace(OutputIterator out, - BidirectionalIterator first, - BidirectionalIterator last, - const basic_regex<B, traits>& e, - const ATL::CSimpleStringT<B, b>& fmt, - match_flag_type flags = match_default) -{ - return ::boost::regex_replace(out, first, last, e, fmt.GetString(), flags); -} - -namespace BOOST_REGEX_DETAIL_NS{ - -template <class B, bool b> -class mfc_string_out_iterator -{ - ATL::CSimpleStringT<B, b>* out; -public: - mfc_string_out_iterator(ATL::CSimpleStringT<B, b>& s) : out(&s) {} - mfc_string_out_iterator& operator++() { return *this; } - mfc_string_out_iterator& operator++(int) { return *this; } - mfc_string_out_iterator& operator*() { return *this; } - mfc_string_out_iterator& operator=(B v) - { - out->AppendChar(v); - return *this; - } - typedef std::ptrdiff_t difference_type; - typedef B value_type; - typedef value_type* pointer; - typedef value_type& reference; - typedef std::output_iterator_tag iterator_category; -}; - -} - -template <class traits, class B, bool b> -ATL::CSimpleStringT<B, b> regex_replace(const ATL::CSimpleStringT<B, b>& s, - const basic_regex<B, traits>& e, - const ATL::CSimpleStringT<B, b>& fmt, - match_flag_type flags = match_default) -{ - ATL::CSimpleStringT<B, b> result(s.GetManager()); - BOOST_REGEX_DETAIL_NS::mfc_string_out_iterator<B, b> i(result); - regex_replace(i, s.GetString(), s.GetString() + s.GetLength(), e, fmt.GetString(), flags); - return result; -} - -} // namespace boost. - -#endif diff --git a/contrib/restricted/boost/regex/include/boost/regex/pending/object_cache.hpp b/contrib/restricted/boost/regex/include/boost/regex/pending/object_cache.hpp deleted file mode 100644 index 0ddbdadfa3..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/pending/object_cache.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * Copyright (c) 2004 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE object_cache.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Implements a generic object cache. - */ - -#ifndef BOOST_REGEX_OBJECT_CACHE_HPP -#define BOOST_REGEX_OBJECT_CACHE_HPP - -#include <boost/regex/config.hpp> -#ifdef BOOST_REGEX_CXX03 -#include <boost/regex/v4/object_cache.hpp> -#else -#include <boost/regex/v5/object_cache.hpp> -#endif - -#endif diff --git a/contrib/restricted/boost/regex/include/boost/regex/pending/unicode_iterator.hpp b/contrib/restricted/boost/regex/include/boost/regex/pending/unicode_iterator.hpp deleted file mode 100644 index a565570a22..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/pending/unicode_iterator.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Copyright (c) 2020 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE unicode_iterator.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Iterator adapters for converting between different Unicode encodings. - */ - -#ifndef BOOST_REGEX_PENDING_UNICODE_ITERATOR_HPP -#define BOOST_REGEX_PENDING_UNICODE_ITERATOR_HPP - -#include <boost/regex/config.hpp> - -#if defined(BOOST_REGEX_CXX03) -#include <boost/regex/v4/unicode_iterator.hpp> -#else -#include <boost/regex/v5/unicode_iterator.hpp> -#endif - - -#endif // BOOST_REGEX_PENDING_UNICODE_ITERATOR_HPP - diff --git a/contrib/restricted/boost/regex/include/boost/regex/v4/icu.hpp b/contrib/restricted/boost/regex/include/boost/regex/v4/icu.hpp deleted file mode 100644 index 7e70f57e5a..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/v4/icu.hpp +++ /dev/null @@ -1,1516 +0,0 @@ -/* - * - * Copyright (c) 2004 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE icu.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Unicode regular expressions on top of the ICU Library. - */ - -#ifndef BOOST_REGEX_ICU_V4_HPP -#define BOOST_REGEX_ICU_V4_HPP - -#include <boost/config.hpp> -#include <unicode/utypes.h> -#include <unicode/uchar.h> -#include <unicode/coll.h> -#include <boost/regex.hpp> -#include <boost/regex/v4/unicode_iterator.hpp> -#include <boost/mpl/int_fwd.hpp> -#include <boost/static_assert.hpp> -#include <bitset> - -#ifdef BOOST_MSVC -#pragma warning (push) -#pragma warning (disable: 4251) -#endif - -namespace boost { - - namespace BOOST_REGEX_DETAIL_NS { - - // - // Implementation details: - // - class icu_regex_traits_implementation - { - typedef UChar32 char_type; - typedef std::size_t size_type; - typedef std::vector<char_type> string_type; - typedef U_NAMESPACE_QUALIFIER Locale locale_type; - typedef boost::uint_least32_t char_class_type; - public: - icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& l) - : m_locale(l) - { - UErrorCode success = U_ZERO_ERROR; - m_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success)); - if (U_SUCCESS(success) == 0) - init_error(); - m_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::IDENTICAL); - success = U_ZERO_ERROR; - m_primary_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success)); - if (U_SUCCESS(success) == 0) - init_error(); - m_primary_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::PRIMARY); - } - U_NAMESPACE_QUALIFIER Locale getloc()const - { - return m_locale; - } - string_type do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const - { - // TODO make thread safe!!!! : - typedef u32_to_u16_iterator<const char_type*, ::UChar> itt; - itt i(p1), j(p2); -#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS - std::vector< ::UChar> t(i, j); -#else - std::vector< ::UChar> t; - while (i != j) - t.push_back(*i++); -#endif - ::uint8_t result[100]; - ::int32_t len; - if (!t.empty()) - len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), result, sizeof(result)); - else - len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast< ::int32_t>(0), result, sizeof(result)); - if (std::size_t(len) > sizeof(result)) - { - scoped_array< ::uint8_t> presult(new ::uint8_t[len + 1]); - if (!t.empty()) - len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), presult.get(), len + 1); - else - len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast< ::int32_t>(0), presult.get(), len + 1); - if ((0 == presult[len - 1]) && (len > 1)) - --len; -#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS - return string_type(presult.get(), presult.get() + len); -#else - string_type sresult; - ::uint8_t const* ia = presult.get(); - ::uint8_t const* ib = presult.get() + len; - while (ia != ib) - sresult.push_back(*ia++); - return sresult; -#endif - } - if ((0 == result[len - 1]) && (len > 1)) - --len; -#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS - return string_type(result, result + len); -#else - string_type sresult; - ::uint8_t const* ia = result; - ::uint8_t const* ib = result + len; - while (ia != ib) - sresult.push_back(*ia++); - return sresult; -#endif - } - string_type transform(const char_type* p1, const char_type* p2) const - { - return do_transform(p1, p2, m_collator.get()); - } - string_type transform_primary(const char_type* p1, const char_type* p2) const - { - return do_transform(p1, p2, m_primary_collator.get()); - } - private: - void init_error() - { - std::runtime_error e("Could not initialize ICU resources"); - boost::throw_exception(e); - } - U_NAMESPACE_QUALIFIER Locale m_locale; // The ICU locale that we're using - boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_collator; // The full collation object - boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_primary_collator; // The primary collation object - }; - - inline boost::shared_ptr<icu_regex_traits_implementation> get_icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& loc) - { - return boost::shared_ptr<icu_regex_traits_implementation>(new icu_regex_traits_implementation(loc)); - } - - } - - class icu_regex_traits - { - public: - typedef UChar32 char_type; - typedef std::size_t size_type; - typedef std::vector<char_type> string_type; - typedef U_NAMESPACE_QUALIFIER Locale locale_type; -#ifdef BOOST_NO_INT64_T - typedef std::bitset<64> char_class_type; -#else - typedef boost::uint64_t char_class_type; -#endif - - struct boost_extensions_tag {}; - - icu_regex_traits() - : m_pimpl(BOOST_REGEX_DETAIL_NS::get_icu_regex_traits_implementation(U_NAMESPACE_QUALIFIER Locale())) - { - } - static size_type length(const char_type* p) - { - size_type result = 0; - while (*p) - { - ++p; - ++result; - } - return result; - } - ::boost::regex_constants::syntax_type syntax_type(char_type c)const - { - return ((c < 0x7f) && (c > 0)) ? BOOST_REGEX_DETAIL_NS::get_default_syntax_type(static_cast<char>(c)) : regex_constants::syntax_char; - } - ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c) const - { - return ((c < 0x7f) && (c > 0)) ? BOOST_REGEX_DETAIL_NS::get_default_escape_syntax_type(static_cast<char>(c)) : regex_constants::syntax_char; - } - char_type translate(char_type c) const - { - return c; - } - char_type translate_nocase(char_type c) const - { - return ::u_foldCase(c, U_FOLD_CASE_DEFAULT); - } - char_type translate(char_type c, bool icase) const - { - return icase ? translate_nocase(c) : translate(c); - } - char_type tolower(char_type c) const - { - return ::u_tolower(c); - } - char_type toupper(char_type c) const - { - return ::u_toupper(c); - } - string_type transform(const char_type* p1, const char_type* p2) const - { - return m_pimpl->transform(p1, p2); - } - string_type transform_primary(const char_type* p1, const char_type* p2) const - { - return m_pimpl->transform_primary(p1, p2); - } - char_class_type lookup_classname(const char_type* p1, const char_type* p2) const - { - static const char_class_type mask_blank = char_class_type(1) << offset_blank; - static const char_class_type mask_space = char_class_type(1) << offset_space; - static const char_class_type mask_xdigit = char_class_type(1) << offset_xdigit; - static const char_class_type mask_underscore = char_class_type(1) << offset_underscore; - static const char_class_type mask_unicode = char_class_type(1) << offset_unicode; - static const char_class_type mask_any = char_class_type(1) << offset_any; - static const char_class_type mask_ascii = char_class_type(1) << offset_ascii; - static const char_class_type mask_horizontal = char_class_type(1) << offset_horizontal; - static const char_class_type mask_vertical = char_class_type(1) << offset_vertical; - - static const char_class_type masks[] = - { - 0, - U_GC_L_MASK | U_GC_ND_MASK, - U_GC_L_MASK, - mask_blank, - U_GC_CC_MASK | U_GC_CF_MASK | U_GC_ZL_MASK | U_GC_ZP_MASK, - U_GC_ND_MASK, - U_GC_ND_MASK, - (0x3FFFFFFFu) & ~(U_GC_CC_MASK | U_GC_CF_MASK | U_GC_CS_MASK | U_GC_CN_MASK | U_GC_Z_MASK), - mask_horizontal, - U_GC_LL_MASK, - U_GC_LL_MASK, - ~(U_GC_C_MASK), - U_GC_P_MASK, - char_class_type(U_GC_Z_MASK) | mask_space, - char_class_type(U_GC_Z_MASK) | mask_space, - U_GC_LU_MASK, - mask_unicode, - U_GC_LU_MASK, - mask_vertical, - char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore, - char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore, - char_class_type(U_GC_ND_MASK) | mask_xdigit, - }; - - int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2); - if (idx >= 0) - return masks[idx + 1]; - char_class_type result = lookup_icu_mask(p1, p2); - if (result != 0) - return result; - - if (idx < 0) - { - string_type s(p1, p2); - string_type::size_type i = 0; - while (i < s.size()) - { - s[i] = static_cast<char>((::u_tolower)(s[i])); - if (::u_isspace(s[i]) || (s[i] == '-') || (s[i] == '_')) - s.erase(s.begin() + i, s.begin() + i + 1); - else - { - s[i] = static_cast<char>((::u_tolower)(s[i])); - ++i; - } - } - if (!s.empty()) - idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); - if (idx >= 0) - return masks[idx + 1]; - if (!s.empty()) - result = lookup_icu_mask(&*s.begin(), &*s.begin() + s.size()); - if (result != 0) - return result; - } - BOOST_ASSERT(std::size_t(idx + 1) < sizeof(masks) / sizeof(masks[0])); - return masks[idx + 1]; - } - string_type lookup_collatename(const char_type* p1, const char_type* p2) const - { - string_type result; -#ifdef BOOST_NO_CXX98_BINDERS - if (std::find_if(p1, p2, std::bind(std::greater< ::UChar32>(), std::placeholders::_1, 0x7f)) == p2) -#else - if (std::find_if(p1, p2, std::bind2nd(std::greater< ::UChar32>(), 0x7f)) == p2) -#endif - { -#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS - std::string s(p1, p2); -#else - std::string s; - const char_type* p3 = p1; - while (p3 != p2) - s.append(1, *p3++); -#endif - // Try Unicode name: - UErrorCode err = U_ZERO_ERROR; - UChar32 c = ::u_charFromName(U_UNICODE_CHAR_NAME, s.c_str(), &err); - if (U_SUCCESS(err)) - { - result.push_back(c); - return result; - } - // Try Unicode-extended name: - err = U_ZERO_ERROR; - c = ::u_charFromName(U_EXTENDED_CHAR_NAME, s.c_str(), &err); - if (U_SUCCESS(err)) - { - result.push_back(c); - return result; - } - // try POSIX name: - s = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(s); -#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS - result.assign(s.begin(), s.end()); -#else - result.clear(); - std::string::const_iterator si, sj; - si = s.begin(); - sj = s.end(); - while (si != sj) - result.push_back(*si++); -#endif - } - if (result.empty() && (p2 - p1 == 1)) - result.push_back(*p1); - return result; - } - bool isctype(char_type c, char_class_type f) const - { - static const char_class_type mask_blank = char_class_type(1) << offset_blank; - static const char_class_type mask_space = char_class_type(1) << offset_space; - static const char_class_type mask_xdigit = char_class_type(1) << offset_xdigit; - static const char_class_type mask_underscore = char_class_type(1) << offset_underscore; - static const char_class_type mask_unicode = char_class_type(1) << offset_unicode; - static const char_class_type mask_any = char_class_type(1) << offset_any; - static const char_class_type mask_ascii = char_class_type(1) << offset_ascii; - static const char_class_type mask_horizontal = char_class_type(1) << offset_horizontal; - static const char_class_type mask_vertical = char_class_type(1) << offset_vertical; - - // check for standard catagories first: - char_class_type m = char_class_type(static_cast<char_class_type>(1) << u_charType(c)); - if ((m & f) != 0) - return true; - // now check for special cases: - if (((f & mask_blank) != 0) && u_isblank(c)) - return true; - if (((f & mask_space) != 0) && u_isspace(c)) - return true; - if (((f & mask_xdigit) != 0) && (u_digit(c, 16) >= 0)) - return true; - if (((f & mask_unicode) != 0) && (c >= 0x100)) - return true; - if (((f & mask_underscore) != 0) && (c == '_')) - return true; - if (((f & mask_any) != 0) && (c <= 0x10FFFF)) - return true; - if (((f & mask_ascii) != 0) && (c <= 0x7F)) - return true; - if (((f & mask_vertical) != 0) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == static_cast<char_type>('\v')) || (m == U_GC_ZL_MASK) || (m == U_GC_ZP_MASK))) - return true; - if (((f & mask_horizontal) != 0) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && u_isspace(c) && (c != static_cast<char_type>('\v'))) - return true; - return false; - } - boost::intmax_t toi(const char_type*& p1, const char_type* p2, int radix)const - { - return BOOST_REGEX_DETAIL_NS::global_toi(p1, p2, radix, *this); - } - int value(char_type c, int radix)const - { - return u_digit(c, static_cast< ::int8_t>(radix)); - } - locale_type imbue(locale_type l) - { - locale_type result(m_pimpl->getloc()); - m_pimpl = BOOST_REGEX_DETAIL_NS::get_icu_regex_traits_implementation(l); - return result; - } - locale_type getloc()const - { - return locale_type(); - } - std::string error_string(::boost::regex_constants::error_type n) const - { - return BOOST_REGEX_DETAIL_NS::get_default_error_string(n); - } - private: - icu_regex_traits(const icu_regex_traits&); - icu_regex_traits& operator=(const icu_regex_traits&); - - // - // define the bitmasks offsets we need for additional character properties: - // - enum { - offset_blank = U_CHAR_CATEGORY_COUNT, - offset_space = U_CHAR_CATEGORY_COUNT + 1, - offset_xdigit = U_CHAR_CATEGORY_COUNT + 2, - offset_underscore = U_CHAR_CATEGORY_COUNT + 3, - offset_unicode = U_CHAR_CATEGORY_COUNT + 4, - offset_any = U_CHAR_CATEGORY_COUNT + 5, - offset_ascii = U_CHAR_CATEGORY_COUNT + 6, - offset_horizontal = U_CHAR_CATEGORY_COUNT + 7, - offset_vertical = U_CHAR_CATEGORY_COUNT + 8 - }; - - static char_class_type lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2) - { - static const char_class_type mask_blank = char_class_type(1) << offset_blank; - static const char_class_type mask_space = char_class_type(1) << offset_space; - static const char_class_type mask_xdigit = char_class_type(1) << offset_xdigit; - static const char_class_type mask_underscore = char_class_type(1) << offset_underscore; - static const char_class_type mask_unicode = char_class_type(1) << offset_unicode; - static const char_class_type mask_any = char_class_type(1) << offset_any; - static const char_class_type mask_ascii = char_class_type(1) << offset_ascii; - static const char_class_type mask_horizontal = char_class_type(1) << offset_horizontal; - static const char_class_type mask_vertical = char_class_type(1) << offset_vertical; - - static const ::UChar32 prop_name_table[] = { - /* any */ 'a', 'n', 'y', - /* ascii */ 'a', 's', 'c', 'i', 'i', - /* assigned */ 'a', 's', 's', 'i', 'g', 'n', 'e', 'd', - /* c* */ 'c', '*', - /* cc */ 'c', 'c', - /* cf */ 'c', 'f', - /* closepunctuation */ 'c', 'l', 'o', 's', 'e', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* cn */ 'c', 'n', - /* co */ 'c', 'o', - /* connectorpunctuation */ 'c', 'o', 'n', 'n', 'e', 'c', 't', 'o', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* control */ 'c', 'o', 'n', 't', 'r', 'o', 'l', - /* cs */ 'c', 's', - /* currencysymbol */ 'c', 'u', 'r', 'r', 'e', 'n', 'c', 'y', 's', 'y', 'm', 'b', 'o', 'l', - /* dashpunctuation */ 'd', 'a', 's', 'h', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* decimaldigitnumber */ 'd', 'e', 'c', 'i', 'm', 'a', 'l', 'd', 'i', 'g', 'i', 't', 'n', 'u', 'm', 'b', 'e', 'r', - /* enclosingmark */ 'e', 'n', 'c', 'l', 'o', 's', 'i', 'n', 'g', 'm', 'a', 'r', 'k', - /* finalpunctuation */ 'f', 'i', 'n', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* format */ 'f', 'o', 'r', 'm', 'a', 't', - /* initialpunctuation */ 'i', 'n', 'i', 't', 'i', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* l* */ 'l', '*', - /* letter */ 'l', 'e', 't', 't', 'e', 'r', - /* letternumber */ 'l', 'e', 't', 't', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r', - /* lineseparator */ 'l', 'i', 'n', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', - /* ll */ 'l', 'l', - /* lm */ 'l', 'm', - /* lo */ 'l', 'o', - /* lowercaseletter */ 'l', 'o', 'w', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', - /* lt */ 'l', 't', - /* lu */ 'l', 'u', - /* m* */ 'm', '*', - /* mark */ 'm', 'a', 'r', 'k', - /* mathsymbol */ 'm', 'a', 't', 'h', 's', 'y', 'm', 'b', 'o', 'l', - /* mc */ 'm', 'c', - /* me */ 'm', 'e', - /* mn */ 'm', 'n', - /* modifierletter */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r', - /* modifiersymbol */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l', - /* n* */ 'n', '*', - /* nd */ 'n', 'd', - /* nl */ 'n', 'l', - /* no */ 'n', 'o', - /* nonspacingmark */ 'n', 'o', 'n', 's', 'p', 'a', 'c', 'i', 'n', 'g', 'm', 'a', 'r', 'k', - /* notassigned */ 'n', 'o', 't', 'a', 's', 's', 'i', 'g', 'n', 'e', 'd', - /* number */ 'n', 'u', 'm', 'b', 'e', 'r', - /* openpunctuation */ 'o', 'p', 'e', 'n', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* other */ 'o', 't', 'h', 'e', 'r', - /* otherletter */ 'o', 't', 'h', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r', - /* othernumber */ 'o', 't', 'h', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r', - /* otherpunctuation */ 'o', 't', 'h', 'e', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* othersymbol */ 'o', 't', 'h', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l', - /* p* */ 'p', '*', - /* paragraphseparator */ 'p', 'a', 'r', 'a', 'g', 'r', 'a', 'p', 'h', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', - /* pc */ 'p', 'c', - /* pd */ 'p', 'd', - /* pe */ 'p', 'e', - /* pf */ 'p', 'f', - /* pi */ 'p', 'i', - /* po */ 'p', 'o', - /* privateuse */ 'p', 'r', 'i', 'v', 'a', 't', 'e', 'u', 's', 'e', - /* ps */ 'p', 's', - /* punctuation */ 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* s* */ 's', '*', - /* sc */ 's', 'c', - /* separator */ 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', - /* sk */ 's', 'k', - /* sm */ 's', 'm', - /* so */ 's', 'o', - /* spaceseparator */ 's', 'p', 'a', 'c', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', - /* spacingcombiningmark */ 's', 'p', 'a', 'c', 'i', 'n', 'g', 'c', 'o', 'm', 'b', 'i', 'n', 'i', 'n', 'g', 'm', 'a', 'r', 'k', - /* surrogate */ 's', 'u', 'r', 'r', 'o', 'g', 'a', 't', 'e', - /* symbol */ 's', 'y', 'm', 'b', 'o', 'l', - /* titlecase */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e', - /* titlecaseletter */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', - /* uppercaseletter */ 'u', 'p', 'p', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', - /* z* */ 'z', '*', - /* zl */ 'z', 'l', - /* zp */ 'z', 'p', - /* zs */ 'z', 's', - }; - - static const BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32> range_data[] = { - { prop_name_table + 0, prop_name_table + 3, }, // any - { prop_name_table + 3, prop_name_table + 8, }, // ascii - { prop_name_table + 8, prop_name_table + 16, }, // assigned - { prop_name_table + 16, prop_name_table + 18, }, // c* - { prop_name_table + 18, prop_name_table + 20, }, // cc - { prop_name_table + 20, prop_name_table + 22, }, // cf - { prop_name_table + 22, prop_name_table + 38, }, // closepunctuation - { prop_name_table + 38, prop_name_table + 40, }, // cn - { prop_name_table + 40, prop_name_table + 42, }, // co - { prop_name_table + 42, prop_name_table + 62, }, // connectorpunctuation - { prop_name_table + 62, prop_name_table + 69, }, // control - { prop_name_table + 69, prop_name_table + 71, }, // cs - { prop_name_table + 71, prop_name_table + 85, }, // currencysymbol - { prop_name_table + 85, prop_name_table + 100, }, // dashpunctuation - { prop_name_table + 100, prop_name_table + 118, }, // decimaldigitnumber - { prop_name_table + 118, prop_name_table + 131, }, // enclosingmark - { prop_name_table + 131, prop_name_table + 147, }, // finalpunctuation - { prop_name_table + 147, prop_name_table + 153, }, // format - { prop_name_table + 153, prop_name_table + 171, }, // initialpunctuation - { prop_name_table + 171, prop_name_table + 173, }, // l* - { prop_name_table + 173, prop_name_table + 179, }, // letter - { prop_name_table + 179, prop_name_table + 191, }, // letternumber - { prop_name_table + 191, prop_name_table + 204, }, // lineseparator - { prop_name_table + 204, prop_name_table + 206, }, // ll - { prop_name_table + 206, prop_name_table + 208, }, // lm - { prop_name_table + 208, prop_name_table + 210, }, // lo - { prop_name_table + 210, prop_name_table + 225, }, // lowercaseletter - { prop_name_table + 225, prop_name_table + 227, }, // lt - { prop_name_table + 227, prop_name_table + 229, }, // lu - { prop_name_table + 229, prop_name_table + 231, }, // m* - { prop_name_table + 231, prop_name_table + 235, }, // mark - { prop_name_table + 235, prop_name_table + 245, }, // mathsymbol - { prop_name_table + 245, prop_name_table + 247, }, // mc - { prop_name_table + 247, prop_name_table + 249, }, // me - { prop_name_table + 249, prop_name_table + 251, }, // mn - { prop_name_table + 251, prop_name_table + 265, }, // modifierletter - { prop_name_table + 265, prop_name_table + 279, }, // modifiersymbol - { prop_name_table + 279, prop_name_table + 281, }, // n* - { prop_name_table + 281, prop_name_table + 283, }, // nd - { prop_name_table + 283, prop_name_table + 285, }, // nl - { prop_name_table + 285, prop_name_table + 287, }, // no - { prop_name_table + 287, prop_name_table + 301, }, // nonspacingmark - { prop_name_table + 301, prop_name_table + 312, }, // notassigned - { prop_name_table + 312, prop_name_table + 318, }, // number - { prop_name_table + 318, prop_name_table + 333, }, // openpunctuation - { prop_name_table + 333, prop_name_table + 338, }, // other - { prop_name_table + 338, prop_name_table + 349, }, // otherletter - { prop_name_table + 349, prop_name_table + 360, }, // othernumber - { prop_name_table + 360, prop_name_table + 376, }, // otherpunctuation - { prop_name_table + 376, prop_name_table + 387, }, // othersymbol - { prop_name_table + 387, prop_name_table + 389, }, // p* - { prop_name_table + 389, prop_name_table + 407, }, // paragraphseparator - { prop_name_table + 407, prop_name_table + 409, }, // pc - { prop_name_table + 409, prop_name_table + 411, }, // pd - { prop_name_table + 411, prop_name_table + 413, }, // pe - { prop_name_table + 413, prop_name_table + 415, }, // pf - { prop_name_table + 415, prop_name_table + 417, }, // pi - { prop_name_table + 417, prop_name_table + 419, }, // po - { prop_name_table + 419, prop_name_table + 429, }, // privateuse - { prop_name_table + 429, prop_name_table + 431, }, // ps - { prop_name_table + 431, prop_name_table + 442, }, // punctuation - { prop_name_table + 442, prop_name_table + 444, }, // s* - { prop_name_table + 444, prop_name_table + 446, }, // sc - { prop_name_table + 446, prop_name_table + 455, }, // separator - { prop_name_table + 455, prop_name_table + 457, }, // sk - { prop_name_table + 457, prop_name_table + 459, }, // sm - { prop_name_table + 459, prop_name_table + 461, }, // so - { prop_name_table + 461, prop_name_table + 475, }, // spaceseparator - { prop_name_table + 475, prop_name_table + 495, }, // spacingcombiningmark - { prop_name_table + 495, prop_name_table + 504, }, // surrogate - { prop_name_table + 504, prop_name_table + 510, }, // symbol - { prop_name_table + 510, prop_name_table + 519, }, // titlecase - { prop_name_table + 519, prop_name_table + 534, }, // titlecaseletter - { prop_name_table + 534, prop_name_table + 549, }, // uppercaseletter - { prop_name_table + 549, prop_name_table + 551, }, // z* - { prop_name_table + 551, prop_name_table + 553, }, // zl - { prop_name_table + 553, prop_name_table + 555, }, // zp - { prop_name_table + 555, prop_name_table + 557, }, // zs - }; - - static const icu_regex_traits::char_class_type icu_class_map[] = { - mask_any, // any - mask_ascii, // ascii - (0x3FFFFFFFu) & ~(U_GC_CN_MASK), // assigned - U_GC_C_MASK, // c* - U_GC_CC_MASK, // cc - U_GC_CF_MASK, // cf - U_GC_PE_MASK, // closepunctuation - U_GC_CN_MASK, // cn - U_GC_CO_MASK, // co - U_GC_PC_MASK, // connectorpunctuation - U_GC_CC_MASK, // control - U_GC_CS_MASK, // cs - U_GC_SC_MASK, // currencysymbol - U_GC_PD_MASK, // dashpunctuation - U_GC_ND_MASK, // decimaldigitnumber - U_GC_ME_MASK, // enclosingmark - U_GC_PF_MASK, // finalpunctuation - U_GC_CF_MASK, // format - U_GC_PI_MASK, // initialpunctuation - U_GC_L_MASK, // l* - U_GC_L_MASK, // letter - U_GC_NL_MASK, // letternumber - U_GC_ZL_MASK, // lineseparator - U_GC_LL_MASK, // ll - U_GC_LM_MASK, // lm - U_GC_LO_MASK, // lo - U_GC_LL_MASK, // lowercaseletter - U_GC_LT_MASK, // lt - U_GC_LU_MASK, // lu - U_GC_M_MASK, // m* - U_GC_M_MASK, // mark - U_GC_SM_MASK, // mathsymbol - U_GC_MC_MASK, // mc - U_GC_ME_MASK, // me - U_GC_MN_MASK, // mn - U_GC_LM_MASK, // modifierletter - U_GC_SK_MASK, // modifiersymbol - U_GC_N_MASK, // n* - U_GC_ND_MASK, // nd - U_GC_NL_MASK, // nl - U_GC_NO_MASK, // no - U_GC_MN_MASK, // nonspacingmark - U_GC_CN_MASK, // notassigned - U_GC_N_MASK, // number - U_GC_PS_MASK, // openpunctuation - U_GC_C_MASK, // other - U_GC_LO_MASK, // otherletter - U_GC_NO_MASK, // othernumber - U_GC_PO_MASK, // otherpunctuation - U_GC_SO_MASK, // othersymbol - U_GC_P_MASK, // p* - U_GC_ZP_MASK, // paragraphseparator - U_GC_PC_MASK, // pc - U_GC_PD_MASK, // pd - U_GC_PE_MASK, // pe - U_GC_PF_MASK, // pf - U_GC_PI_MASK, // pi - U_GC_PO_MASK, // po - U_GC_CO_MASK, // privateuse - U_GC_PS_MASK, // ps - U_GC_P_MASK, // punctuation - U_GC_S_MASK, // s* - U_GC_SC_MASK, // sc - U_GC_Z_MASK, // separator - U_GC_SK_MASK, // sk - U_GC_SM_MASK, // sm - U_GC_SO_MASK, // so - U_GC_ZS_MASK, // spaceseparator - U_GC_MC_MASK, // spacingcombiningmark - U_GC_CS_MASK, // surrogate - U_GC_S_MASK, // symbol - U_GC_LT_MASK, // titlecase - U_GC_LT_MASK, // titlecaseletter - U_GC_LU_MASK, // uppercaseletter - U_GC_Z_MASK, // z* - U_GC_ZL_MASK, // zl - U_GC_ZP_MASK, // zp - U_GC_ZS_MASK, // zs - }; - - - const BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32>* ranges_begin = range_data; - const BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32>* ranges_end = range_data + (sizeof(range_data) / sizeof(range_data[0])); - - BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32> t = { p1, p2, }; - const BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32>* p = std::lower_bound(ranges_begin, ranges_end, t); - if ((p != ranges_end) && (t == *p)) - return icu_class_map[p - ranges_begin]; - return 0; - } - - boost::shared_ptr< ::boost::BOOST_REGEX_DETAIL_NS::icu_regex_traits_implementation> m_pimpl; - }; - -} // namespace boost - -namespace boost { - - // types: - typedef basic_regex< ::UChar32, icu_regex_traits> u32regex; - typedef match_results<const ::UChar32*> u32match; - typedef match_results<const ::UChar*> u16match; - - // - // Construction of 32-bit regex types from UTF-8 and UTF-16 primitives: - // - namespace BOOST_REGEX_DETAIL_NS { - -#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) - template <class InputIterator> - inline u32regex do_make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt, - const boost::mpl::int_<1>*) - { - typedef boost::u8_to_u32_iterator<InputIterator, UChar32> conv_type; - return u32regex(conv_type(i, i, j), conv_type(j, i, j), opt); - } - - template <class InputIterator> - inline u32regex do_make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt, - const boost::mpl::int_<2>*) - { - typedef boost::u16_to_u32_iterator<InputIterator, UChar32> conv_type; - return u32regex(conv_type(i, i, j), conv_type(j, i, j), opt); - } - - template <class InputIterator> - inline u32regex do_make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt, - const boost::mpl::int_<4>*) - { - return u32regex(i, j, opt); - } -#else - template <class InputIterator> - inline u32regex do_make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt, - const boost::mpl::int_<1>*) - { - typedef boost::u8_to_u32_iterator<InputIterator, UChar32> conv_type; - typedef std::vector<UChar32> vector_type; - vector_type v; - conv_type a(i, i, j), b(j, i, j); - while (a != b) - { - v.push_back(*a); - ++a; - } - if (v.size()) - return u32regex(&*v.begin(), v.size(), opt); - return u32regex(static_cast<UChar32 const*>(0), static_cast<u32regex::size_type>(0), opt); - } - - template <class InputIterator> - inline u32regex do_make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt, - const boost::mpl::int_<2>*) - { - typedef boost::u16_to_u32_iterator<InputIterator, UChar32> conv_type; - typedef std::vector<UChar32> vector_type; - vector_type v; - conv_type a(i, i, j), b(j, i, j); - while (a != b) - { - v.push_back(*a); - ++a; - } - if (v.size()) - return u32regex(&*v.begin(), v.size(), opt); - return u32regex(static_cast<UChar32 const*>(0), static_cast<u32regex::size_type>(0), opt); - } - - template <class InputIterator> - inline u32regex do_make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt, - const boost::mpl::int_<4>*) - { - typedef std::vector<UChar32> vector_type; - vector_type v; - while (i != j) - { - v.push_back((UChar32)(*i)); - ++i; - } - if (v.size()) - return u32regex(&*v.begin(), v.size(), opt); - return u32regex(static_cast<UChar32 const*>(0), static_cast<u32regex::size_type>(0), opt); - } -#endif - } - - // BOOST_REGEX_UCHAR_IS_WCHAR_T - // - // Source inspection of unicode/umachine.h in ICU version 59 indicates that: - // - // On version 59, UChar is always char16_t in C++ mode (and uint16_t in C mode) - // - // On earlier versions, the logic is - // - // #if U_SIZEOF_WCHAR_T==2 - // typedef wchar_t OldUChar; - // #elif defined(__CHAR16_TYPE__) - // typedef __CHAR16_TYPE__ OldUChar; - // #else - // typedef uint16_t OldUChar; - // #endif - // - // That is, UChar is wchar_t only on versions below 59, when U_SIZEOF_WCHAR_T==2 - // - // Hence, - -#define BOOST_REGEX_UCHAR_IS_WCHAR_T (U_ICU_VERSION_MAJOR_NUM < 59 && U_SIZEOF_WCHAR_T == 2) - -#if BOOST_REGEX_UCHAR_IS_WCHAR_T - BOOST_STATIC_ASSERT((boost::is_same<UChar, wchar_t>::value)); -#else - BOOST_STATIC_ASSERT(!(boost::is_same<UChar, wchar_t>::value)); -#endif - - // - // Construction from an iterator pair: - // - template <class InputIterator> - inline u32regex make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt) - { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(i, j, opt, static_cast<boost::mpl::int_<sizeof(*i)> const*>(0)); - } - // - // construction from UTF-8 nul-terminated strings: - // - inline u32regex make_u32regex(const char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) - { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::strlen(p), opt, static_cast<boost::mpl::int_<1> const*>(0)); - } - inline u32regex make_u32regex(const unsigned char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) - { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::strlen(reinterpret_cast<const char*>(p)), opt, static_cast<boost::mpl::int_<1> const*>(0)); - } - // - // construction from UTF-16 nul-terminated strings: - // -#ifndef BOOST_NO_WREGEX - inline u32regex make_u32regex(const wchar_t* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) - { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::wcslen(p), opt, static_cast<boost::mpl::int_<sizeof(wchar_t)> const*>(0)); - } -#endif -#if !BOOST_REGEX_UCHAR_IS_WCHAR_T - inline u32regex make_u32regex(const UChar* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) - { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + u_strlen(p), opt, static_cast<boost::mpl::int_<2> const*>(0)); - } -#endif - // - // construction from basic_string class-template: - // - template<class C, class T, class A> - inline u32regex make_u32regex(const std::basic_string<C, T, A>& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) - { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(s.begin(), s.end(), opt, static_cast<boost::mpl::int_<sizeof(C)> const*>(0)); - } - // - // Construction from ICU string type: - // - inline u32regex make_u32regex(const U_NAMESPACE_QUALIFIER UnicodeString& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) - { - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(s.getBuffer(), s.getBuffer() + s.length(), opt, static_cast<boost::mpl::int_<2> const*>(0)); - } - - // - // regex_match overloads that widen the character type as appropriate: - // - namespace BOOST_REGEX_DETAIL_NS { - template<class MR1, class MR2, class NSubs> - void copy_results(MR1& out, MR2 const& in, NSubs named_subs) - { - // copy results from an adapted MR2 match_results: - out.set_size(in.size(), in.prefix().first.base(), in.suffix().second.base()); - out.set_base(in.base().base()); - out.set_named_subs(named_subs); - for (int i = 0; i < (int)in.size(); ++i) - { - if (in[i].matched || !i) - { - out.set_first(in[i].first.base(), i); - out.set_second(in[i].second.base(), i, in[i].matched); - } - } -#ifdef BOOST_REGEX_MATCH_EXTRA - // Copy full capture info as well: - for (int i = 0; i < (int)in.size(); ++i) - { - if (in[i].captures().size()) - { - out[i].get_captures().assign(in[i].captures().size(), typename MR1::value_type()); - for (int j = 0; j < (int)out[i].captures().size(); ++j) - { - out[i].get_captures()[j].first = in[i].captures()[j].first.base(); - out[i].get_captures()[j].second = in[i].captures()[j].second.base(); - out[i].get_captures()[j].matched = in[i].captures()[j].matched; - } - } - } -#endif - } - - template <class BidiIterator, class Allocator> - inline bool do_regex_match(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - boost::mpl::int_<4> const*) - { - return ::boost::regex_match(first, last, m, e, flags); - } - template <class BidiIterator, class Allocator> - bool do_regex_match(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - boost::mpl::int_<2> const*) - { - typedef u16_to_u32_iterator<BidiIterator, UChar32> conv_type; - typedef match_results<conv_type> match_type; - //typedef typename match_type::allocator_type alloc_type; - match_type what; - bool result = ::boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags); - // copy results across to m: - if (result) copy_results(m, what, e.get_named_subs()); - return result; - } - template <class BidiIterator, class Allocator> - bool do_regex_match(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - boost::mpl::int_<1> const*) - { - typedef u8_to_u32_iterator<BidiIterator, UChar32> conv_type; - typedef match_results<conv_type> match_type; - //typedef typename match_type::allocator_type alloc_type; - match_type what; - bool result = ::boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags); - // copy results across to m: - if (result) copy_results(m, what, e.get_named_subs()); - return result; - } - } // namespace BOOST_REGEX_DETAIL_NS - - template <class BidiIterator, class Allocator> - inline bool u32regex_match(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_match(first, last, m, e, flags, static_cast<mpl::int_<sizeof(*first)> const*>(0)); - } - inline bool u32regex_match(const UChar* p, - match_results<const UChar*>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p + u_strlen(p), m, e, flags, static_cast<mpl::int_<2> const*>(0)); - } -#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX) - inline bool u32regex_match(const wchar_t* p, - match_results<const wchar_t*>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p + std::wcslen(p), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); - } -#endif - inline bool u32regex_match(const char* p, - match_results<const char*>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p + std::strlen(p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); - } - inline bool u32regex_match(const unsigned char* p, - match_results<const unsigned char*>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p + std::strlen((const char*)p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); - } - inline bool u32regex_match(const std::string& s, - match_results<std::string::const_iterator>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<1> const*>(0)); - } -#ifndef BOOST_NO_STD_WSTRING - inline bool u32regex_match(const std::wstring& s, - match_results<std::wstring::const_iterator>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); - } -#endif - inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, - match_results<const UChar*>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast<mpl::int_<2> const*>(0)); - } - // - // regex_match overloads that do not return what matched: - // - template <class BidiIterator> - inline bool u32regex_match(BidiIterator first, BidiIterator last, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<BidiIterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(first, last, m, e, flags, static_cast<mpl::int_<sizeof(*first)> const*>(0)); - } - inline bool u32regex_match(const UChar* p, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<const UChar*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p + u_strlen(p), m, e, flags, static_cast<mpl::int_<2> const*>(0)); - } -#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX) - inline bool u32regex_match(const wchar_t* p, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<const wchar_t*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p + std::wcslen(p), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); - } -#endif - inline bool u32regex_match(const char* p, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<const char*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p + std::strlen(p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); - } - inline bool u32regex_match(const unsigned char* p, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<const unsigned char*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p + std::strlen((const char*)p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); - } - inline bool u32regex_match(const std::string& s, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<std::string::const_iterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<1> const*>(0)); - } -#ifndef BOOST_NO_STD_WSTRING - inline bool u32regex_match(const std::wstring& s, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<std::wstring::const_iterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); - } -#endif - inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<const UChar*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast<mpl::int_<2> const*>(0)); - } - - // - // regex_search overloads that widen the character type as appropriate: - // - namespace BOOST_REGEX_DETAIL_NS { - template <class BidiIterator, class Allocator> - inline bool do_regex_search(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - BidiIterator base, - boost::mpl::int_<4> const*) - { - return ::boost::regex_search(first, last, m, e, flags, base); - } - template <class BidiIterator, class Allocator> - bool do_regex_search(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - BidiIterator base, - boost::mpl::int_<2> const*) - { - typedef u16_to_u32_iterator<BidiIterator, UChar32> conv_type; - typedef match_results<conv_type> match_type; - //typedef typename match_type::allocator_type alloc_type; - match_type what; - bool result = ::boost::regex_search(conv_type(first, first, last), conv_type(last, first, last), what, e, flags, conv_type(base)); - // copy results across to m: - if (result) copy_results(m, what, e.get_named_subs()); - return result; - } - template <class BidiIterator, class Allocator> - bool do_regex_search(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - BidiIterator base, - boost::mpl::int_<1> const*) - { - typedef u8_to_u32_iterator<BidiIterator, UChar32> conv_type; - typedef match_results<conv_type> match_type; - //typedef typename match_type::allocator_type alloc_type; - match_type what; - bool result = ::boost::regex_search(conv_type(first, first, last), conv_type(last, first, last), what, e, flags, conv_type(base)); - // copy results across to m: - if (result) copy_results(m, what, e.get_named_subs()); - return result; - } - } - - template <class BidiIterator, class Allocator> - inline bool u32regex_search(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, first, static_cast<mpl::int_<sizeof(*first)> const*>(0)); - } - template <class BidiIterator, class Allocator> - inline bool u32regex_search(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - BidiIterator base) - { - return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, base, static_cast<mpl::int_<sizeof(*first)> const*>(0)); - } - inline bool u32regex_search(const UChar* p, - match_results<const UChar*>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p + u_strlen(p), m, e, flags, p, static_cast<mpl::int_<2> const*>(0)); - } -#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX) - inline bool u32regex_search(const wchar_t* p, - match_results<const wchar_t*>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p + std::wcslen(p), m, e, flags, p, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); - } -#endif - inline bool u32regex_search(const char* p, - match_results<const char*>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p + std::strlen(p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); - } - inline bool u32regex_search(const unsigned char* p, - match_results<const unsigned char*>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p + std::strlen((const char*)p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); - } - inline bool u32regex_search(const std::string& s, - match_results<std::string::const_iterator>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<1> const*>(0)); - } -#ifndef BOOST_NO_STD_WSTRING - inline bool u32regex_search(const std::wstring& s, - match_results<std::wstring::const_iterator>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); - } -#endif - inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, - match_results<const UChar*>& m, - const u32regex& e, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<mpl::int_<2> const*>(0)); - } - template <class BidiIterator> - inline bool u32regex_search(BidiIterator first, BidiIterator last, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<BidiIterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, first, static_cast<mpl::int_<sizeof(*first)> const*>(0)); - } - inline bool u32regex_search(const UChar* p, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<const UChar*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p + u_strlen(p), m, e, flags, p, static_cast<mpl::int_<2> const*>(0)); - } -#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX) - inline bool u32regex_search(const wchar_t* p, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<const wchar_t*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p + std::wcslen(p), m, e, flags, p, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); - } -#endif - inline bool u32regex_search(const char* p, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<const char*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p + std::strlen(p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); - } - inline bool u32regex_search(const unsigned char* p, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<const unsigned char*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p + std::strlen((const char*)p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); - } - inline bool u32regex_search(const std::string& s, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<std::string::const_iterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<1> const*>(0)); - } -#ifndef BOOST_NO_STD_WSTRING - inline bool u32regex_search(const std::wstring& s, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<std::wstring::const_iterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); - } -#endif - inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, - const u32regex& e, - match_flag_type flags = match_default) - { - match_results<const UChar*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<mpl::int_<2> const*>(0)); - } - - // - // overloads for regex_replace with utf-8 and utf-16 data types: - // - namespace BOOST_REGEX_DETAIL_NS { - template <class I> - inline std::pair< boost::u8_to_u32_iterator<I>, boost::u8_to_u32_iterator<I> > - make_utf32_seq(I i, I j, mpl::int_<1> const*) - { - return std::pair< boost::u8_to_u32_iterator<I>, boost::u8_to_u32_iterator<I> >(boost::u8_to_u32_iterator<I>(i, i, j), boost::u8_to_u32_iterator<I>(j, i, j)); - } - template <class I> - inline std::pair< boost::u16_to_u32_iterator<I>, boost::u16_to_u32_iterator<I> > - make_utf32_seq(I i, I j, mpl::int_<2> const*) - { - return std::pair< boost::u16_to_u32_iterator<I>, boost::u16_to_u32_iterator<I> >(boost::u16_to_u32_iterator<I>(i, i, j), boost::u16_to_u32_iterator<I>(j, i, j)); - } - template <class I> - inline std::pair< I, I > - make_utf32_seq(I i, I j, mpl::int_<4> const*) - { - return std::pair< I, I >(i, j); - } - template <class charT> - inline std::pair< boost::u8_to_u32_iterator<const charT*>, boost::u8_to_u32_iterator<const charT*> > - make_utf32_seq(const charT* p, mpl::int_<1> const*) - { - std::size_t len = std::strlen((const char*)p); - return std::pair< boost::u8_to_u32_iterator<const charT*>, boost::u8_to_u32_iterator<const charT*> >(boost::u8_to_u32_iterator<const charT*>(p, p, p + len), boost::u8_to_u32_iterator<const charT*>(p + len, p, p + len)); - } - template <class charT> - inline std::pair< boost::u16_to_u32_iterator<const charT*>, boost::u16_to_u32_iterator<const charT*> > - make_utf32_seq(const charT* p, mpl::int_<2> const*) - { - std::size_t len = u_strlen((const UChar*)p); - return std::pair< boost::u16_to_u32_iterator<const charT*>, boost::u16_to_u32_iterator<const charT*> >(boost::u16_to_u32_iterator<const charT*>(p, p, p + len), boost::u16_to_u32_iterator<const charT*>(p + len, p, p + len)); - } - template <class charT> - inline std::pair< const charT*, const charT* > - make_utf32_seq(const charT* p, mpl::int_<4> const*) - { - return std::pair< const charT*, const charT* >(p, p + icu_regex_traits::length((UChar32 const*)p)); - } - template <class OutputIterator> - inline OutputIterator make_utf32_out(OutputIterator o, mpl::int_<4> const*) - { - return o; - } - template <class OutputIterator> - inline utf16_output_iterator<OutputIterator> make_utf32_out(OutputIterator o, mpl::int_<2> const*) - { - return o; - } - template <class OutputIterator> - inline utf8_output_iterator<OutputIterator> make_utf32_out(OutputIterator o, mpl::int_<1> const*) - { - return o; - } - - template <class OutputIterator, class I1, class I2> - OutputIterator do_regex_replace(OutputIterator out, - std::pair<I1, I1> const& in, - const u32regex& e, - const std::pair<I2, I2>& fmt, - match_flag_type flags - ) - { - // unfortunately we have to copy the format string in order to pass in onward: - std::vector<UChar32> f; -#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS - f.assign(fmt.first, fmt.second); -#else - f.clear(); - I2 pos = fmt.first; - while (pos != fmt.second) - f.push_back(*pos++); -#endif - - regex_iterator<I1, UChar32, icu_regex_traits> i(in.first, in.second, e, flags); - regex_iterator<I1, UChar32, icu_regex_traits> j; - if (i == j) - { - if (!(flags & regex_constants::format_no_copy)) - out = BOOST_REGEX_DETAIL_NS::copy(in.first, in.second, out); - } - else - { - I1 last_m = in.first; - while (i != j) - { - if (!(flags & regex_constants::format_no_copy)) - out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out); - if (!f.empty()) - out = ::boost::BOOST_REGEX_DETAIL_NS::regex_format_imp(out, *i, &*f.begin(), &*f.begin() + f.size(), flags, e.get_traits()); - else - out = ::boost::BOOST_REGEX_DETAIL_NS::regex_format_imp(out, *i, static_cast<UChar32 const*>(0), static_cast<UChar32 const*>(0), flags, e.get_traits()); - last_m = (*i)[0].second; - if (flags & regex_constants::format_first_only) - break; - ++i; - } - if (!(flags & regex_constants::format_no_copy)) - out = BOOST_REGEX_DETAIL_NS::copy(last_m, in.second, out); - } - return out; - } - template <class BaseIterator> - inline const BaseIterator& extract_output_base(const BaseIterator& b) - { - return b; - } - template <class BaseIterator> - inline BaseIterator extract_output_base(const utf8_output_iterator<BaseIterator>& b) - { - return b.base(); - } - template <class BaseIterator> - inline BaseIterator extract_output_base(const utf16_output_iterator<BaseIterator>& b) - { - return b.base(); - } - } // BOOST_REGEX_DETAIL_NS - - template <class OutputIterator, class BidirectionalIterator, class charT> - inline OutputIterator u32regex_replace(OutputIterator out, - BidirectionalIterator first, - BidirectionalIterator last, - const u32regex& e, - const charT* fmt, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::extract_output_base - ( - BOOST_REGEX_DETAIL_NS::do_regex_replace( - BOOST_REGEX_DETAIL_NS::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)), - BOOST_REGEX_DETAIL_NS::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)), - e, - BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt, static_cast<mpl::int_<sizeof(*fmt)> const*>(0)), - flags) - ); - } - - template <class OutputIterator, class Iterator, class charT> - inline OutputIterator u32regex_replace(OutputIterator out, - Iterator first, - Iterator last, - const u32regex& e, - const std::basic_string<charT>& fmt, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::extract_output_base - ( - BOOST_REGEX_DETAIL_NS::do_regex_replace( - BOOST_REGEX_DETAIL_NS::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)), - BOOST_REGEX_DETAIL_NS::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)), - e, - BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt.begin(), fmt.end(), static_cast<mpl::int_<sizeof(charT)> const*>(0)), - flags) - ); - } - - template <class OutputIterator, class Iterator> - inline OutputIterator u32regex_replace(OutputIterator out, - Iterator first, - Iterator last, - const u32regex& e, - const U_NAMESPACE_QUALIFIER UnicodeString& fmt, - match_flag_type flags = match_default) - { - return BOOST_REGEX_DETAIL_NS::extract_output_base - ( - BOOST_REGEX_DETAIL_NS::do_regex_replace( - BOOST_REGEX_DETAIL_NS::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)), - BOOST_REGEX_DETAIL_NS::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)), - e, - BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast<mpl::int_<2> const*>(0)), - flags) - ); - } - - template <class charT> - std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s, - const u32regex& e, - const charT* fmt, - match_flag_type flags = match_default) - { - std::basic_string<charT> result; - BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result); - u32regex_replace(i, s.begin(), s.end(), e, fmt, flags); - return result; - } - - template <class charT> - std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s, - const u32regex& e, - const std::basic_string<charT>& fmt, - match_flag_type flags = match_default) - { - std::basic_string<charT> result; - BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result); - u32regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags); - return result; - } - - namespace BOOST_REGEX_DETAIL_NS { - - class unicode_string_out_iterator - { - U_NAMESPACE_QUALIFIER UnicodeString* out; - public: - unicode_string_out_iterator(U_NAMESPACE_QUALIFIER UnicodeString& s) : out(&s) {} - unicode_string_out_iterator& operator++() { return *this; } - unicode_string_out_iterator& operator++(int) { return *this; } - unicode_string_out_iterator& operator*() { return *this; } - unicode_string_out_iterator& operator=(UChar v) - { - *out += v; - return *this; - } - typedef std::ptrdiff_t difference_type; - typedef UChar value_type; - typedef value_type* pointer; - typedef value_type& reference; - typedef std::output_iterator_tag iterator_category; - }; - - } - - inline U_NAMESPACE_QUALIFIER UnicodeString u32regex_replace(const U_NAMESPACE_QUALIFIER UnicodeString& s, - const u32regex& e, - const UChar* fmt, - match_flag_type flags = match_default) - { - U_NAMESPACE_QUALIFIER UnicodeString result; - BOOST_REGEX_DETAIL_NS::unicode_string_out_iterator i(result); - u32regex_replace(i, s.getBuffer(), s.getBuffer() + s.length(), e, fmt, flags); - return result; - } - - inline U_NAMESPACE_QUALIFIER UnicodeString u32regex_replace(const U_NAMESPACE_QUALIFIER UnicodeString& s, - const u32regex& e, - const U_NAMESPACE_QUALIFIER UnicodeString& fmt, - match_flag_type flags = match_default) - { - U_NAMESPACE_QUALIFIER UnicodeString result; - BOOST_REGEX_DETAIL_NS::unicode_string_out_iterator i(result); - BOOST_REGEX_DETAIL_NS::do_regex_replace( - BOOST_REGEX_DETAIL_NS::make_utf32_out(i, static_cast<mpl::int_<2> const*>(0)), - BOOST_REGEX_DETAIL_NS::make_utf32_seq(s.getBuffer(), s.getBuffer() + s.length(), static_cast<mpl::int_<2> const*>(0)), - e, - BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast<mpl::int_<2> const*>(0)), - flags); - return result; - } - -} // namespace boost. - -#ifdef BOOST_MSVC -#pragma warning (pop) -#endif - -#include <boost/regex/v4/u32regex_iterator.hpp> -#include <boost/regex/v4/u32regex_token_iterator.hpp> - -#endif diff --git a/contrib/restricted/boost/regex/include/boost/regex/v4/u32regex_iterator.hpp b/contrib/restricted/boost/regex/include/boost/regex/v4/u32regex_iterator.hpp deleted file mode 100644 index f8763a8d6a..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/v4/u32regex_iterator.hpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * - * Copyright (c) 2003 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE u32regex_iterator.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Provides u32regex_iterator implementation. - */ - -#ifndef BOOST_REGEX_V4_U32REGEX_ITERATOR_HPP -#define BOOST_REGEX_V4_U32REGEX_ITERATOR_HPP - -namespace boost{ - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -template <class BidirectionalIterator> -class u32regex_iterator_implementation -{ - typedef u32regex regex_type; - - match_results<BidirectionalIterator> what; // current match - BidirectionalIterator base; // start of sequence - BidirectionalIterator end; // end of sequence - const regex_type re; // the expression - match_flag_type flags; // flags for matching - -public: - u32regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f) - : base(), end(last), re(*p), flags(f){} - bool init(BidirectionalIterator first) - { - base = first; - return u32regex_search(first, end, what, re, flags, base); - } - bool compare(const u32regex_iterator_implementation& that) - { - if(this == &that) return true; - return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second); - } - const match_results<BidirectionalIterator>& get() - { return what; } - bool next() - { - //if(what.prefix().first != what[0].second) - // flags |= match_prev_avail; - BidirectionalIterator next_start = what[0].second; - match_flag_type f(flags); - if(!what.length()) - f |= regex_constants::match_not_initial_null; - //if(base != next_start) - // f |= regex_constants::match_not_bob; - bool result = u32regex_search(next_start, end, what, re, f, base); - if(result) - what.set_base(base); - return result; - } -private: - u32regex_iterator_implementation& operator=(const u32regex_iterator_implementation&); -}; - -template <class BidirectionalIterator> -class u32regex_iterator -{ -private: - typedef u32regex_iterator_implementation<BidirectionalIterator> impl; - typedef shared_ptr<impl> pimpl; -public: - typedef u32regex regex_type; - typedef match_results<BidirectionalIterator> value_type; - typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::difference_type - difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; - typedef std::forward_iterator_tag iterator_category; - - u32regex_iterator(){} - u32regex_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - match_flag_type m = match_default) - : pdata(new impl(&re, b, m)) - { - if(!pdata->init(a)) - { - pdata.reset(); - } - } - u32regex_iterator(const u32regex_iterator& that) - : pdata(that.pdata) {} - u32regex_iterator& operator=(const u32regex_iterator& that) - { - pdata = that.pdata; - return *this; - } - bool operator==(const u32regex_iterator& that)const - { - if((pdata.get() == 0) || (that.pdata.get() == 0)) - return pdata.get() == that.pdata.get(); - return pdata->compare(*(that.pdata.get())); - } - bool operator!=(const u32regex_iterator& that)const - { return !(*this == that); } - const value_type& operator*()const - { return pdata->get(); } - const value_type* operator->()const - { return &(pdata->get()); } - u32regex_iterator& operator++() - { - cow(); - if(0 == pdata->next()) - { - pdata.reset(); - } - return *this; - } - u32regex_iterator operator++(int) - { - u32regex_iterator result(*this); - ++(*this); - return result; - } -private: - - pimpl pdata; - - void cow() - { - // copy-on-write - if(pdata.get() && !pdata.unique()) - { - pdata.reset(new impl(*(pdata.get()))); - } - } -}; - -typedef u32regex_iterator<const char*> utf8regex_iterator; -typedef u32regex_iterator<const UChar*> utf16regex_iterator; -typedef u32regex_iterator<const UChar32*> utf32regex_iterator; - -inline u32regex_iterator<const char*> make_u32regex_iterator(const char* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_iterator<const char*>(p, p+std::strlen(p), e, m); -} -#ifndef BOOST_NO_WREGEX -inline u32regex_iterator<const wchar_t*> make_u32regex_iterator(const wchar_t* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_iterator<const wchar_t*>(p, p+std::wcslen(p), e, m); -} -#endif -#if !defined(BOOST_REGEX_UCHAR_IS_WCHAR_T) -inline u32regex_iterator<const UChar*> make_u32regex_iterator(const UChar* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_iterator<const UChar*>(p, p+u_strlen(p), e, m); -} -#endif -template <class charT, class Traits, class Alloc> -inline u32regex_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) -{ - typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type; - return u32regex_iterator<iter_type>(p.begin(), p.end(), e, m); -} -inline u32regex_iterator<const UChar*> make_u32regex_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, m); -} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -} // namespace boost - -#endif // BOOST_REGEX_V4_REGEX_ITERATOR_HPP - diff --git a/contrib/restricted/boost/regex/include/boost/regex/v4/u32regex_token_iterator.hpp b/contrib/restricted/boost/regex/include/boost/regex/v4/u32regex_token_iterator.hpp deleted file mode 100644 index 2e04810dff..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/v4/u32regex_token_iterator.hpp +++ /dev/null @@ -1,360 +0,0 @@ -/* - * - * Copyright (c) 2003 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE u32regex_token_iterator.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Provides u32regex_token_iterator implementation. - */ - -#ifndef BOOST_REGEX_V4_U32REGEX_TOKEN_ITERATOR_HPP -#define BOOST_REGEX_V4_U32REGEX_TOKEN_ITERATOR_HPP - -#if (BOOST_WORKAROUND(BOOST_BORLANDC, >= 0x560) && BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x570)))\ - || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) -// -// Borland C++ Builder 6, and Visual C++ 6, -// can't cope with the array template constructor -// so we have a template member that will accept any type as -// argument, and then assert that is really is an array: -// -#include <boost/static_assert.hpp> -#include <boost/type_traits/is_array.hpp> -#endif - -namespace boost{ - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif -#ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable:4700) -#endif - -template <class BidirectionalIterator> -class u32regex_token_iterator_implementation -{ - typedef u32regex regex_type; - typedef sub_match<BidirectionalIterator> value_type; - - match_results<BidirectionalIterator> what; // current match - BidirectionalIterator end; // end of search area - BidirectionalIterator base; // start of search area - const regex_type re; // the expression - match_flag_type flags; // match flags - value_type result; // the current string result - int N; // the current sub-expression being enumerated - std::vector<int> subs; // the sub-expressions to enumerate - -public: - u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f) - : end(last), re(*p), flags(f){ subs.push_back(sub); } - u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector<int>& v, match_flag_type f) - : end(last), re(*p), flags(f), subs(v){} -#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ - || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ - || BOOST_WORKAROUND(__HP_aCC, < 60700) - template <class T> - u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const T& submatches, match_flag_type f) - : end(last), re(*p), flags(f) - { - // assert that T really is an array: - BOOST_STATIC_ASSERT(::boost::is_array<T>::value); - const std::size_t array_size = sizeof(T) / sizeof(submatches[0]); - for(std::size_t i = 0; i < array_size; ++i) - { - subs.push_back(submatches[i]); - } - } -#else - template <std::size_t CN> - u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const int (&submatches)[CN], match_flag_type f) - : end(last), re(*p), flags(f) - { - for(std::size_t i = 0; i < CN; ++i) - { - subs.push_back(submatches[i]); - } - } -#endif - - bool init(BidirectionalIterator first) - { - base = first; - N = 0; - if(u32regex_search(first, end, what, re, flags, base) == true) - { - N = 0; - result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]); - return true; - } - else if((subs[N] == -1) && (first != end)) - { - result.first = first; - result.second = end; - result.matched = (first != end); - N = -1; - return true; - } - return false; - } - bool compare(const u32regex_token_iterator_implementation& that) - { - if(this == &that) return true; - return (&re.get_data() == &that.re.get_data()) - && (end == that.end) - && (flags == that.flags) - && (N == that.N) - && (what[0].first == that.what[0].first) - && (what[0].second == that.what[0].second); - } - const value_type& get() - { return result; } - bool next() - { - if(N == -1) - return false; - if(N+1 < (int)subs.size()) - { - ++N; - result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); - return true; - } - //if(what.prefix().first != what[0].second) - // flags |= match_prev_avail | regex_constants::match_not_bob; - BidirectionalIterator last_end(what[0].second); - if(u32regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base)) - { - N =0; - result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); - return true; - } - else if((last_end != end) && (subs[0] == -1)) - { - N =-1; - result.first = last_end; - result.second = end; - result.matched = (last_end != end); - return true; - } - return false; - } -private: - u32regex_token_iterator_implementation& operator=(const u32regex_token_iterator_implementation&); -}; - -template <class BidirectionalIterator> -class u32regex_token_iterator -{ -private: - typedef u32regex_token_iterator_implementation<BidirectionalIterator> impl; - typedef shared_ptr<impl> pimpl; -public: - typedef u32regex regex_type; - typedef sub_match<BidirectionalIterator> value_type; - typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::difference_type - difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; - typedef std::forward_iterator_tag iterator_category; - - u32regex_token_iterator(){} - u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, - int submatch = 0, match_flag_type m = match_default) - : pdata(new impl(&re, b, submatch, m)) - { - if(!pdata->init(a)) - pdata.reset(); - } - u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, - const std::vector<int>& submatches, match_flag_type m = match_default) - : pdata(new impl(&re, b, submatches, m)) - { - if(!pdata->init(a)) - pdata.reset(); - } -#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ - || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ - || BOOST_WORKAROUND(__HP_aCC, < 60700) - template <class T> - u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, - const T& submatches, match_flag_type m = match_default) - : pdata(new impl(&re, b, submatches, m)) - { - if(!pdata->init(a)) - pdata.reset(); - } -#else - template <std::size_t N> - u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, - const int (&submatches)[N], match_flag_type m = match_default) - : pdata(new impl(&re, b, submatches, m)) - { - if(!pdata->init(a)) - pdata.reset(); - } -#endif - u32regex_token_iterator(const u32regex_token_iterator& that) - : pdata(that.pdata) {} - u32regex_token_iterator& operator=(const u32regex_token_iterator& that) - { - pdata = that.pdata; - return *this; - } - bool operator==(const u32regex_token_iterator& that)const - { - if((pdata.get() == 0) || (that.pdata.get() == 0)) - return pdata.get() == that.pdata.get(); - return pdata->compare(*(that.pdata.get())); - } - bool operator!=(const u32regex_token_iterator& that)const - { return !(*this == that); } - const value_type& operator*()const - { return pdata->get(); } - const value_type* operator->()const - { return &(pdata->get()); } - u32regex_token_iterator& operator++() - { - cow(); - if(0 == pdata->next()) - { - pdata.reset(); - } - return *this; - } - u32regex_token_iterator operator++(int) - { - u32regex_token_iterator result(*this); - ++(*this); - return result; - } -private: - - pimpl pdata; - - void cow() - { - // copy-on-write - if(pdata.get() && !pdata.unique()) - { - pdata.reset(new impl(*(pdata.get()))); - } - } -}; - -typedef u32regex_token_iterator<const char*> utf8regex_token_iterator; -typedef u32regex_token_iterator<const UChar*> utf16regex_token_iterator; -typedef u32regex_token_iterator<const UChar32*> utf32regex_token_iterator; - -// construction from an integral sub_match state_id: -inline u32regex_token_iterator<const char*> make_u32regex_token_iterator(const char* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const char*>(p, p+std::strlen(p), e, submatch, m); -} -#ifndef BOOST_NO_WREGEX -inline u32regex_token_iterator<const wchar_t*> make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const wchar_t*>(p, p+std::wcslen(p), e, submatch, m); -} -#endif -#if !defined(BOOST_REGEX_UCHAR_IS_WCHAR_T) -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, submatch, m); -} -#endif -template <class charT, class Traits, class Alloc> -inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) -{ - typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type; - return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m); -} -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); -} - -// construction from a reference to an array: -template <std::size_t N> -inline u32regex_token_iterator<const char*> make_u32regex_token_iterator(const char* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const char*>(p, p+std::strlen(p), e, submatch, m); -} -#ifndef BOOST_NO_WREGEX -template <std::size_t N> -inline u32regex_token_iterator<const wchar_t*> make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const wchar_t*>(p, p+std::wcslen(p), e, submatch, m); -} -#endif -#if !defined(BOOST_REGEX_UCHAR_IS_WCHAR_T) -template <std::size_t N> -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, submatch, m); -} -#endif -template <class charT, class Traits, class Alloc, std::size_t N> -inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) -{ - typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type; - return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m); -} -template <std::size_t N> -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); -} - -// construction from a vector of sub_match state_id's: -inline u32regex_token_iterator<const char*> make_u32regex_token_iterator(const char* p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const char*>(p, p+std::strlen(p), e, submatch, m); -} -#ifndef BOOST_NO_WREGEX -inline u32regex_token_iterator<const wchar_t*> make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const wchar_t*>(p, p+std::wcslen(p), e, submatch, m); -} -#endif -#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, submatch, m); -} -#endif -template <class charT, class Traits, class Alloc> -inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default) -{ - typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type; - return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m); -} -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); -} - -#ifdef BOOST_MSVC -# pragma warning(pop) -#endif -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -} // namespace boost - -#endif // BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP - - - - diff --git a/contrib/restricted/boost/regex/include/boost/regex/v4/unicode_iterator.hpp b/contrib/restricted/boost/regex/include/boost/regex/v4/unicode_iterator.hpp deleted file mode 100644 index 985aa72b20..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/v4/unicode_iterator.hpp +++ /dev/null @@ -1,871 +0,0 @@ -/* - * - * Copyright (c) 2004 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE unicode_iterator.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Iterator adapters for converting between different Unicode encodings. - */ - -/**************************************************************************** - -Contents: -~~~~~~~~~ - -1) Read Only, Input Adapters: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -template <class BaseIterator, class U8Type = ::boost::uint8_t> -class u32_to_u8_iterator; - -Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-8. - -template <class BaseIterator, class U32Type = ::boost::uint32_t> -class u8_to_u32_iterator; - -Adapts sequence of UTF-8 code points to "look like" a sequence of UTF-32. - -template <class BaseIterator, class U16Type = ::boost::uint16_t> -class u32_to_u16_iterator; - -Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-16. - -template <class BaseIterator, class U32Type = ::boost::uint32_t> -class u16_to_u32_iterator; - -Adapts sequence of UTF-16 code points to "look like" a sequence of UTF-32. - -2) Single pass output iterator adapters: - -template <class BaseIterator> -class utf8_output_iterator; - -Accepts UTF-32 code points and forwards them on as UTF-8 code points. - -template <class BaseIterator> -class utf16_output_iterator; - -Accepts UTF-32 code points and forwards them on as UTF-16 code points. - -****************************************************************************/ - -#ifndef BOOST_REGEX_V4_UNICODE_ITERATOR_HPP -#define BOOST_REGEX_V4_UNICODE_ITERATOR_HPP -#include <boost/cstdint.hpp> -#include <boost/regex/config.hpp> -#include <boost/static_assert.hpp> -#include <boost/throw_exception.hpp> -#include <stdexcept> -#ifndef BOOST_NO_STD_LOCALE -#include <sstream> -#include <ios> -#endif -#include <limits.h> // CHAR_BIT - -#ifdef BOOST_REGEX_CXX03 - -#else -#endif - -namespace boost{ - -namespace detail{ - -static const ::boost::uint16_t high_surrogate_base = 0xD7C0u; -static const ::boost::uint16_t low_surrogate_base = 0xDC00u; -static const ::boost::uint32_t ten_bit_mask = 0x3FFu; - -inline bool is_high_surrogate(::boost::uint16_t v) -{ - return (v & 0xFFFFFC00u) == 0xd800u; -} -inline bool is_low_surrogate(::boost::uint16_t v) -{ - return (v & 0xFFFFFC00u) == 0xdc00u; -} -template <class T> -inline bool is_surrogate(T v) -{ - return (v & 0xFFFFF800u) == 0xd800; -} - -inline unsigned utf8_byte_count(boost::uint8_t c) -{ - // if the most significant bit with a zero in it is in position - // 8-N then there are N bytes in this UTF-8 sequence: - boost::uint8_t mask = 0x80u; - unsigned result = 0; - while(c & mask) - { - ++result; - mask >>= 1; - } - return (result == 0) ? 1 : ((result > 4) ? 4 : result); -} - -inline unsigned utf8_trailing_byte_count(boost::uint8_t c) -{ - return utf8_byte_count(c) - 1; -} - -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4100) -#endif -#ifndef BOOST_NO_EXCEPTIONS -BOOST_NORETURN -#endif -inline void invalid_utf32_code_point(::boost::uint32_t val) -{ -#ifndef BOOST_NO_STD_LOCALE - std::stringstream ss; - ss << "Invalid UTF-32 code point U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-16 sequence"; - std::out_of_range e(ss.str()); -#else - std::out_of_range e("Invalid UTF-32 code point encountered while trying to encode UTF-16 sequence"); -#endif - boost::throw_exception(e); -} -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif - - -} // namespace detail - -template <class BaseIterator, class U16Type = ::boost::uint16_t> -class u32_to_u16_iterator -{ -#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) - typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type; - - BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 32); - BOOST_STATIC_ASSERT(sizeof(U16Type)*CHAR_BIT == 16); -#endif - -public: - typedef std::ptrdiff_t difference_type; - typedef U16Type value_type; - typedef value_type const* pointer; - typedef value_type const reference; - typedef std::bidirectional_iterator_tag iterator_category; - - reference operator*()const - { - if(m_current == 2) - extract_current(); - return m_values[m_current]; - } - bool operator==(const u32_to_u16_iterator& that)const - { - if(m_position == that.m_position) - { - // Both m_currents must be equal, or both even - // this is the same as saying their sum must be even: - return (m_current + that.m_current) & 1u ? false : true; - } - return false; - } - bool operator!=(const u32_to_u16_iterator& that)const - { - return !(*this == that); - } - u32_to_u16_iterator& operator++() - { - // if we have a pending read then read now, so that we know whether - // to skip a position, or move to a low-surrogate: - if(m_current == 2) - { - // pending read: - extract_current(); - } - // move to the next surrogate position: - ++m_current; - // if we've reached the end skip a position: - if(m_values[m_current] == 0) - { - m_current = 2; - ++m_position; - } - return *this; - } - u32_to_u16_iterator operator++(int) - { - u32_to_u16_iterator r(*this); - ++(*this); - return r; - } - u32_to_u16_iterator& operator--() - { - if(m_current != 1) - { - // decrementing an iterator always leads to a valid position: - --m_position; - extract_current(); - m_current = m_values[1] ? 1 : 0; - } - else - { - m_current = 0; - } - return *this; - } - u32_to_u16_iterator operator--(int) - { - u32_to_u16_iterator r(*this); - --(*this); - return r; - } - BaseIterator base()const - { - return m_position; - } - // construct: - u32_to_u16_iterator() : m_position(), m_current(0) - { - m_values[0] = 0; - m_values[1] = 0; - m_values[2] = 0; - } - u32_to_u16_iterator(BaseIterator b) : m_position(b), m_current(2) - { - m_values[0] = 0; - m_values[1] = 0; - m_values[2] = 0; - } -private: - - void extract_current()const - { - // begin by checking for a code point out of range: - ::boost::uint32_t v = *m_position; - if(v >= 0x10000u) - { - if(v > 0x10FFFFu) - detail::invalid_utf32_code_point(*m_position); - // split into two surrogates: - m_values[0] = static_cast<U16Type>(v >> 10) + detail::high_surrogate_base; - m_values[1] = static_cast<U16Type>(v & detail::ten_bit_mask) + detail::low_surrogate_base; - m_current = 0; - BOOST_REGEX_ASSERT(detail::is_high_surrogate(m_values[0])); - BOOST_REGEX_ASSERT(detail::is_low_surrogate(m_values[1])); - } - else - { - // 16-bit code point: - m_values[0] = static_cast<U16Type>(*m_position); - m_values[1] = 0; - m_current = 0; - // value must not be a surrogate: - if(detail::is_surrogate(m_values[0])) - detail::invalid_utf32_code_point(*m_position); - } - } - BaseIterator m_position; - mutable U16Type m_values[3]; - mutable unsigned m_current; -}; - -template <class BaseIterator, class U32Type = ::boost::uint32_t> -class u16_to_u32_iterator -{ - // special values for pending iterator reads: - BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu); - -#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) - typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type; - - BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 16); - BOOST_STATIC_ASSERT(sizeof(U32Type)*CHAR_BIT == 32); -#endif - -public: - typedef std::ptrdiff_t difference_type; - typedef U32Type value_type; - typedef value_type const* pointer; - typedef value_type const reference; - typedef std::bidirectional_iterator_tag iterator_category; - - reference operator*()const - { - if(m_value == pending_read) - extract_current(); - return m_value; - } - bool operator==(const u16_to_u32_iterator& that)const - { - return m_position == that.m_position; - } - bool operator!=(const u16_to_u32_iterator& that)const - { - return !(*this == that); - } - u16_to_u32_iterator& operator++() - { - // skip high surrogate first if there is one: - if(detail::is_high_surrogate(*m_position)) ++m_position; - ++m_position; - m_value = pending_read; - return *this; - } - u16_to_u32_iterator operator++(int) - { - u16_to_u32_iterator r(*this); - ++(*this); - return r; - } - u16_to_u32_iterator& operator--() - { - --m_position; - // if we have a low surrogate then go back one more: - if(detail::is_low_surrogate(*m_position)) - --m_position; - m_value = pending_read; - return *this; - } - u16_to_u32_iterator operator--(int) - { - u16_to_u32_iterator r(*this); - --(*this); - return r; - } - BaseIterator base()const - { - return m_position; - } - // construct: - u16_to_u32_iterator() : m_position() - { - m_value = pending_read; - } - u16_to_u32_iterator(BaseIterator b) : m_position(b) - { - m_value = pending_read; - } - // - // Range checked version: - // - u16_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b) - { - m_value = pending_read; - // - // The range must not start with a low surrogate, or end in a high surrogate, - // otherwise we run the risk of running outside the underlying input range. - // Likewise b must not be located at a low surrogate. - // - boost::uint16_t val; - if(start != end) - { - if((b != start) && (b != end)) - { - val = *b; - if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u)) - invalid_code_point(val); - } - val = *start; - if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u)) - invalid_code_point(val); - val = *--end; - if(detail::is_high_surrogate(val)) - invalid_code_point(val); - } - } -private: - static void invalid_code_point(::boost::uint16_t val) - { -#ifndef BOOST_NO_STD_LOCALE - std::stringstream ss; - ss << "Misplaced UTF-16 surrogate U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-32 sequence"; - std::out_of_range e(ss.str()); -#else - std::out_of_range e("Misplaced UTF-16 surrogate encountered while trying to encode UTF-32 sequence"); -#endif - boost::throw_exception(e); - } - void extract_current()const - { - m_value = static_cast<U32Type>(static_cast< ::boost::uint16_t>(*m_position)); - // if the last value is a high surrogate then adjust m_position and m_value as needed: - if(detail::is_high_surrogate(*m_position)) - { - // precondition; next value must have be a low-surrogate: - BaseIterator next(m_position); - ::boost::uint16_t t = *++next; - if((t & 0xFC00u) != 0xDC00u) - invalid_code_point(t); - m_value = (m_value - detail::high_surrogate_base) << 10; - m_value |= (static_cast<U32Type>(static_cast< ::boost::uint16_t>(t)) & detail::ten_bit_mask); - } - // postcondition; result must not be a surrogate: - if(detail::is_surrogate(m_value)) - invalid_code_point(static_cast< ::boost::uint16_t>(m_value)); - } - BaseIterator m_position; - mutable U32Type m_value; -}; - -template <class BaseIterator, class U8Type = ::boost::uint8_t> -class u32_to_u8_iterator -{ -#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) - typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type; - - BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 32); - BOOST_STATIC_ASSERT(sizeof(U8Type)*CHAR_BIT == 8); -#endif - -public: - typedef std::ptrdiff_t difference_type; - typedef U8Type value_type; - typedef value_type const* pointer; - typedef value_type const reference; - typedef std::bidirectional_iterator_tag iterator_category; - - reference operator*()const - { - if(m_current == 4) - extract_current(); - return m_values[m_current]; - } - bool operator==(const u32_to_u8_iterator& that)const - { - if(m_position == that.m_position) - { - // either the m_current's must be equal, or one must be 0 and - // the other 4: which means neither must have bits 1 or 2 set: - return (m_current == that.m_current) - || (((m_current | that.m_current) & 3) == 0); - } - return false; - } - bool operator!=(const u32_to_u8_iterator& that)const - { - return !(*this == that); - } - u32_to_u8_iterator& operator++() - { - // if we have a pending read then read now, so that we know whether - // to skip a position, or move to a low-surrogate: - if(m_current == 4) - { - // pending read: - extract_current(); - } - // move to the next surrogate position: - ++m_current; - // if we've reached the end skip a position: - if(m_values[m_current] == 0) - { - m_current = 4; - ++m_position; - } - return *this; - } - u32_to_u8_iterator operator++(int) - { - u32_to_u8_iterator r(*this); - ++(*this); - return r; - } - u32_to_u8_iterator& operator--() - { - if((m_current & 3) == 0) - { - --m_position; - extract_current(); - m_current = 3; - while(m_current && (m_values[m_current] == 0)) - --m_current; - } - else - --m_current; - return *this; - } - u32_to_u8_iterator operator--(int) - { - u32_to_u8_iterator r(*this); - --(*this); - return r; - } - BaseIterator base()const - { - return m_position; - } - // construct: - u32_to_u8_iterator() : m_position(), m_current(0) - { - m_values[0] = 0; - m_values[1] = 0; - m_values[2] = 0; - m_values[3] = 0; - m_values[4] = 0; - } - u32_to_u8_iterator(BaseIterator b) : m_position(b), m_current(4) - { - m_values[0] = 0; - m_values[1] = 0; - m_values[2] = 0; - m_values[3] = 0; - m_values[4] = 0; - } -private: - - void extract_current()const - { - boost::uint32_t c = *m_position; - if(c > 0x10FFFFu) - detail::invalid_utf32_code_point(c); - if(c < 0x80u) - { - m_values[0] = static_cast<unsigned char>(c); - m_values[1] = static_cast<unsigned char>(0u); - m_values[2] = static_cast<unsigned char>(0u); - m_values[3] = static_cast<unsigned char>(0u); - } - else if(c < 0x800u) - { - m_values[0] = static_cast<unsigned char>(0xC0u + (c >> 6)); - m_values[1] = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - m_values[2] = static_cast<unsigned char>(0u); - m_values[3] = static_cast<unsigned char>(0u); - } - else if(c < 0x10000u) - { - m_values[0] = static_cast<unsigned char>(0xE0u + (c >> 12)); - m_values[1] = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu)); - m_values[2] = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - m_values[3] = static_cast<unsigned char>(0u); - } - else - { - m_values[0] = static_cast<unsigned char>(0xF0u + (c >> 18)); - m_values[1] = static_cast<unsigned char>(0x80u + ((c >> 12) & 0x3Fu)); - m_values[2] = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu)); - m_values[3] = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - } - m_current= 0; - } - BaseIterator m_position; - mutable U8Type m_values[5]; - mutable unsigned m_current; -}; - -template <class BaseIterator, class U32Type = ::boost::uint32_t> -class u8_to_u32_iterator -{ - // special values for pending iterator reads: - BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu); - -#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) - typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type; - - BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 8); - BOOST_STATIC_ASSERT(sizeof(U32Type)*CHAR_BIT == 32); -#endif - -public: - typedef std::ptrdiff_t difference_type; - typedef U32Type value_type; - typedef value_type const* pointer; - typedef value_type const reference; - typedef std::bidirectional_iterator_tag iterator_category; - - reference operator*()const - { - if(m_value == pending_read) - extract_current(); - return m_value; - } - bool operator==(const u8_to_u32_iterator& that)const - { - return m_position == that.m_position; - } - bool operator!=(const u8_to_u32_iterator& that)const - { - return !(*this == that); - } - u8_to_u32_iterator& operator++() - { - // We must not start with a continuation character: - if((static_cast<boost::uint8_t>(*m_position) & 0xC0) == 0x80) - invalid_sequence(); - // skip high surrogate first if there is one: - unsigned c = detail::utf8_byte_count(*m_position); - if(m_value == pending_read) - { - // Since we haven't read in a value, we need to validate the code points: - for(unsigned i = 0; i < c; ++i) - { - ++m_position; - // We must have a continuation byte: - if((i != c - 1) && ((static_cast<boost::uint8_t>(*m_position) & 0xC0) != 0x80)) - invalid_sequence(); - } - } - else - { - std::advance(m_position, c); - } - m_value = pending_read; - return *this; - } - u8_to_u32_iterator operator++(int) - { - u8_to_u32_iterator r(*this); - ++(*this); - return r; - } - u8_to_u32_iterator& operator--() - { - // Keep backtracking until we don't have a trailing character: - unsigned count = 0; - while((*--m_position & 0xC0u) == 0x80u) ++count; - // now check that the sequence was valid: - if(count != detail::utf8_trailing_byte_count(*m_position)) - invalid_sequence(); - m_value = pending_read; - return *this; - } - u8_to_u32_iterator operator--(int) - { - u8_to_u32_iterator r(*this); - --(*this); - return r; - } - BaseIterator base()const - { - return m_position; - } - // construct: - u8_to_u32_iterator() : m_position() - { - m_value = pending_read; - } - u8_to_u32_iterator(BaseIterator b) : m_position(b) - { - m_value = pending_read; - } - // - // Checked constructor: - // - u8_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b) - { - m_value = pending_read; - // - // We must not start with a continuation character, or end with a - // truncated UTF-8 sequence otherwise we run the risk of going past - // the start/end of the underlying sequence: - // - if(start != end) - { - unsigned char v = *start; - if((v & 0xC0u) == 0x80u) - invalid_sequence(); - if((b != start) && (b != end) && ((*b & 0xC0u) == 0x80u)) - invalid_sequence(); - BaseIterator pos = end; - do - { - v = *--pos; - } - while((start != pos) && ((v & 0xC0u) == 0x80u)); - std::ptrdiff_t extra = detail::utf8_byte_count(v); - if(std::distance(pos, end) < extra) - invalid_sequence(); - } - } -private: - static void invalid_sequence() - { - std::out_of_range e("Invalid UTF-8 sequence encountered while trying to encode UTF-32 character"); - boost::throw_exception(e); - } - void extract_current()const - { - m_value = static_cast<U32Type>(static_cast< ::boost::uint8_t>(*m_position)); - // we must not have a continuation character: - if((m_value & 0xC0u) == 0x80u) - invalid_sequence(); - // see how many extra bytes we have: - unsigned extra = detail::utf8_trailing_byte_count(*m_position); - // extract the extra bits, 6 from each extra byte: - BaseIterator next(m_position); - for(unsigned c = 0; c < extra; ++c) - { - ++next; - m_value <<= 6; - // We must have a continuation byte: - if((static_cast<boost::uint8_t>(*next) & 0xC0) != 0x80) - invalid_sequence(); - m_value += static_cast<boost::uint8_t>(*next) & 0x3Fu; - } - // we now need to remove a few of the leftmost bits, but how many depends - // upon how many extra bytes we've extracted: - static const boost::uint32_t masks[4] = - { - 0x7Fu, - 0x7FFu, - 0xFFFFu, - 0x1FFFFFu, - }; - m_value &= masks[extra]; - // check the result is in range: - if(m_value > static_cast<U32Type>(0x10FFFFu)) - invalid_sequence(); - // The result must not be a surrogate: - if((m_value >= static_cast<U32Type>(0xD800)) && (m_value <= static_cast<U32Type>(0xDFFF))) - invalid_sequence(); - // We should not have had an invalidly encoded UTF8 sequence: - if((extra > 0) && (m_value <= static_cast<U32Type>(masks[extra - 1]))) - invalid_sequence(); - } - BaseIterator m_position; - mutable U32Type m_value; -}; - -template <class BaseIterator> -class utf16_output_iterator -{ -public: - typedef void difference_type; - typedef void value_type; - typedef boost::uint32_t* pointer; - typedef boost::uint32_t& reference; - typedef std::output_iterator_tag iterator_category; - - utf16_output_iterator(const BaseIterator& b) - : m_position(b){} - utf16_output_iterator(const utf16_output_iterator& that) - : m_position(that.m_position){} - utf16_output_iterator& operator=(const utf16_output_iterator& that) - { - m_position = that.m_position; - return *this; - } - const utf16_output_iterator& operator*()const - { - return *this; - } - void operator=(boost::uint32_t val)const - { - push(val); - } - utf16_output_iterator& operator++() - { - return *this; - } - utf16_output_iterator& operator++(int) - { - return *this; - } - BaseIterator base()const - { - return m_position; - } -private: - void push(boost::uint32_t v)const - { - if(v >= 0x10000u) - { - // begin by checking for a code point out of range: - if(v > 0x10FFFFu) - detail::invalid_utf32_code_point(v); - // split into two surrogates: - *m_position++ = static_cast<boost::uint16_t>(v >> 10) + detail::high_surrogate_base; - *m_position++ = static_cast<boost::uint16_t>(v & detail::ten_bit_mask) + detail::low_surrogate_base; - } - else - { - // 16-bit code point: - // value must not be a surrogate: - if(detail::is_surrogate(v)) - detail::invalid_utf32_code_point(v); - *m_position++ = static_cast<boost::uint16_t>(v); - } - } - mutable BaseIterator m_position; -}; - -template <class BaseIterator> -class utf8_output_iterator -{ -public: - typedef void difference_type; - typedef void value_type; - typedef boost::uint32_t* pointer; - typedef boost::uint32_t& reference; - typedef std::output_iterator_tag iterator_category; - - utf8_output_iterator(const BaseIterator& b) - : m_position(b){} - utf8_output_iterator(const utf8_output_iterator& that) - : m_position(that.m_position){} - utf8_output_iterator& operator=(const utf8_output_iterator& that) - { - m_position = that.m_position; - return *this; - } - const utf8_output_iterator& operator*()const - { - return *this; - } - void operator=(boost::uint32_t val)const - { - push(val); - } - utf8_output_iterator& operator++() - { - return *this; - } - utf8_output_iterator& operator++(int) - { - return *this; - } - BaseIterator base()const - { - return m_position; - } -private: - void push(boost::uint32_t c)const - { - if(c > 0x10FFFFu) - detail::invalid_utf32_code_point(c); - if(c < 0x80u) - { - *m_position++ = static_cast<unsigned char>(c); - } - else if(c < 0x800u) - { - *m_position++ = static_cast<unsigned char>(0xC0u + (c >> 6)); - *m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - } - else if(c < 0x10000u) - { - *m_position++ = static_cast<unsigned char>(0xE0u + (c >> 12)); - *m_position++ = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu)); - *m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - } - else - { - *m_position++ = static_cast<unsigned char>(0xF0u + (c >> 18)); - *m_position++ = static_cast<unsigned char>(0x80u + ((c >> 12) & 0x3Fu)); - *m_position++ = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu)); - *m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - } - } - mutable BaseIterator m_position; -}; - -} // namespace boost - -#endif // BOOST_REGEX_UNICODE_ITERATOR_HPP - diff --git a/contrib/restricted/boost/regex/include/boost/regex/v5/icu.hpp b/contrib/restricted/boost/regex/include/boost/regex/v5/icu.hpp deleted file mode 100644 index aefd97684a..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/v5/icu.hpp +++ /dev/null @@ -1,1402 +0,0 @@ -/* - * - * Copyright (c) 2004 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE icu.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Unicode regular expressions on top of the ICU Library. - */ - -#ifndef BOOST_REGEX_ICU_V5_HPP -#define BOOST_REGEX_ICU_V5_HPP - -#include <unicode/utypes.h> -#include <unicode/uchar.h> -#include <unicode/coll.h> -#include <type_traits> -#include <functional> -#include <boost/regex.hpp> -#include <boost/regex/v5/unicode_iterator.hpp> - -#ifdef BOOST_REGEX_MSVC -#pragma warning (push) -#pragma warning (disable: 4251) -#endif - -namespace boost{ - -namespace BOOST_REGEX_DETAIL_NS{ - -// -// Implementation details: -// -class icu_regex_traits_implementation -{ - typedef UChar32 char_type; - typedef std::size_t size_type; - typedef std::vector<char_type> string_type; - typedef U_NAMESPACE_QUALIFIER Locale locale_type; - typedef std::uint_least32_t char_class_type; -public: - icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& l) - : m_locale(l) - { - UErrorCode success = U_ZERO_ERROR; - m_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success)); - if(U_SUCCESS(success) == 0) - init_error(); - m_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::IDENTICAL); - success = U_ZERO_ERROR; - m_primary_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success)); - if(U_SUCCESS(success) == 0) - init_error(); - m_primary_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::PRIMARY); - } - U_NAMESPACE_QUALIFIER Locale getloc()const - { - return m_locale; - } - string_type do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const - { - // TODO make thread safe!!!! : - typedef u32_to_u16_iterator<const char_type*, ::UChar> itt; - itt i(p1), j(p2); - std::vector< ::UChar> t(i, j); - std::uint8_t result[100]; - std::int32_t len; - if (!t.empty()) - len = pcoll->getSortKey(&*t.begin(), static_cast<std::int32_t>(t.size()), result, sizeof(result)); - else - len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast<std::int32_t>(0), result, sizeof(result)); - if (std::size_t(len) > sizeof(result)) - { - std::unique_ptr< std::uint8_t[]> presult(new ::uint8_t[len + 1]); - if (!t.empty()) - len = pcoll->getSortKey(&*t.begin(), static_cast<std::int32_t>(t.size()), presult.get(), len + 1); - else - len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast<std::int32_t>(0), presult.get(), len + 1); - if ((0 == presult[len - 1]) && (len > 1)) - --len; - return string_type(presult.get(), presult.get() + len); - } - if ((0 == result[len - 1]) && (len > 1)) - --len; - return string_type(result, result + len); - } - string_type transform(const char_type* p1, const char_type* p2) const - { - return do_transform(p1, p2, m_collator.get()); - } - string_type transform_primary(const char_type* p1, const char_type* p2) const - { - return do_transform(p1, p2, m_primary_collator.get()); - } -private: - void init_error() - { - std::runtime_error e("Could not initialize ICU resources"); -#ifndef BOOST_REGEX_STANDALONE - boost::throw_exception(e); -#else - throw e; -#endif - } - U_NAMESPACE_QUALIFIER Locale m_locale; // The ICU locale that we're using - std::unique_ptr< U_NAMESPACE_QUALIFIER Collator> m_collator; // The full collation object - std::unique_ptr< U_NAMESPACE_QUALIFIER Collator> m_primary_collator; // The primary collation object -}; -inline std::shared_ptr<icu_regex_traits_implementation> get_icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& loc) -{ - return std::shared_ptr<icu_regex_traits_implementation>(new icu_regex_traits_implementation(loc)); -} - -} - -class icu_regex_traits -{ -public: - typedef UChar32 char_type; - typedef std::size_t size_type; - typedef std::vector<char_type> string_type; - typedef U_NAMESPACE_QUALIFIER Locale locale_type; - typedef std::uint64_t char_class_type; - - struct boost_extensions_tag{}; - - icu_regex_traits() - : m_pimpl(BOOST_REGEX_DETAIL_NS::get_icu_regex_traits_implementation(U_NAMESPACE_QUALIFIER Locale())) - { - } - static size_type length(const char_type* p) - { - size_type result = 0; - while (*p) - { - ++p; - ++result; - } - return result; - } - - ::boost::regex_constants::syntax_type syntax_type(char_type c)const - { - return ((c < 0x7f) && (c > 0)) ? BOOST_REGEX_DETAIL_NS::get_default_syntax_type(static_cast<char>(c)) : regex_constants::syntax_char; - } - ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c) const - { - return ((c < 0x7f) && (c > 0)) ? BOOST_REGEX_DETAIL_NS::get_default_escape_syntax_type(static_cast<char>(c)) : regex_constants::syntax_char; - } - char_type translate(char_type c) const - { - return c; - } - char_type translate_nocase(char_type c) const - { - return ::u_foldCase(c, U_FOLD_CASE_DEFAULT); - } - char_type translate(char_type c, bool icase) const - { - return icase ? translate_nocase(c) : translate(c); - } - char_type tolower(char_type c) const - { - return ::u_tolower(c); - } - char_type toupper(char_type c) const - { - return ::u_toupper(c); - } - string_type transform(const char_type* p1, const char_type* p2) const - { - return m_pimpl->transform(p1, p2); - } - string_type transform_primary(const char_type* p1, const char_type* p2) const - { - return m_pimpl->transform_primary(p1, p2); - } - char_class_type lookup_classname(const char_type* p1, const char_type* p2) const - { - constexpr char_class_type mask_blank = char_class_type(1) << offset_blank; - constexpr char_class_type mask_space = char_class_type(1) << offset_space; - constexpr char_class_type mask_xdigit = char_class_type(1) << offset_xdigit; - constexpr char_class_type mask_underscore = char_class_type(1) << offset_underscore; - constexpr char_class_type mask_unicode = char_class_type(1) << offset_unicode; - //constexpr char_class_type mask_any = char_class_type(1) << offset_any; - //constexpr char_class_type mask_ascii = char_class_type(1) << offset_ascii; - constexpr char_class_type mask_horizontal = char_class_type(1) << offset_horizontal; - constexpr char_class_type mask_vertical = char_class_type(1) << offset_vertical; - - static const char_class_type masks[] = - { - 0, - U_GC_L_MASK | U_GC_ND_MASK, - U_GC_L_MASK, - mask_blank, - U_GC_CC_MASK | U_GC_CF_MASK | U_GC_ZL_MASK | U_GC_ZP_MASK, - U_GC_ND_MASK, - U_GC_ND_MASK, - (0x3FFFFFFFu) & ~(U_GC_CC_MASK | U_GC_CF_MASK | U_GC_CS_MASK | U_GC_CN_MASK | U_GC_Z_MASK), - mask_horizontal, - U_GC_LL_MASK, - U_GC_LL_MASK, - ~(U_GC_C_MASK), - U_GC_P_MASK, - char_class_type(U_GC_Z_MASK) | mask_space, - char_class_type(U_GC_Z_MASK) | mask_space, - U_GC_LU_MASK, - mask_unicode, - U_GC_LU_MASK, - mask_vertical, - char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore, - char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore, - char_class_type(U_GC_ND_MASK) | mask_xdigit, - }; - - int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2); - if (idx >= 0) - return masks[idx + 1]; - char_class_type result = lookup_icu_mask(p1, p2); - if (result != 0) - return result; - - if (idx < 0) - { - string_type s(p1, p2); - string_type::size_type i = 0; - while (i < s.size()) - { - s[i] = static_cast<char>((::u_tolower)(s[i])); - if (::u_isspace(s[i]) || (s[i] == '-') || (s[i] == '_')) - s.erase(s.begin() + i, s.begin() + i + 1); - else - { - s[i] = static_cast<char>((::u_tolower)(s[i])); - ++i; - } - } - if (!s.empty()) - idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); - if (idx >= 0) - return masks[idx + 1]; - if (!s.empty()) - result = lookup_icu_mask(&*s.begin(), &*s.begin() + s.size()); - if (result != 0) - return result; - } - BOOST_REGEX_ASSERT(std::size_t(idx + 1) < sizeof(masks) / sizeof(masks[0])); - return masks[idx + 1]; - } - string_type lookup_collatename(const char_type* p1, const char_type* p2) const - { - string_type result; - if (std::find_if(p1, p2, std::bind(std::greater< ::UChar32>(), std::placeholders::_1, 0x7f)) == p2) - { - std::string s(p1, p2); - // Try Unicode name: - UErrorCode err = U_ZERO_ERROR; - UChar32 c = ::u_charFromName(U_UNICODE_CHAR_NAME, s.c_str(), &err); - if (U_SUCCESS(err)) - { - result.push_back(c); - return result; - } - // Try Unicode-extended name: - err = U_ZERO_ERROR; - c = ::u_charFromName(U_EXTENDED_CHAR_NAME, s.c_str(), &err); - if (U_SUCCESS(err)) - { - result.push_back(c); - return result; - } - // try POSIX name: - s = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(s); - result.assign(s.begin(), s.end()); - } - if (result.empty() && (p2 - p1 == 1)) - result.push_back(*p1); - return result; - } - bool isctype(char_type c, char_class_type f) const - { - constexpr char_class_type mask_blank = char_class_type(1) << offset_blank; - constexpr char_class_type mask_space = char_class_type(1) << offset_space; - constexpr char_class_type mask_xdigit = char_class_type(1) << offset_xdigit; - constexpr char_class_type mask_underscore = char_class_type(1) << offset_underscore; - constexpr char_class_type mask_unicode = char_class_type(1) << offset_unicode; - constexpr char_class_type mask_any = char_class_type(1) << offset_any; - constexpr char_class_type mask_ascii = char_class_type(1) << offset_ascii; - constexpr char_class_type mask_horizontal = char_class_type(1) << offset_horizontal; - constexpr char_class_type mask_vertical = char_class_type(1) << offset_vertical; - - // check for standard catagories first: - char_class_type m = char_class_type(static_cast<char_class_type>(1) << u_charType(c)); - if ((m & f) != 0) - return true; - // now check for special cases: - if (((f & mask_blank) != 0) && u_isblank(c)) - return true; - if (((f & mask_space) != 0) && u_isspace(c)) - return true; - if (((f & mask_xdigit) != 0) && (u_digit(c, 16) >= 0)) - return true; - if (((f & mask_unicode) != 0) && (c >= 0x100)) - return true; - if (((f & mask_underscore) != 0) && (c == '_')) - return true; - if (((f & mask_any) != 0) && (c <= 0x10FFFF)) - return true; - if (((f & mask_ascii) != 0) && (c <= 0x7F)) - return true; - if (((f & mask_vertical) != 0) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == static_cast<char_type>('\v')) || (m == U_GC_ZL_MASK) || (m == U_GC_ZP_MASK))) - return true; - if (((f & mask_horizontal) != 0) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && u_isspace(c) && (c != static_cast<char_type>('\v'))) - return true; - return false; - } - std::intmax_t toi(const char_type*& p1, const char_type* p2, int radix)const - { - return BOOST_REGEX_DETAIL_NS::global_toi(p1, p2, radix, *this); - } - int value(char_type c, int radix)const - { - return u_digit(c, static_cast< std::int8_t>(radix)); - } - locale_type imbue(locale_type l) - { - locale_type result(m_pimpl->getloc()); - m_pimpl = BOOST_REGEX_DETAIL_NS::get_icu_regex_traits_implementation(l); - return result; - } - locale_type getloc()const - { - return locale_type(); - } - std::string error_string(::boost::regex_constants::error_type n) const - { - return BOOST_REGEX_DETAIL_NS::get_default_error_string(n); - } -private: - icu_regex_traits(const icu_regex_traits&); - icu_regex_traits& operator=(const icu_regex_traits&); - - // - // define the bitmasks offsets we need for additional character properties: - // - enum{ - offset_blank = U_CHAR_CATEGORY_COUNT, - offset_space = U_CHAR_CATEGORY_COUNT+1, - offset_xdigit = U_CHAR_CATEGORY_COUNT+2, - offset_underscore = U_CHAR_CATEGORY_COUNT+3, - offset_unicode = U_CHAR_CATEGORY_COUNT+4, - offset_any = U_CHAR_CATEGORY_COUNT+5, - offset_ascii = U_CHAR_CATEGORY_COUNT+6, - offset_horizontal = U_CHAR_CATEGORY_COUNT+7, - offset_vertical = U_CHAR_CATEGORY_COUNT+8 - }; - - static char_class_type lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2) - { - //constexpr char_class_type mask_blank = char_class_type(1) << offset_blank; - //constexpr char_class_type mask_space = char_class_type(1) << offset_space; - //constexpr char_class_type mask_xdigit = char_class_type(1) << offset_xdigit; - //constexpr char_class_type mask_underscore = char_class_type(1) << offset_underscore; - //constexpr char_class_type mask_unicode = char_class_type(1) << offset_unicode; - constexpr char_class_type mask_any = char_class_type(1) << offset_any; - constexpr char_class_type mask_ascii = char_class_type(1) << offset_ascii; - //constexpr char_class_type mask_horizontal = char_class_type(1) << offset_horizontal; - //constexpr char_class_type mask_vertical = char_class_type(1) << offset_vertical; - - static const ::UChar32 prop_name_table[] = { - /* any */ 'a', 'n', 'y', - /* ascii */ 'a', 's', 'c', 'i', 'i', - /* assigned */ 'a', 's', 's', 'i', 'g', 'n', 'e', 'd', - /* c* */ 'c', '*', - /* cc */ 'c', 'c', - /* cf */ 'c', 'f', - /* closepunctuation */ 'c', 'l', 'o', 's', 'e', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* cn */ 'c', 'n', - /* co */ 'c', 'o', - /* connectorpunctuation */ 'c', 'o', 'n', 'n', 'e', 'c', 't', 'o', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* control */ 'c', 'o', 'n', 't', 'r', 'o', 'l', - /* cs */ 'c', 's', - /* currencysymbol */ 'c', 'u', 'r', 'r', 'e', 'n', 'c', 'y', 's', 'y', 'm', 'b', 'o', 'l', - /* dashpunctuation */ 'd', 'a', 's', 'h', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* decimaldigitnumber */ 'd', 'e', 'c', 'i', 'm', 'a', 'l', 'd', 'i', 'g', 'i', 't', 'n', 'u', 'm', 'b', 'e', 'r', - /* enclosingmark */ 'e', 'n', 'c', 'l', 'o', 's', 'i', 'n', 'g', 'm', 'a', 'r', 'k', - /* finalpunctuation */ 'f', 'i', 'n', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* format */ 'f', 'o', 'r', 'm', 'a', 't', - /* initialpunctuation */ 'i', 'n', 'i', 't', 'i', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* l* */ 'l', '*', - /* letter */ 'l', 'e', 't', 't', 'e', 'r', - /* letternumber */ 'l', 'e', 't', 't', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r', - /* lineseparator */ 'l', 'i', 'n', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', - /* ll */ 'l', 'l', - /* lm */ 'l', 'm', - /* lo */ 'l', 'o', - /* lowercaseletter */ 'l', 'o', 'w', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', - /* lt */ 'l', 't', - /* lu */ 'l', 'u', - /* m* */ 'm', '*', - /* mark */ 'm', 'a', 'r', 'k', - /* mathsymbol */ 'm', 'a', 't', 'h', 's', 'y', 'm', 'b', 'o', 'l', - /* mc */ 'm', 'c', - /* me */ 'm', 'e', - /* mn */ 'm', 'n', - /* modifierletter */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r', - /* modifiersymbol */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l', - /* n* */ 'n', '*', - /* nd */ 'n', 'd', - /* nl */ 'n', 'l', - /* no */ 'n', 'o', - /* nonspacingmark */ 'n', 'o', 'n', 's', 'p', 'a', 'c', 'i', 'n', 'g', 'm', 'a', 'r', 'k', - /* notassigned */ 'n', 'o', 't', 'a', 's', 's', 'i', 'g', 'n', 'e', 'd', - /* number */ 'n', 'u', 'm', 'b', 'e', 'r', - /* openpunctuation */ 'o', 'p', 'e', 'n', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* other */ 'o', 't', 'h', 'e', 'r', - /* otherletter */ 'o', 't', 'h', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r', - /* othernumber */ 'o', 't', 'h', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r', - /* otherpunctuation */ 'o', 't', 'h', 'e', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* othersymbol */ 'o', 't', 'h', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l', - /* p* */ 'p', '*', - /* paragraphseparator */ 'p', 'a', 'r', 'a', 'g', 'r', 'a', 'p', 'h', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', - /* pc */ 'p', 'c', - /* pd */ 'p', 'd', - /* pe */ 'p', 'e', - /* pf */ 'p', 'f', - /* pi */ 'p', 'i', - /* po */ 'p', 'o', - /* privateuse */ 'p', 'r', 'i', 'v', 'a', 't', 'e', 'u', 's', 'e', - /* ps */ 'p', 's', - /* punctuation */ 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', - /* s* */ 's', '*', - /* sc */ 's', 'c', - /* separator */ 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', - /* sk */ 's', 'k', - /* sm */ 's', 'm', - /* so */ 's', 'o', - /* spaceseparator */ 's', 'p', 'a', 'c', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', - /* spacingcombiningmark */ 's', 'p', 'a', 'c', 'i', 'n', 'g', 'c', 'o', 'm', 'b', 'i', 'n', 'i', 'n', 'g', 'm', 'a', 'r', 'k', - /* surrogate */ 's', 'u', 'r', 'r', 'o', 'g', 'a', 't', 'e', - /* symbol */ 's', 'y', 'm', 'b', 'o', 'l', - /* titlecase */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e', - /* titlecaseletter */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', - /* uppercaseletter */ 'u', 'p', 'p', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', - /* z* */ 'z', '*', - /* zl */ 'z', 'l', - /* zp */ 'z', 'p', - /* zs */ 'z', 's', - }; - - static const BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32> range_data[] = { - { prop_name_table + 0, prop_name_table + 3, }, // any - { prop_name_table + 3, prop_name_table + 8, }, // ascii - { prop_name_table + 8, prop_name_table + 16, }, // assigned - { prop_name_table + 16, prop_name_table + 18, }, // c* - { prop_name_table + 18, prop_name_table + 20, }, // cc - { prop_name_table + 20, prop_name_table + 22, }, // cf - { prop_name_table + 22, prop_name_table + 38, }, // closepunctuation - { prop_name_table + 38, prop_name_table + 40, }, // cn - { prop_name_table + 40, prop_name_table + 42, }, // co - { prop_name_table + 42, prop_name_table + 62, }, // connectorpunctuation - { prop_name_table + 62, prop_name_table + 69, }, // control - { prop_name_table + 69, prop_name_table + 71, }, // cs - { prop_name_table + 71, prop_name_table + 85, }, // currencysymbol - { prop_name_table + 85, prop_name_table + 100, }, // dashpunctuation - { prop_name_table + 100, prop_name_table + 118, }, // decimaldigitnumber - { prop_name_table + 118, prop_name_table + 131, }, // enclosingmark - { prop_name_table + 131, prop_name_table + 147, }, // finalpunctuation - { prop_name_table + 147, prop_name_table + 153, }, // format - { prop_name_table + 153, prop_name_table + 171, }, // initialpunctuation - { prop_name_table + 171, prop_name_table + 173, }, // l* - { prop_name_table + 173, prop_name_table + 179, }, // letter - { prop_name_table + 179, prop_name_table + 191, }, // letternumber - { prop_name_table + 191, prop_name_table + 204, }, // lineseparator - { prop_name_table + 204, prop_name_table + 206, }, // ll - { prop_name_table + 206, prop_name_table + 208, }, // lm - { prop_name_table + 208, prop_name_table + 210, }, // lo - { prop_name_table + 210, prop_name_table + 225, }, // lowercaseletter - { prop_name_table + 225, prop_name_table + 227, }, // lt - { prop_name_table + 227, prop_name_table + 229, }, // lu - { prop_name_table + 229, prop_name_table + 231, }, // m* - { prop_name_table + 231, prop_name_table + 235, }, // mark - { prop_name_table + 235, prop_name_table + 245, }, // mathsymbol - { prop_name_table + 245, prop_name_table + 247, }, // mc - { prop_name_table + 247, prop_name_table + 249, }, // me - { prop_name_table + 249, prop_name_table + 251, }, // mn - { prop_name_table + 251, prop_name_table + 265, }, // modifierletter - { prop_name_table + 265, prop_name_table + 279, }, // modifiersymbol - { prop_name_table + 279, prop_name_table + 281, }, // n* - { prop_name_table + 281, prop_name_table + 283, }, // nd - { prop_name_table + 283, prop_name_table + 285, }, // nl - { prop_name_table + 285, prop_name_table + 287, }, // no - { prop_name_table + 287, prop_name_table + 301, }, // nonspacingmark - { prop_name_table + 301, prop_name_table + 312, }, // notassigned - { prop_name_table + 312, prop_name_table + 318, }, // number - { prop_name_table + 318, prop_name_table + 333, }, // openpunctuation - { prop_name_table + 333, prop_name_table + 338, }, // other - { prop_name_table + 338, prop_name_table + 349, }, // otherletter - { prop_name_table + 349, prop_name_table + 360, }, // othernumber - { prop_name_table + 360, prop_name_table + 376, }, // otherpunctuation - { prop_name_table + 376, prop_name_table + 387, }, // othersymbol - { prop_name_table + 387, prop_name_table + 389, }, // p* - { prop_name_table + 389, prop_name_table + 407, }, // paragraphseparator - { prop_name_table + 407, prop_name_table + 409, }, // pc - { prop_name_table + 409, prop_name_table + 411, }, // pd - { prop_name_table + 411, prop_name_table + 413, }, // pe - { prop_name_table + 413, prop_name_table + 415, }, // pf - { prop_name_table + 415, prop_name_table + 417, }, // pi - { prop_name_table + 417, prop_name_table + 419, }, // po - { prop_name_table + 419, prop_name_table + 429, }, // privateuse - { prop_name_table + 429, prop_name_table + 431, }, // ps - { prop_name_table + 431, prop_name_table + 442, }, // punctuation - { prop_name_table + 442, prop_name_table + 444, }, // s* - { prop_name_table + 444, prop_name_table + 446, }, // sc - { prop_name_table + 446, prop_name_table + 455, }, // separator - { prop_name_table + 455, prop_name_table + 457, }, // sk - { prop_name_table + 457, prop_name_table + 459, }, // sm - { prop_name_table + 459, prop_name_table + 461, }, // so - { prop_name_table + 461, prop_name_table + 475, }, // spaceseparator - { prop_name_table + 475, prop_name_table + 495, }, // spacingcombiningmark - { prop_name_table + 495, prop_name_table + 504, }, // surrogate - { prop_name_table + 504, prop_name_table + 510, }, // symbol - { prop_name_table + 510, prop_name_table + 519, }, // titlecase - { prop_name_table + 519, prop_name_table + 534, }, // titlecaseletter - { prop_name_table + 534, prop_name_table + 549, }, // uppercaseletter - { prop_name_table + 549, prop_name_table + 551, }, // z* - { prop_name_table + 551, prop_name_table + 553, }, // zl - { prop_name_table + 553, prop_name_table + 555, }, // zp - { prop_name_table + 555, prop_name_table + 557, }, // zs - }; - - static const icu_regex_traits::char_class_type icu_class_map[] = { - mask_any, // any - mask_ascii, // ascii - (0x3FFFFFFFu) & ~(U_GC_CN_MASK), // assigned - U_GC_C_MASK, // c* - U_GC_CC_MASK, // cc - U_GC_CF_MASK, // cf - U_GC_PE_MASK, // closepunctuation - U_GC_CN_MASK, // cn - U_GC_CO_MASK, // co - U_GC_PC_MASK, // connectorpunctuation - U_GC_CC_MASK, // control - U_GC_CS_MASK, // cs - U_GC_SC_MASK, // currencysymbol - U_GC_PD_MASK, // dashpunctuation - U_GC_ND_MASK, // decimaldigitnumber - U_GC_ME_MASK, // enclosingmark - U_GC_PF_MASK, // finalpunctuation - U_GC_CF_MASK, // format - U_GC_PI_MASK, // initialpunctuation - U_GC_L_MASK, // l* - U_GC_L_MASK, // letter - U_GC_NL_MASK, // letternumber - U_GC_ZL_MASK, // lineseparator - U_GC_LL_MASK, // ll - U_GC_LM_MASK, // lm - U_GC_LO_MASK, // lo - U_GC_LL_MASK, // lowercaseletter - U_GC_LT_MASK, // lt - U_GC_LU_MASK, // lu - U_GC_M_MASK, // m* - U_GC_M_MASK, // mark - U_GC_SM_MASK, // mathsymbol - U_GC_MC_MASK, // mc - U_GC_ME_MASK, // me - U_GC_MN_MASK, // mn - U_GC_LM_MASK, // modifierletter - U_GC_SK_MASK, // modifiersymbol - U_GC_N_MASK, // n* - U_GC_ND_MASK, // nd - U_GC_NL_MASK, // nl - U_GC_NO_MASK, // no - U_GC_MN_MASK, // nonspacingmark - U_GC_CN_MASK, // notassigned - U_GC_N_MASK, // number - U_GC_PS_MASK, // openpunctuation - U_GC_C_MASK, // other - U_GC_LO_MASK, // otherletter - U_GC_NO_MASK, // othernumber - U_GC_PO_MASK, // otherpunctuation - U_GC_SO_MASK, // othersymbol - U_GC_P_MASK, // p* - U_GC_ZP_MASK, // paragraphseparator - U_GC_PC_MASK, // pc - U_GC_PD_MASK, // pd - U_GC_PE_MASK, // pe - U_GC_PF_MASK, // pf - U_GC_PI_MASK, // pi - U_GC_PO_MASK, // po - U_GC_CO_MASK, // privateuse - U_GC_PS_MASK, // ps - U_GC_P_MASK, // punctuation - U_GC_S_MASK, // s* - U_GC_SC_MASK, // sc - U_GC_Z_MASK, // separator - U_GC_SK_MASK, // sk - U_GC_SM_MASK, // sm - U_GC_SO_MASK, // so - U_GC_ZS_MASK, // spaceseparator - U_GC_MC_MASK, // spacingcombiningmark - U_GC_CS_MASK, // surrogate - U_GC_S_MASK, // symbol - U_GC_LT_MASK, // titlecase - U_GC_LT_MASK, // titlecaseletter - U_GC_LU_MASK, // uppercaseletter - U_GC_Z_MASK, // z* - U_GC_ZL_MASK, // zl - U_GC_ZP_MASK, // zp - U_GC_ZS_MASK, // zs - }; - - - const BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32>* ranges_begin = range_data; - const BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32>* ranges_end = range_data + (sizeof(range_data) / sizeof(range_data[0])); - - BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32> t = { p1, p2, }; - const BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32>* p = std::lower_bound(ranges_begin, ranges_end, t); - if ((p != ranges_end) && (t == *p)) - return icu_class_map[p - ranges_begin]; - return 0; - } - std::shared_ptr< ::boost::BOOST_REGEX_DETAIL_NS::icu_regex_traits_implementation> m_pimpl; -}; - -} // namespace boost - -namespace boost{ - -// types: -typedef basic_regex< ::UChar32, icu_regex_traits> u32regex; -typedef match_results<const ::UChar32*> u32match; -typedef match_results<const ::UChar*> u16match; - -// -// Construction of 32-bit regex types from UTF-8 and UTF-16 primitives: -// -namespace BOOST_REGEX_DETAIL_NS{ - -template <class InputIterator> -inline u32regex do_make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt, - const std::integral_constant<int, 1>*) -{ - typedef boost::u8_to_u32_iterator<InputIterator, UChar32> conv_type; - return u32regex(conv_type(i, i, j), conv_type(j, i, j), opt); -} - -template <class InputIterator> -inline u32regex do_make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt, - const std::integral_constant<int, 2>*) -{ - typedef boost::u16_to_u32_iterator<InputIterator, UChar32> conv_type; - return u32regex(conv_type(i, i, j), conv_type(j, i, j), opt); -} - -template <class InputIterator> -inline u32regex do_make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt, - const std::integral_constant<int, 4>*) -{ - return u32regex(i, j, opt); -} -} - -// BOOST_REGEX_UCHAR_IS_WCHAR_T -// -// Source inspection of unicode/umachine.h in ICU version 59 indicates that: -// -// On version 59, UChar is always char16_t in C++ mode (and uint16_t in C mode) -// -// On earlier versions, the logic is -// -// #if U_SIZEOF_WCHAR_T==2 -// typedef wchar_t OldUChar; -// #elif defined(__CHAR16_TYPE__) -// typedef __CHAR16_TYPE__ OldUChar; -// #else -// typedef uint16_t OldUChar; -// #endif -// -// That is, UChar is wchar_t only on versions below 59, when U_SIZEOF_WCHAR_T==2 -// -// Hence, - -#define BOOST_REGEX_UCHAR_IS_WCHAR_T (U_ICU_VERSION_MAJOR_NUM < 59 && U_SIZEOF_WCHAR_T == 2) - -#if BOOST_REGEX_UCHAR_IS_WCHAR_T - static_assert((std::is_same<UChar, wchar_t>::value), "Configuration logic has failed!"); -#else - static_assert(!(std::is_same<UChar, wchar_t>::value), "Configuration logic has failed!"); -#endif - -// -// Construction from an iterator pair: -// -template <class InputIterator> -inline u32regex make_u32regex(InputIterator i, - InputIterator j, - boost::regex_constants::syntax_option_type opt) -{ - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(i, j, opt, static_cast<std::integral_constant<int, sizeof(*i)> const*>(0)); -} -// -// construction from UTF-8 nul-terminated strings: -// -inline u32regex make_u32regex(const char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) -{ - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::strlen(p), opt, static_cast<std::integral_constant<int, 1> const*>(0)); -} -inline u32regex make_u32regex(const unsigned char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) -{ - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::strlen(reinterpret_cast<const char*>(p)), opt, static_cast<std::integral_constant<int, 1> const*>(0)); -} -// -// construction from UTF-16 nul-terminated strings: -// -#ifndef BOOST_NO_WREGEX -inline u32regex make_u32regex(const wchar_t* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) -{ - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::wcslen(p), opt, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0)); -} -#endif -#if !BOOST_REGEX_UCHAR_IS_WCHAR_T -inline u32regex make_u32regex(const UChar* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) -{ - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + u_strlen(p), opt, static_cast<std::integral_constant<int, 2> const*>(0)); -} -#endif -// -// construction from basic_string class-template: -// -template<class C, class T, class A> -inline u32regex make_u32regex(const std::basic_string<C, T, A>& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) -{ - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(s.begin(), s.end(), opt, static_cast<std::integral_constant<int, sizeof(C)> const*>(0)); -} -// -// Construction from ICU string type: -// -inline u32regex make_u32regex(const U_NAMESPACE_QUALIFIER UnicodeString& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) -{ - return BOOST_REGEX_DETAIL_NS::do_make_u32regex(s.getBuffer(), s.getBuffer() + s.length(), opt, static_cast<std::integral_constant<int, 2> const*>(0)); -} - -// -// regex_match overloads that widen the character type as appropriate: -// -namespace BOOST_REGEX_DETAIL_NS{ -template<class MR1, class MR2, class NSubs> -void copy_results(MR1& out, MR2 const& in, NSubs named_subs) -{ - // copy results from an adapted MR2 match_results: - out.set_size(in.size(), in.prefix().first.base(), in.suffix().second.base()); - out.set_base(in.base().base()); - out.set_named_subs(named_subs); - for(int i = 0; i < (int)in.size(); ++i) - { - if(in[i].matched || !i) - { - out.set_first(in[i].first.base(), i); - out.set_second(in[i].second.base(), i, in[i].matched); - } - } -#ifdef BOOST_REGEX_MATCH_EXTRA - // Copy full capture info as well: - for(int i = 0; i < (int)in.size(); ++i) - { - if(in[i].captures().size()) - { - out[i].get_captures().assign(in[i].captures().size(), typename MR1::value_type()); - for(int j = 0; j < (int)out[i].captures().size(); ++j) - { - out[i].get_captures()[j].first = in[i].captures()[j].first.base(); - out[i].get_captures()[j].second = in[i].captures()[j].second.base(); - out[i].get_captures()[j].matched = in[i].captures()[j].matched; - } - } - } -#endif -} - -template <class BidiIterator, class Allocator> -inline bool do_regex_match(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - std::integral_constant<int, 4> const*) -{ - return ::boost::regex_match(first, last, m, e, flags); -} -template <class BidiIterator, class Allocator> -bool do_regex_match(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - std::integral_constant<int, 2> const*) -{ - typedef u16_to_u32_iterator<BidiIterator, UChar32> conv_type; - typedef match_results<conv_type> match_type; - //typedef typename match_type::allocator_type alloc_type; - match_type what; - bool result = ::boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags); - // copy results across to m: - if(result) copy_results(m, what, e.get_named_subs()); - return result; -} -template <class BidiIterator, class Allocator> -bool do_regex_match(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - std::integral_constant<int, 1> const*) -{ - typedef u8_to_u32_iterator<BidiIterator, UChar32> conv_type; - typedef match_results<conv_type> match_type; - //typedef typename match_type::allocator_type alloc_type; - match_type what; - bool result = ::boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags); - // copy results across to m: - if(result) copy_results(m, what, e.get_named_subs()); - return result; -} -} // namespace BOOST_REGEX_DETAIL_NS - -template <class BidiIterator, class Allocator> -inline bool u32regex_match(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_match(first, last, m, e, flags, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)); -} -inline bool u32regex_match(const UChar* p, - match_results<const UChar*>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast<std::integral_constant<int, 2> const*>(0)); -} -#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX) -inline bool u32regex_match(const wchar_t* p, - match_results<const wchar_t*>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0)); -} -#endif -inline bool u32regex_match(const char* p, - match_results<const char*>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0)); -} -inline bool u32regex_match(const unsigned char* p, - match_results<const unsigned char*>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0)); -} -inline bool u32regex_match(const std::string& s, - match_results<std::string::const_iterator>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0)); -} -#ifndef BOOST_NO_STD_WSTRING -inline bool u32regex_match(const std::wstring& s, - match_results<std::wstring::const_iterator>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0)); -} -#endif -inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, - match_results<const UChar*>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast<std::integral_constant<int, 2> const*>(0)); -} -// -// regex_match overloads that do not return what matched: -// -template <class BidiIterator> -inline bool u32regex_match(BidiIterator first, BidiIterator last, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<BidiIterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(first, last, m, e, flags, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)); -} -inline bool u32regex_match(const UChar* p, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<const UChar*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast<std::integral_constant<int, 2> const*>(0)); -} -#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX) -inline bool u32regex_match(const wchar_t* p, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<const wchar_t*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0)); -} -#endif -inline bool u32regex_match(const char* p, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<const char*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0)); -} -inline bool u32regex_match(const unsigned char* p, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<const unsigned char*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0)); -} -inline bool u32regex_match(const std::string& s, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<std::string::const_iterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0)); -} -#ifndef BOOST_NO_STD_WSTRING -inline bool u32regex_match(const std::wstring& s, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<std::wstring::const_iterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0)); -} -#endif -inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<const UChar*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast<std::integral_constant<int, 2> const*>(0)); -} - -// -// regex_search overloads that widen the character type as appropriate: -// -namespace BOOST_REGEX_DETAIL_NS{ -template <class BidiIterator, class Allocator> -inline bool do_regex_search(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - BidiIterator base, - std::integral_constant<int, 4> const*) -{ - return ::boost::regex_search(first, last, m, e, flags, base); -} -template <class BidiIterator, class Allocator> -bool do_regex_search(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - BidiIterator base, - std::integral_constant<int, 2> const*) -{ - typedef u16_to_u32_iterator<BidiIterator, UChar32> conv_type; - typedef match_results<conv_type> match_type; - //typedef typename match_type::allocator_type alloc_type; - match_type what; - bool result = ::boost::regex_search(conv_type(first, first, last), conv_type(last, first, last), what, e, flags, conv_type(base)); - // copy results across to m: - if(result) copy_results(m, what, e.get_named_subs()); - return result; -} -template <class BidiIterator, class Allocator> -bool do_regex_search(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - BidiIterator base, - std::integral_constant<int, 1> const*) -{ - typedef u8_to_u32_iterator<BidiIterator, UChar32> conv_type; - typedef match_results<conv_type> match_type; - //typedef typename match_type::allocator_type alloc_type; - match_type what; - bool result = ::boost::regex_search(conv_type(first, first, last), conv_type(last, first, last), what, e, flags, conv_type(base)); - // copy results across to m: - if(result) copy_results(m, what, e.get_named_subs()); - return result; -} -} - -template <class BidiIterator, class Allocator> -inline bool u32regex_search(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, first, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)); -} -template <class BidiIterator, class Allocator> -inline bool u32regex_search(BidiIterator first, BidiIterator last, - match_results<BidiIterator, Allocator>& m, - const u32regex& e, - match_flag_type flags, - BidiIterator base) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, base, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)); -} -inline bool u32regex_search(const UChar* p, - match_results<const UChar*>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast<std::integral_constant<int, 2> const*>(0)); -} -#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX) -inline bool u32regex_search(const wchar_t* p, - match_results<const wchar_t*>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0)); -} -#endif -inline bool u32regex_search(const char* p, - match_results<const char*>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast<std::integral_constant<int, 1> const*>(0)); -} -inline bool u32regex_search(const unsigned char* p, - match_results<const unsigned char*>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast<std::integral_constant<int, 1> const*>(0)); -} -inline bool u32regex_search(const std::string& s, - match_results<std::string::const_iterator>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<std::integral_constant<int, 1> const*>(0)); -} -#ifndef BOOST_NO_STD_WSTRING -inline bool u32regex_search(const std::wstring& s, - match_results<std::wstring::const_iterator>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0)); -} -#endif -inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, - match_results<const UChar*>& m, - const u32regex& e, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<std::integral_constant<int, 2> const*>(0)); -} -template <class BidiIterator> -inline bool u32regex_search(BidiIterator first, BidiIterator last, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<BidiIterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, first, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)); -} -inline bool u32regex_search(const UChar* p, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<const UChar*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast<std::integral_constant<int, 2> const*>(0)); -} -#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX) -inline bool u32regex_search(const wchar_t* p, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<const wchar_t*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0)); -} -#endif -inline bool u32regex_search(const char* p, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<const char*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast<std::integral_constant<int, 1> const*>(0)); -} -inline bool u32regex_search(const unsigned char* p, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<const unsigned char*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast<std::integral_constant<int, 1> const*>(0)); -} -inline bool u32regex_search(const std::string& s, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<std::string::const_iterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<std::integral_constant<int, 1> const*>(0)); -} -#ifndef BOOST_NO_STD_WSTRING -inline bool u32regex_search(const std::wstring& s, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<std::wstring::const_iterator> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0)); -} -#endif -inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, - const u32regex& e, - match_flag_type flags = match_default) -{ - match_results<const UChar*> m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<std::integral_constant<int, 2> const*>(0)); -} - -// -// overloads for regex_replace with utf-8 and utf-16 data types: -// -namespace BOOST_REGEX_DETAIL_NS{ -template <class I> -inline std::pair< boost::u8_to_u32_iterator<I>, boost::u8_to_u32_iterator<I> > - make_utf32_seq(I i, I j, std::integral_constant<int, 1> const*) -{ - return std::pair< boost::u8_to_u32_iterator<I>, boost::u8_to_u32_iterator<I> >(boost::u8_to_u32_iterator<I>(i, i, j), boost::u8_to_u32_iterator<I>(j, i, j)); -} -template <class I> -inline std::pair< boost::u16_to_u32_iterator<I>, boost::u16_to_u32_iterator<I> > - make_utf32_seq(I i, I j, std::integral_constant<int, 2> const*) -{ - return std::pair< boost::u16_to_u32_iterator<I>, boost::u16_to_u32_iterator<I> >(boost::u16_to_u32_iterator<I>(i, i, j), boost::u16_to_u32_iterator<I>(j, i, j)); -} -template <class I> -inline std::pair< I, I > - make_utf32_seq(I i, I j, std::integral_constant<int, 4> const*) -{ - return std::pair< I, I >(i, j); -} -template <class charT> -inline std::pair< boost::u8_to_u32_iterator<const charT*>, boost::u8_to_u32_iterator<const charT*> > - make_utf32_seq(const charT* p, std::integral_constant<int, 1> const*) -{ - std::size_t len = std::strlen((const char*)p); - return std::pair< boost::u8_to_u32_iterator<const charT*>, boost::u8_to_u32_iterator<const charT*> >(boost::u8_to_u32_iterator<const charT*>(p, p, p+len), boost::u8_to_u32_iterator<const charT*>(p+len, p, p+len)); -} -template <class charT> -inline std::pair< boost::u16_to_u32_iterator<const charT*>, boost::u16_to_u32_iterator<const charT*> > - make_utf32_seq(const charT* p, std::integral_constant<int, 2> const*) -{ - std::size_t len = u_strlen((const UChar*)p); - return std::pair< boost::u16_to_u32_iterator<const charT*>, boost::u16_to_u32_iterator<const charT*> >(boost::u16_to_u32_iterator<const charT*>(p, p, p + len), boost::u16_to_u32_iterator<const charT*>(p+len, p, p + len)); -} -template <class charT> -inline std::pair< const charT*, const charT* > - make_utf32_seq(const charT* p, std::integral_constant<int, 4> const*) -{ - return std::pair< const charT*, const charT* >(p, p+icu_regex_traits::length((UChar32 const*)p)); -} -template <class OutputIterator> -inline OutputIterator make_utf32_out(OutputIterator o, std::integral_constant<int, 4> const*) -{ - return o; -} -template <class OutputIterator> -inline utf16_output_iterator<OutputIterator> make_utf32_out(OutputIterator o, std::integral_constant<int, 2> const*) -{ - return o; -} -template <class OutputIterator> -inline utf8_output_iterator<OutputIterator> make_utf32_out(OutputIterator o, std::integral_constant<int, 1> const*) -{ - return o; -} - -template <class OutputIterator, class I1, class I2> -OutputIterator do_regex_replace(OutputIterator out, - std::pair<I1, I1> const& in, - const u32regex& e, - const std::pair<I2, I2>& fmt, - match_flag_type flags - ) -{ - // unfortunately we have to copy the format string in order to pass in onward: - std::vector<UChar32> f; - f.assign(fmt.first, fmt.second); - - regex_iterator<I1, UChar32, icu_regex_traits> i(in.first, in.second, e, flags); - regex_iterator<I1, UChar32, icu_regex_traits> j; - if(i == j) - { - if(!(flags & regex_constants::format_no_copy)) - out = std::copy(in.first, in.second, out); - } - else - { - I1 last_m = in.first; - while(i != j) - { - if(!(flags & regex_constants::format_no_copy)) - out = std::copy(i->prefix().first, i->prefix().second, out); - if(!f.empty()) - out = ::boost::BOOST_REGEX_DETAIL_NS::regex_format_imp(out, *i, &*f.begin(), &*f.begin() + f.size(), flags, e.get_traits()); - else - out = ::boost::BOOST_REGEX_DETAIL_NS::regex_format_imp(out, *i, static_cast<UChar32 const*>(0), static_cast<UChar32 const*>(0), flags, e.get_traits()); - last_m = (*i)[0].second; - if(flags & regex_constants::format_first_only) - break; - ++i; - } - if(!(flags & regex_constants::format_no_copy)) - out = std::copy(last_m, in.second, out); - } - return out; -} -template <class BaseIterator> -inline const BaseIterator& extract_output_base(const BaseIterator& b) -{ - return b; -} -template <class BaseIterator> -inline BaseIterator extract_output_base(const utf8_output_iterator<BaseIterator>& b) -{ - return b.base(); -} -template <class BaseIterator> -inline BaseIterator extract_output_base(const utf16_output_iterator<BaseIterator>& b) -{ - return b.base(); -} -} // BOOST_REGEX_DETAIL_NS - -template <class OutputIterator, class BidirectionalIterator, class charT> -inline OutputIterator u32regex_replace(OutputIterator out, - BidirectionalIterator first, - BidirectionalIterator last, - const u32regex& e, - const charT* fmt, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::extract_output_base - ( - BOOST_REGEX_DETAIL_NS::do_regex_replace( - BOOST_REGEX_DETAIL_NS::make_utf32_out(out, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)), - BOOST_REGEX_DETAIL_NS::make_utf32_seq(first, last, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)), - e, - BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt, static_cast<std::integral_constant<int, sizeof(*fmt)> const*>(0)), - flags) - ); -} - -template <class OutputIterator, class Iterator, class charT> -inline OutputIterator u32regex_replace(OutputIterator out, - Iterator first, - Iterator last, - const u32regex& e, - const std::basic_string<charT>& fmt, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::extract_output_base - ( - BOOST_REGEX_DETAIL_NS::do_regex_replace( - BOOST_REGEX_DETAIL_NS::make_utf32_out(out, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)), - BOOST_REGEX_DETAIL_NS::make_utf32_seq(first, last, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)), - e, - BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt.begin(), fmt.end(), static_cast<std::integral_constant<int, sizeof(charT)> const*>(0)), - flags) - ); -} - -template <class OutputIterator, class Iterator> -inline OutputIterator u32regex_replace(OutputIterator out, - Iterator first, - Iterator last, - const u32regex& e, - const U_NAMESPACE_QUALIFIER UnicodeString& fmt, - match_flag_type flags = match_default) -{ - return BOOST_REGEX_DETAIL_NS::extract_output_base - ( - BOOST_REGEX_DETAIL_NS::do_regex_replace( - BOOST_REGEX_DETAIL_NS::make_utf32_out(out, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)), - BOOST_REGEX_DETAIL_NS::make_utf32_seq(first, last, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0)), - e, - BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast<std::integral_constant<int, 2> const*>(0)), - flags) - ); -} - -template <class charT> -std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s, - const u32regex& e, - const charT* fmt, - match_flag_type flags = match_default) -{ - std::basic_string<charT> result; - BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result); - u32regex_replace(i, s.begin(), s.end(), e, fmt, flags); - return result; -} - -template <class charT> -std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s, - const u32regex& e, - const std::basic_string<charT>& fmt, - match_flag_type flags = match_default) -{ - std::basic_string<charT> result; - BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result); - u32regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags); - return result; -} - -namespace BOOST_REGEX_DETAIL_NS{ - -class unicode_string_out_iterator -{ - U_NAMESPACE_QUALIFIER UnicodeString* out; -public: - unicode_string_out_iterator(U_NAMESPACE_QUALIFIER UnicodeString& s) : out(&s) {} - unicode_string_out_iterator& operator++() { return *this; } - unicode_string_out_iterator& operator++(int) { return *this; } - unicode_string_out_iterator& operator*() { return *this; } - unicode_string_out_iterator& operator=(UChar v) - { - *out += v; - return *this; - } - typedef std::ptrdiff_t difference_type; - typedef UChar value_type; - typedef value_type* pointer; - typedef value_type& reference; - typedef std::output_iterator_tag iterator_category; -}; - -} - -inline U_NAMESPACE_QUALIFIER UnicodeString u32regex_replace(const U_NAMESPACE_QUALIFIER UnicodeString& s, - const u32regex& e, - const UChar* fmt, - match_flag_type flags = match_default) -{ - U_NAMESPACE_QUALIFIER UnicodeString result; - BOOST_REGEX_DETAIL_NS::unicode_string_out_iterator i(result); - u32regex_replace(i, s.getBuffer(), s.getBuffer()+s.length(), e, fmt, flags); - return result; -} - -inline U_NAMESPACE_QUALIFIER UnicodeString u32regex_replace(const U_NAMESPACE_QUALIFIER UnicodeString& s, - const u32regex& e, - const U_NAMESPACE_QUALIFIER UnicodeString& fmt, - match_flag_type flags = match_default) -{ - U_NAMESPACE_QUALIFIER UnicodeString result; - BOOST_REGEX_DETAIL_NS::unicode_string_out_iterator i(result); - BOOST_REGEX_DETAIL_NS::do_regex_replace( - BOOST_REGEX_DETAIL_NS::make_utf32_out(i, static_cast<std::integral_constant<int, 2> const*>(0)), - BOOST_REGEX_DETAIL_NS::make_utf32_seq(s.getBuffer(), s.getBuffer()+s.length(), static_cast<std::integral_constant<int, 2> const*>(0)), - e, - BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast<std::integral_constant<int, 2> const*>(0)), - flags); - return result; -} - -} // namespace boost. - -#ifdef BOOST_REGEX_MSVC -#pragma warning (pop) -#endif - -#include <boost/regex/v5/u32regex_iterator.hpp> -#include <boost/regex/v5/u32regex_token_iterator.hpp> - -#endif diff --git a/contrib/restricted/boost/regex/include/boost/regex/v5/iterator_traits.hpp b/contrib/restricted/boost/regex/include/boost/regex/v5/iterator_traits.hpp deleted file mode 100644 index 293db6bf8c..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/v5/iterator_traits.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE iterator_traits.cpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Declares iterator traits workarounds. - */ - -#ifndef BOOST_REGEX_V5_ITERATOR_TRAITS_HPP -#define BOOST_REGEX_V5_ITERATOR_TRAITS_HPP - -namespace boost{ -namespace BOOST_REGEX_DETAIL_NS{ - -template <class T> -struct regex_iterator_traits : public std::iterator_traits<T> {}; - -} // namespace BOOST_REGEX_DETAIL_NS -} // namespace boost - -#endif - diff --git a/contrib/restricted/boost/regex/include/boost/regex/v5/u32regex_iterator.hpp b/contrib/restricted/boost/regex/include/boost/regex/v5/u32regex_iterator.hpp deleted file mode 100644 index 6677019aca..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/v5/u32regex_iterator.hpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * - * Copyright (c) 2003 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE u32regex_iterator.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Provides u32regex_iterator implementation. - */ - -#ifndef BOOST_REGEX_V5_U32REGEX_ITERATOR_HPP -#define BOOST_REGEX_V5_U32REGEX_ITERATOR_HPP - -namespace boost{ - -template <class BidirectionalIterator> -class u32regex_iterator_implementation -{ - typedef u32regex regex_type; - - match_results<BidirectionalIterator> what; // current match - BidirectionalIterator base; // start of sequence - BidirectionalIterator end; // end of sequence - const regex_type re; // the expression - match_flag_type flags; // flags for matching - -public: - u32regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f) - : base(), end(last), re(*p), flags(f){} - bool init(BidirectionalIterator first) - { - base = first; - return u32regex_search(first, end, what, re, flags, base); - } - bool compare(const u32regex_iterator_implementation& that) - { - if(this == &that) return true; - return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second); - } - const match_results<BidirectionalIterator>& get() - { return what; } - bool next() - { - //if(what.prefix().first != what[0].second) - // flags |= match_prev_avail; - BidirectionalIterator next_start = what[0].second; - match_flag_type f(flags); - if(!what.length()) - f |= regex_constants::match_not_initial_null; - //if(base != next_start) - // f |= regex_constants::match_not_bob; - bool result = u32regex_search(next_start, end, what, re, f, base); - if(result) - what.set_base(base); - return result; - } -private: - u32regex_iterator_implementation& operator=(const u32regex_iterator_implementation&); -}; - -template <class BidirectionalIterator> -class u32regex_iterator -{ -private: - typedef u32regex_iterator_implementation<BidirectionalIterator> impl; - typedef std::shared_ptr<impl> pimpl; -public: - typedef u32regex regex_type; - typedef match_results<BidirectionalIterator> value_type; - typedef typename std::iterator_traits<BidirectionalIterator>::difference_type - difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; - typedef std::forward_iterator_tag iterator_category; - - u32regex_iterator(){} - u32regex_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - match_flag_type m = match_default) - : pdata(new impl(&re, b, m)) - { - if(!pdata->init(a)) - { - pdata.reset(); - } - } - u32regex_iterator(const u32regex_iterator& that) - : pdata(that.pdata) {} - u32regex_iterator& operator=(const u32regex_iterator& that) - { - pdata = that.pdata; - return *this; - } - bool operator==(const u32regex_iterator& that)const - { - if((pdata.get() == 0) || (that.pdata.get() == 0)) - return pdata.get() == that.pdata.get(); - return pdata->compare(*(that.pdata.get())); - } - bool operator!=(const u32regex_iterator& that)const - { return !(*this == that); } - const value_type& operator*()const - { return pdata->get(); } - const value_type* operator->()const - { return &(pdata->get()); } - u32regex_iterator& operator++() - { - cow(); - if(0 == pdata->next()) - { - pdata.reset(); - } - return *this; - } - u32regex_iterator operator++(int) - { - u32regex_iterator result(*this); - ++(*this); - return result; - } -private: - - pimpl pdata; - - void cow() - { - // copy-on-write - if(pdata.get() && (pdata.use_count() > 1)) - { - pdata.reset(new impl(*(pdata.get()))); - } - } -}; - -typedef u32regex_iterator<const char*> utf8regex_iterator; -typedef u32regex_iterator<const UChar*> utf16regex_iterator; -typedef u32regex_iterator<const UChar32*> utf32regex_iterator; - -inline u32regex_iterator<const char*> make_u32regex_iterator(const char* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_iterator<const char*>(p, p+std::strlen(p), e, m); -} -#ifndef BOOST_NO_WREGEX -inline u32regex_iterator<const wchar_t*> make_u32regex_iterator(const wchar_t* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_iterator<const wchar_t*>(p, p+std::wcslen(p), e, m); -} -#endif -#if !defined(BOOST_REGEX_UCHAR_IS_WCHAR_T) -inline u32regex_iterator<const UChar*> make_u32regex_iterator(const UChar* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_iterator<const UChar*>(p, p+u_strlen(p), e, m); -} -#endif -template <class charT, class Traits, class Alloc> -inline u32regex_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) -{ - typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type; - return u32regex_iterator<iter_type>(p.begin(), p.end(), e, m); -} -inline u32regex_iterator<const UChar*> make_u32regex_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, m); -} - -} // namespace boost - -#endif // BOOST_REGEX_V5_REGEX_ITERATOR_HPP - diff --git a/contrib/restricted/boost/regex/include/boost/regex/v5/u32regex_token_iterator.hpp b/contrib/restricted/boost/regex/include/boost/regex/v5/u32regex_token_iterator.hpp deleted file mode 100644 index 3d3032652f..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/v5/u32regex_token_iterator.hpp +++ /dev/null @@ -1,312 +0,0 @@ -/* - * - * Copyright (c) 2003 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE u32regex_token_iterator.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Provides u32regex_token_iterator implementation. - */ - -#ifndef BOOST_REGEX_V5_U32REGEX_TOKEN_ITERATOR_HPP -#define BOOST_REGEX_V5_U32REGEX_TOKEN_ITERATOR_HPP - -namespace boost{ - -#ifdef BOOST_REGEX_MSVC -# pragma warning(push) -# pragma warning(disable:4700) -#endif - -template <class BidirectionalIterator> -class u32regex_token_iterator_implementation -{ - typedef u32regex regex_type; - typedef sub_match<BidirectionalIterator> value_type; - - match_results<BidirectionalIterator> what; // current match - BidirectionalIterator end; // end of search area - BidirectionalIterator base; // start of search area - const regex_type re; // the expression - match_flag_type flags; // match flags - value_type result; // the current string result - int N; // the current sub-expression being enumerated - std::vector<int> subs; // the sub-expressions to enumerate - -public: - u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f) - : end(last), re(*p), flags(f){ subs.push_back(sub); } - u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector<int>& v, match_flag_type f) - : end(last), re(*p), flags(f), subs(v){} - template <std::size_t CN> - u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const int (&submatches)[CN], match_flag_type f) - : end(last), re(*p), flags(f) - { - for(std::size_t i = 0; i < CN; ++i) - { - subs.push_back(submatches[i]); - } - } - - bool init(BidirectionalIterator first) - { - base = first; - N = 0; - if(u32regex_search(first, end, what, re, flags, base) == true) - { - N = 0; - result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]); - return true; - } - else if((subs[N] == -1) && (first != end)) - { - result.first = first; - result.second = end; - result.matched = (first != end); - N = -1; - return true; - } - return false; - } - bool compare(const u32regex_token_iterator_implementation& that) - { - if(this == &that) return true; - return (&re.get_data() == &that.re.get_data()) - && (end == that.end) - && (flags == that.flags) - && (N == that.N) - && (what[0].first == that.what[0].first) - && (what[0].second == that.what[0].second); - } - const value_type& get() - { return result; } - bool next() - { - if(N == -1) - return false; - if(N+1 < (int)subs.size()) - { - ++N; - result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); - return true; - } - //if(what.prefix().first != what[0].second) - // flags |= match_prev_avail | regex_constants::match_not_bob; - BidirectionalIterator last_end(what[0].second); - if(u32regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base)) - { - N =0; - result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); - return true; - } - else if((last_end != end) && (subs[0] == -1)) - { - N =-1; - result.first = last_end; - result.second = end; - result.matched = (last_end != end); - return true; - } - return false; - } -private: - u32regex_token_iterator_implementation& operator=(const u32regex_token_iterator_implementation&); -}; - -template <class BidirectionalIterator> -class u32regex_token_iterator -{ -private: - typedef u32regex_token_iterator_implementation<BidirectionalIterator> impl; - typedef std::shared_ptr<impl> pimpl; -public: - typedef u32regex regex_type; - typedef sub_match<BidirectionalIterator> value_type; - typedef typename std::iterator_traits<BidirectionalIterator>::difference_type - difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; - typedef std::forward_iterator_tag iterator_category; - - u32regex_token_iterator(){} - u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, - int submatch = 0, match_flag_type m = match_default) - : pdata(new impl(&re, b, submatch, m)) - { - if(!pdata->init(a)) - pdata.reset(); - } - u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, - const std::vector<int>& submatches, match_flag_type m = match_default) - : pdata(new impl(&re, b, submatches, m)) - { - if(!pdata->init(a)) - pdata.reset(); - } - template <std::size_t N> - u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, - const int (&submatches)[N], match_flag_type m = match_default) - : pdata(new impl(&re, b, submatches, m)) - { - if(!pdata->init(a)) - pdata.reset(); - } - u32regex_token_iterator(const u32regex_token_iterator& that) - : pdata(that.pdata) {} - u32regex_token_iterator& operator=(const u32regex_token_iterator& that) - { - pdata = that.pdata; - return *this; - } - bool operator==(const u32regex_token_iterator& that)const - { - if((pdata.get() == 0) || (that.pdata.get() == 0)) - return pdata.get() == that.pdata.get(); - return pdata->compare(*(that.pdata.get())); - } - bool operator!=(const u32regex_token_iterator& that)const - { return !(*this == that); } - const value_type& operator*()const - { return pdata->get(); } - const value_type* operator->()const - { return &(pdata->get()); } - u32regex_token_iterator& operator++() - { - cow(); - if(0 == pdata->next()) - { - pdata.reset(); - } - return *this; - } - u32regex_token_iterator operator++(int) - { - u32regex_token_iterator result(*this); - ++(*this); - return result; - } -private: - - pimpl pdata; - - void cow() - { - // copy-on-write - if(pdata.get() && (pdata.use_count() > 1)) - { - pdata.reset(new impl(*(pdata.get()))); - } - } -}; - -typedef u32regex_token_iterator<const char*> utf8regex_token_iterator; -typedef u32regex_token_iterator<const UChar*> utf16regex_token_iterator; -typedef u32regex_token_iterator<const UChar32*> utf32regex_token_iterator; - -// construction from an integral sub_match state_id: -inline u32regex_token_iterator<const char*> make_u32regex_token_iterator(const char* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const char*>(p, p+std::strlen(p), e, submatch, m); -} -#ifndef BOOST_NO_WREGEX -inline u32regex_token_iterator<const wchar_t*> make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const wchar_t*>(p, p+std::wcslen(p), e, submatch, m); -} -#endif -#if !defined(BOOST_REGEX_UCHAR_IS_WCHAR_T) -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, submatch, m); -} -#endif -template <class charT, class Traits, class Alloc> -inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) -{ - typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type; - return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m); -} -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); -} - -// construction from a reference to an array: -template <std::size_t N> -inline u32regex_token_iterator<const char*> make_u32regex_token_iterator(const char* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const char*>(p, p+std::strlen(p), e, submatch, m); -} -#ifndef BOOST_NO_WREGEX -template <std::size_t N> -inline u32regex_token_iterator<const wchar_t*> make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const wchar_t*>(p, p+std::wcslen(p), e, submatch, m); -} -#endif -#if !defined(BOOST_REGEX_UCHAR_IS_WCHAR_T) -template <std::size_t N> -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, submatch, m); -} -#endif -template <class charT, class Traits, class Alloc, std::size_t N> -inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) -{ - typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type; - return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m); -} -template <std::size_t N> -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); -} - -// construction from a vector of sub_match state_id's: -inline u32regex_token_iterator<const char*> make_u32regex_token_iterator(const char* p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const char*>(p, p+std::strlen(p), e, submatch, m); -} -#ifndef BOOST_NO_WREGEX -inline u32regex_token_iterator<const wchar_t*> make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const wchar_t*>(p, p+std::wcslen(p), e, submatch, m); -} -#endif -#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, submatch, m); -} -#endif -template <class charT, class Traits, class Alloc> -inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default) -{ - typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type; - return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m); -} -inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default) -{ - return u32regex_token_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); -} - -#ifdef BOOST_REGEX_MSVC -# pragma warning(pop) -#endif - -} // namespace boost - -#endif // BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP - - - - diff --git a/contrib/restricted/boost/regex/include/boost/regex/v5/unicode_iterator.hpp b/contrib/restricted/boost/regex/include/boost/regex/v5/unicode_iterator.hpp deleted file mode 100644 index 9d3dd8b962..0000000000 --- a/contrib/restricted/boost/regex/include/boost/regex/v5/unicode_iterator.hpp +++ /dev/null @@ -1,862 +0,0 @@ -/* - * - * Copyright (c) 2004 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE unicode_iterator.hpp - * VERSION see <boost/version.hpp> - * DESCRIPTION: Iterator adapters for converting between different Unicode encodings. - */ - -/**************************************************************************** - -Contents: -~~~~~~~~~ - -1) Read Only, Input Adapters: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -template <class BaseIterator, class U8Type = std::uint8_t> -class u32_to_u8_iterator; - -Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-8. - -template <class BaseIterator, class U32Type = std::uint32_t> -class u8_to_u32_iterator; - -Adapts sequence of UTF-8 code points to "look like" a sequence of UTF-32. - -template <class BaseIterator, class U16Type = std::uint16_t> -class u32_to_u16_iterator; - -Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-16. - -template <class BaseIterator, class U32Type = std::uint32_t> -class u16_to_u32_iterator; - -Adapts sequence of UTF-16 code points to "look like" a sequence of UTF-32. - -2) Single pass output iterator adapters: - -template <class BaseIterator> -class utf8_output_iterator; - -Accepts UTF-32 code points and forwards them on as UTF-8 code points. - -template <class BaseIterator> -class utf16_output_iterator; - -Accepts UTF-32 code points and forwards them on as UTF-16 code points. - -****************************************************************************/ - -#ifndef BOOST_REGEX_UNICODE_ITERATOR_HPP -#define BOOST_REGEX_UNICODE_ITERATOR_HPP -#include <cstdint> -#include <boost/regex/config.hpp> -#include <stdexcept> -#include <sstream> -#include <ios> -#include <limits.h> // CHAR_BIT - -#ifndef BOOST_REGEX_STANDALONE -#include <boost/throw_exception.hpp> -#endif - -namespace boost{ - -namespace detail{ - -static const std::uint16_t high_surrogate_base = 0xD7C0u; -static const std::uint16_t low_surrogate_base = 0xDC00u; -static const std::uint32_t ten_bit_mask = 0x3FFu; - -inline bool is_high_surrogate(std::uint16_t v) -{ - return (v & 0xFFFFFC00u) == 0xd800u; -} -inline bool is_low_surrogate(std::uint16_t v) -{ - return (v & 0xFFFFFC00u) == 0xdc00u; -} -template <class T> -inline bool is_surrogate(T v) -{ - return (v & 0xFFFFF800u) == 0xd800; -} - -inline unsigned utf8_byte_count(std::uint8_t c) -{ - // if the most significant bit with a zero in it is in position - // 8-N then there are N bytes in this UTF-8 sequence: - std::uint8_t mask = 0x80u; - unsigned result = 0; - while(c & mask) - { - ++result; - mask >>= 1; - } - return (result == 0) ? 1 : ((result > 4) ? 4 : result); -} - -inline unsigned utf8_trailing_byte_count(std::uint8_t c) -{ - return utf8_byte_count(c) - 1; -} - -#ifdef BOOST_REGEX_MSVC -#pragma warning(push) -#pragma warning(disable:4100) -#endif -#ifndef BOOST_NO_EXCEPTIONS -BOOST_REGEX_NORETURN -#endif -inline void invalid_utf32_code_point(std::uint32_t val) -{ - std::stringstream ss; - ss << "Invalid UTF-32 code point U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-16 sequence"; - std::out_of_range e(ss.str()); -#ifndef BOOST_REGEX_STANDALONE - boost::throw_exception(e); -#else - throw e; -#endif -} -#ifdef BOOST_REGEX_MSVC -#pragma warning(pop) -#endif - - -} // namespace detail - -template <class BaseIterator, class U16Type = std::uint16_t> -class u32_to_u16_iterator -{ - typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type; - - static_assert(sizeof(base_value_type)*CHAR_BIT == 32, "Incorrectly sized template argument"); - static_assert(sizeof(U16Type)*CHAR_BIT == 16, "Incorrectly sized template argument"); - -public: - typedef std::ptrdiff_t difference_type; - typedef U16Type value_type; - typedef value_type const* pointer; - typedef value_type const reference; - typedef std::bidirectional_iterator_tag iterator_category; - - reference operator*()const - { - if(m_current == 2) - extract_current(); - return m_values[m_current]; - } - bool operator==(const u32_to_u16_iterator& that)const - { - if(m_position == that.m_position) - { - // Both m_currents must be equal, or both even - // this is the same as saying their sum must be even: - return (m_current + that.m_current) & 1u ? false : true; - } - return false; - } - bool operator!=(const u32_to_u16_iterator& that)const - { - return !(*this == that); - } - u32_to_u16_iterator& operator++() - { - // if we have a pending read then read now, so that we know whether - // to skip a position, or move to a low-surrogate: - if(m_current == 2) - { - // pending read: - extract_current(); - } - // move to the next surrogate position: - ++m_current; - // if we've reached the end skip a position: - if(m_values[m_current] == 0) - { - m_current = 2; - ++m_position; - } - return *this; - } - u32_to_u16_iterator operator++(int) - { - u32_to_u16_iterator r(*this); - ++(*this); - return r; - } - u32_to_u16_iterator& operator--() - { - if(m_current != 1) - { - // decrementing an iterator always leads to a valid position: - --m_position; - extract_current(); - m_current = m_values[1] ? 1 : 0; - } - else - { - m_current = 0; - } - return *this; - } - u32_to_u16_iterator operator--(int) - { - u32_to_u16_iterator r(*this); - --(*this); - return r; - } - BaseIterator base()const - { - return m_position; - } - // construct: - u32_to_u16_iterator() : m_position(), m_current(0) - { - m_values[0] = 0; - m_values[1] = 0; - m_values[2] = 0; - } - u32_to_u16_iterator(BaseIterator b) : m_position(b), m_current(2) - { - m_values[0] = 0; - m_values[1] = 0; - m_values[2] = 0; - } -private: - - void extract_current()const - { - // begin by checking for a code point out of range: - std::uint32_t v = *m_position; - if(v >= 0x10000u) - { - if(v > 0x10FFFFu) - detail::invalid_utf32_code_point(*m_position); - // split into two surrogates: - m_values[0] = static_cast<U16Type>(v >> 10) + detail::high_surrogate_base; - m_values[1] = static_cast<U16Type>(v & detail::ten_bit_mask) + detail::low_surrogate_base; - m_current = 0; - BOOST_REGEX_ASSERT(detail::is_high_surrogate(m_values[0])); - BOOST_REGEX_ASSERT(detail::is_low_surrogate(m_values[1])); - } - else - { - // 16-bit code point: - m_values[0] = static_cast<U16Type>(*m_position); - m_values[1] = 0; - m_current = 0; - // value must not be a surrogate: - if(detail::is_surrogate(m_values[0])) - detail::invalid_utf32_code_point(*m_position); - } - } - BaseIterator m_position; - mutable U16Type m_values[3]; - mutable unsigned m_current; -}; - -template <class BaseIterator, class U32Type = std::uint32_t> -class u16_to_u32_iterator -{ - // special values for pending iterator reads: - static const U32Type pending_read = 0xffffffffu; - - typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type; - - static_assert(sizeof(base_value_type)*CHAR_BIT == 16, "Incorrectly sized template argument"); - static_assert(sizeof(U32Type)*CHAR_BIT == 32, "Incorrectly sized template argument"); - -public: - typedef std::ptrdiff_t difference_type; - typedef U32Type value_type; - typedef value_type const* pointer; - typedef value_type const reference; - typedef std::bidirectional_iterator_tag iterator_category; - - reference operator*()const - { - if(m_value == pending_read) - extract_current(); - return m_value; - } - bool operator==(const u16_to_u32_iterator& that)const - { - return m_position == that.m_position; - } - bool operator!=(const u16_to_u32_iterator& that)const - { - return !(*this == that); - } - u16_to_u32_iterator& operator++() - { - // skip high surrogate first if there is one: - if(detail::is_high_surrogate(*m_position)) ++m_position; - ++m_position; - m_value = pending_read; - return *this; - } - u16_to_u32_iterator operator++(int) - { - u16_to_u32_iterator r(*this); - ++(*this); - return r; - } - u16_to_u32_iterator& operator--() - { - --m_position; - // if we have a low surrogate then go back one more: - if(detail::is_low_surrogate(*m_position)) - --m_position; - m_value = pending_read; - return *this; - } - u16_to_u32_iterator operator--(int) - { - u16_to_u32_iterator r(*this); - --(*this); - return r; - } - BaseIterator base()const - { - return m_position; - } - // construct: - u16_to_u32_iterator() : m_position() - { - m_value = pending_read; - } - u16_to_u32_iterator(BaseIterator b) : m_position(b) - { - m_value = pending_read; - } - // - // Range checked version: - // - u16_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b) - { - m_value = pending_read; - // - // The range must not start with a low surrogate, or end in a high surrogate, - // otherwise we run the risk of running outside the underlying input range. - // Likewise b must not be located at a low surrogate. - // - std::uint16_t val; - if(start != end) - { - if((b != start) && (b != end)) - { - val = *b; - if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u)) - invalid_code_point(val); - } - val = *start; - if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u)) - invalid_code_point(val); - val = *--end; - if(detail::is_high_surrogate(val)) - invalid_code_point(val); - } - } -private: - static void invalid_code_point(std::uint16_t val) - { - std::stringstream ss; - ss << "Misplaced UTF-16 surrogate U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-32 sequence"; - std::out_of_range e(ss.str()); -#ifndef BOOST_REGEX_STANDALONE - boost::throw_exception(e); -#else - throw e; -#endif - } - void extract_current()const - { - m_value = static_cast<U32Type>(static_cast< std::uint16_t>(*m_position)); - // if the last value is a high surrogate then adjust m_position and m_value as needed: - if(detail::is_high_surrogate(*m_position)) - { - // precondition; next value must have be a low-surrogate: - BaseIterator next(m_position); - std::uint16_t t = *++next; - if((t & 0xFC00u) != 0xDC00u) - invalid_code_point(t); - m_value = (m_value - detail::high_surrogate_base) << 10; - m_value |= (static_cast<U32Type>(static_cast< std::uint16_t>(t)) & detail::ten_bit_mask); - } - // postcondition; result must not be a surrogate: - if(detail::is_surrogate(m_value)) - invalid_code_point(static_cast< std::uint16_t>(m_value)); - } - BaseIterator m_position; - mutable U32Type m_value; -}; - -template <class BaseIterator, class U8Type = std::uint8_t> -class u32_to_u8_iterator -{ - typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type; - - static_assert(sizeof(base_value_type)*CHAR_BIT == 32, "Incorrectly sized template argument"); - static_assert(sizeof(U8Type)*CHAR_BIT == 8, "Incorrectly sized template argument"); - -public: - typedef std::ptrdiff_t difference_type; - typedef U8Type value_type; - typedef value_type const* pointer; - typedef value_type const reference; - typedef std::bidirectional_iterator_tag iterator_category; - - reference operator*()const - { - if(m_current == 4) - extract_current(); - return m_values[m_current]; - } - bool operator==(const u32_to_u8_iterator& that)const - { - if(m_position == that.m_position) - { - // either the m_current's must be equal, or one must be 0 and - // the other 4: which means neither must have bits 1 or 2 set: - return (m_current == that.m_current) - || (((m_current | that.m_current) & 3) == 0); - } - return false; - } - bool operator!=(const u32_to_u8_iterator& that)const - { - return !(*this == that); - } - u32_to_u8_iterator& operator++() - { - // if we have a pending read then read now, so that we know whether - // to skip a position, or move to a low-surrogate: - if(m_current == 4) - { - // pending read: - extract_current(); - } - // move to the next surrogate position: - ++m_current; - // if we've reached the end skip a position: - if(m_values[m_current] == 0) - { - m_current = 4; - ++m_position; - } - return *this; - } - u32_to_u8_iterator operator++(int) - { - u32_to_u8_iterator r(*this); - ++(*this); - return r; - } - u32_to_u8_iterator& operator--() - { - if((m_current & 3) == 0) - { - --m_position; - extract_current(); - m_current = 3; - while(m_current && (m_values[m_current] == 0)) - --m_current; - } - else - --m_current; - return *this; - } - u32_to_u8_iterator operator--(int) - { - u32_to_u8_iterator r(*this); - --(*this); - return r; - } - BaseIterator base()const - { - return m_position; - } - // construct: - u32_to_u8_iterator() : m_position(), m_current(0) - { - m_values[0] = 0; - m_values[1] = 0; - m_values[2] = 0; - m_values[3] = 0; - m_values[4] = 0; - } - u32_to_u8_iterator(BaseIterator b) : m_position(b), m_current(4) - { - m_values[0] = 0; - m_values[1] = 0; - m_values[2] = 0; - m_values[3] = 0; - m_values[4] = 0; - } -private: - - void extract_current()const - { - std::uint32_t c = *m_position; - if(c > 0x10FFFFu) - detail::invalid_utf32_code_point(c); - if(c < 0x80u) - { - m_values[0] = static_cast<unsigned char>(c); - m_values[1] = static_cast<unsigned char>(0u); - m_values[2] = static_cast<unsigned char>(0u); - m_values[3] = static_cast<unsigned char>(0u); - } - else if(c < 0x800u) - { - m_values[0] = static_cast<unsigned char>(0xC0u + (c >> 6)); - m_values[1] = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - m_values[2] = static_cast<unsigned char>(0u); - m_values[3] = static_cast<unsigned char>(0u); - } - else if(c < 0x10000u) - { - m_values[0] = static_cast<unsigned char>(0xE0u + (c >> 12)); - m_values[1] = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu)); - m_values[2] = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - m_values[3] = static_cast<unsigned char>(0u); - } - else - { - m_values[0] = static_cast<unsigned char>(0xF0u + (c >> 18)); - m_values[1] = static_cast<unsigned char>(0x80u + ((c >> 12) & 0x3Fu)); - m_values[2] = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu)); - m_values[3] = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - } - m_current= 0; - } - BaseIterator m_position; - mutable U8Type m_values[5]; - mutable unsigned m_current; -}; - -template <class BaseIterator, class U32Type = std::uint32_t> -class u8_to_u32_iterator -{ - // special values for pending iterator reads: - static const U32Type pending_read = 0xffffffffu; - - typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type; - - static_assert(sizeof(base_value_type)*CHAR_BIT == 8, "Incorrectly sized template argument"); - static_assert(sizeof(U32Type)*CHAR_BIT == 32, "Incorrectly sized template argument"); - -public: - typedef std::ptrdiff_t difference_type; - typedef U32Type value_type; - typedef value_type const* pointer; - typedef value_type const reference; - typedef std::bidirectional_iterator_tag iterator_category; - - reference operator*()const - { - if(m_value == pending_read) - extract_current(); - return m_value; - } - bool operator==(const u8_to_u32_iterator& that)const - { - return m_position == that.m_position; - } - bool operator!=(const u8_to_u32_iterator& that)const - { - return !(*this == that); - } - u8_to_u32_iterator& operator++() - { - // We must not start with a continuation character: - if((static_cast<std::uint8_t>(*m_position) & 0xC0) == 0x80) - invalid_sequence(); - // skip high surrogate first if there is one: - unsigned c = detail::utf8_byte_count(*m_position); - if(m_value == pending_read) - { - // Since we haven't read in a value, we need to validate the code points: - for(unsigned i = 0; i < c; ++i) - { - ++m_position; - // We must have a continuation byte: - if((i != c - 1) && ((static_cast<std::uint8_t>(*m_position) & 0xC0) != 0x80)) - invalid_sequence(); - } - } - else - { - std::advance(m_position, c); - } - m_value = pending_read; - return *this; - } - u8_to_u32_iterator operator++(int) - { - u8_to_u32_iterator r(*this); - ++(*this); - return r; - } - u8_to_u32_iterator& operator--() - { - // Keep backtracking until we don't have a trailing character: - unsigned count = 0; - while((*--m_position & 0xC0u) == 0x80u) ++count; - // now check that the sequence was valid: - if(count != detail::utf8_trailing_byte_count(*m_position)) - invalid_sequence(); - m_value = pending_read; - return *this; - } - u8_to_u32_iterator operator--(int) - { - u8_to_u32_iterator r(*this); - --(*this); - return r; - } - BaseIterator base()const - { - return m_position; - } - // construct: - u8_to_u32_iterator() : m_position() - { - m_value = pending_read; - } - u8_to_u32_iterator(BaseIterator b) : m_position(b) - { - m_value = pending_read; - } - // - // Checked constructor: - // - u8_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b) - { - m_value = pending_read; - // - // We must not start with a continuation character, or end with a - // truncated UTF-8 sequence otherwise we run the risk of going past - // the start/end of the underlying sequence: - // - if(start != end) - { - unsigned char v = *start; - if((v & 0xC0u) == 0x80u) - invalid_sequence(); - if((b != start) && (b != end) && ((*b & 0xC0u) == 0x80u)) - invalid_sequence(); - BaseIterator pos = end; - do - { - v = *--pos; - } - while((start != pos) && ((v & 0xC0u) == 0x80u)); - std::ptrdiff_t extra = detail::utf8_byte_count(v); - if(std::distance(pos, end) < extra) - invalid_sequence(); - } - } -private: - static void invalid_sequence() - { - std::out_of_range e("Invalid UTF-8 sequence encountered while trying to encode UTF-32 character"); -#ifndef BOOST_REGEX_STANDALONE - boost::throw_exception(e); -#else - throw e; -#endif - } - void extract_current()const - { - m_value = static_cast<U32Type>(static_cast< std::uint8_t>(*m_position)); - // we must not have a continuation character: - if((m_value & 0xC0u) == 0x80u) - invalid_sequence(); - // see how many extra bytes we have: - unsigned extra = detail::utf8_trailing_byte_count(*m_position); - // extract the extra bits, 6 from each extra byte: - BaseIterator next(m_position); - for(unsigned c = 0; c < extra; ++c) - { - ++next; - m_value <<= 6; - // We must have a continuation byte: - if((static_cast<std::uint8_t>(*next) & 0xC0) != 0x80) - invalid_sequence(); - m_value += static_cast<std::uint8_t>(*next) & 0x3Fu; - } - // we now need to remove a few of the leftmost bits, but how many depends - // upon how many extra bytes we've extracted: - static const std::uint32_t masks[4] = - { - 0x7Fu, - 0x7FFu, - 0xFFFFu, - 0x1FFFFFu, - }; - m_value &= masks[extra]; - // check the result is in range: - if(m_value > static_cast<U32Type>(0x10FFFFu)) - invalid_sequence(); - // The result must not be a surrogate: - if((m_value >= static_cast<U32Type>(0xD800)) && (m_value <= static_cast<U32Type>(0xDFFF))) - invalid_sequence(); - // We should not have had an invalidly encoded UTF8 sequence: - if((extra > 0) && (m_value <= static_cast<U32Type>(masks[extra - 1]))) - invalid_sequence(); - } - BaseIterator m_position; - mutable U32Type m_value; -}; - -template <class BaseIterator> -class utf16_output_iterator -{ -public: - typedef void difference_type; - typedef void value_type; - typedef std::uint32_t* pointer; - typedef std::uint32_t& reference; - typedef std::output_iterator_tag iterator_category; - - utf16_output_iterator(const BaseIterator& b) - : m_position(b){} - utf16_output_iterator(const utf16_output_iterator& that) - : m_position(that.m_position){} - utf16_output_iterator& operator=(const utf16_output_iterator& that) - { - m_position = that.m_position; - return *this; - } - const utf16_output_iterator& operator*()const - { - return *this; - } - void operator=(std::uint32_t val)const - { - push(val); - } - utf16_output_iterator& operator++() - { - return *this; - } - utf16_output_iterator& operator++(int) - { - return *this; - } - BaseIterator base()const - { - return m_position; - } -private: - void push(std::uint32_t v)const - { - if(v >= 0x10000u) - { - // begin by checking for a code point out of range: - if(v > 0x10FFFFu) - detail::invalid_utf32_code_point(v); - // split into two surrogates: - *m_position++ = static_cast<std::uint16_t>(v >> 10) + detail::high_surrogate_base; - *m_position++ = static_cast<std::uint16_t>(v & detail::ten_bit_mask) + detail::low_surrogate_base; - } - else - { - // 16-bit code point: - // value must not be a surrogate: - if(detail::is_surrogate(v)) - detail::invalid_utf32_code_point(v); - *m_position++ = static_cast<std::uint16_t>(v); - } - } - mutable BaseIterator m_position; -}; - -template <class BaseIterator> -class utf8_output_iterator -{ -public: - typedef void difference_type; - typedef void value_type; - typedef std::uint32_t* pointer; - typedef std::uint32_t& reference; - typedef std::output_iterator_tag iterator_category; - - utf8_output_iterator(const BaseIterator& b) - : m_position(b){} - utf8_output_iterator(const utf8_output_iterator& that) - : m_position(that.m_position){} - utf8_output_iterator& operator=(const utf8_output_iterator& that) - { - m_position = that.m_position; - return *this; - } - const utf8_output_iterator& operator*()const - { - return *this; - } - void operator=(std::uint32_t val)const - { - push(val); - } - utf8_output_iterator& operator++() - { - return *this; - } - utf8_output_iterator& operator++(int) - { - return *this; - } - BaseIterator base()const - { - return m_position; - } -private: - void push(std::uint32_t c)const - { - if(c > 0x10FFFFu) - detail::invalid_utf32_code_point(c); - if(c < 0x80u) - { - *m_position++ = static_cast<unsigned char>(c); - } - else if(c < 0x800u) - { - *m_position++ = static_cast<unsigned char>(0xC0u + (c >> 6)); - *m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - } - else if(c < 0x10000u) - { - *m_position++ = static_cast<unsigned char>(0xE0u + (c >> 12)); - *m_position++ = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu)); - *m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - } - else - { - *m_position++ = static_cast<unsigned char>(0xF0u + (c >> 18)); - *m_position++ = static_cast<unsigned char>(0x80u + ((c >> 12) & 0x3Fu)); - *m_position++ = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu)); - *m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu)); - } - } - mutable BaseIterator m_position; -}; - -} // namespace boost - -#endif // BOOST_REGEX_UNICODE_ITERATOR_HPP - |