-#include <cstring>
-#include <boost/regex_fwd.hpp>
-#include <boost/regex/detail/regex_stack.hpp>
-#include <boost/regex/detail/regex_raw_buffer.hpp>
-#include <boost/regex/detail/regex_kmp.hpp>
-#include <boost/regex/pattern_except.hpp>
-#include <boost/regex/regex_traits.hpp>
-#include <boost/type_traits/cv_traits.hpp>
-#include <boost/scoped_array.hpp>
-
-
-namespace boost{
-
-#ifdef __BORLANDC__
- #pragma option push -a8 -b -Vx -Ve -pc -w-8027
-#endif
-
-namespace re_detail{
-
-struct re_set_long;
-struct re_syntax_base;
-
-} // namespace re_detail
-
-namespace deprecated{
-//
-// class char_regex_traits_i
-// provides case insensitive traits classes (deprecated):
-template <class charT>
-class char_regex_traits_i : public regex_traits<charT> {};
-
-template<>
-class char_regex_traits_i<char> : public regex_traits<char>
-{
-public:
- typedef char char_type;
- typedef unsigned char uchar_type;
- typedef unsigned int size_type;
- typedef regex_traits<char> base_type;
-
- char BOOST_REGEX_CALL translate(char c, bool)const
- {
- return static_cast<const regex_traits<char>*>(this)->translate(c, true);
- }
-};
-
-#ifndef BOOST_NO_WREGEX
-template<>
-class char_regex_traits_i<wchar_t> : public regex_traits<wchar_t>
-{
-public:
- typedef wchar_t char_type;
- typedef unsigned short uchar_type;
- typedef unsigned int size_type;
- typedef regex_traits<wchar_t> base_type;
-
- wchar_t BOOST_REGEX_CALL translate(wchar_t c, bool)const
- {
- return static_cast<const regex_traits<wchar_t>*>(this)->translate(c, true);
- }
- boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const wchar_t* first, const wchar_t* last)const
- {
- boost::uint_fast32_t result = static_cast<const regex_traits<wchar_t>*>(this)->lookup_classname(first, last);
- if((result & base_type::char_class_upper) == base_type::char_class_upper)
- result |= base_type::char_class_alpha;
- return result;
- }
-};
-#endif
-} // namespace deprecated
-
-
-namespace re_detail{
-
-enum mask_type
-{
- mask_take = 1,
- mask_skip = 2,
- mask_any = mask_skip | mask_take,
- mask_all = mask_any
-};
-
-struct _narrow_type{};
-struct _wide_type{};
-
-template <class charT>
-class is_byte;
-
-template<>
-class is_byte<char>
-{
-public:
- typedef _narrow_type width_type;
-};
-
-template<>
-class is_byte<unsigned char>
-{
-public:
- typedef _narrow_type width_type;
-};
-
-template<>
-class is_byte<signed char>
-{
-public:
- typedef _narrow_type width_type;
-};
-
-template <class charT>
-class is_byte
-{
-public:
- typedef _wide_type width_type;
-};
-
-
-//
-// compiled structures
-//
-// the following defs describe the format of the compiled string
-//
-
-//
-// enum syntax_element_type
-// describes the type of a record
-enum syntax_element_type
-{
- syntax_element_startmark = 0,
- syntax_element_endmark = syntax_element_startmark + 1,
- syntax_element_literal = syntax_element_endmark + 1,
- syntax_element_start_line = syntax_element_literal + 1,
- syntax_element_end_line = syntax_element_start_line + 1,
- syntax_element_wild = syntax_element_end_line + 1,
- syntax_element_match = syntax_element_wild + 1,
- syntax_element_word_boundary = syntax_element_match + 1,
- syntax_element_within_word = syntax_element_word_boundary + 1,
- syntax_element_word_start = syntax_element_within_word + 1,
- syntax_element_word_end = syntax_element_word_start + 1,
- syntax_element_buffer_start = syntax_element_word_end + 1,
- syntax_element_buffer_end = syntax_element_buffer_start + 1,
- syntax_element_backref = syntax_element_buffer_end + 1,
- syntax_element_long_set = syntax_element_backref + 1,
- syntax_element_set = syntax_element_long_set + 1,
- syntax_element_jump = syntax_element_set + 1,
- syntax_element_alt = syntax_element_jump + 1,
- syntax_element_rep = syntax_element_alt + 1,
- syntax_element_combining = syntax_element_rep + 1,
- syntax_element_soft_buffer_end = syntax_element_combining + 1,
- syntax_element_restart_continue = syntax_element_soft_buffer_end + 1
-};
-
-#ifdef BOOST_REGEX_DEBUG
-// dwa 09/26/00 - This is needed to suppress warnings about an ambiguous conversion
-std::ostream& operator<<(std::ostream&, syntax_element_type);
-#endif
-
-union offset_type
-{
- re_syntax_base* p;
- std::size_t i;
-};
-
-//
-// struct re_syntax_base
-// base class for all syntax types:
-struct re_syntax_base
-{
- syntax_element_type type;
- offset_type next;
- unsigned int can_be_null;
-};
-
-//
-// struct re_brace
-// marks start or end of (...)
-struct re_brace : public re_syntax_base
-{
- int index;
-};
-
-//
-// struct re_literal
-// marks a literal string and
-// is followed by an array of charT[length]:
-struct re_literal : public re_syntax_base
-{
- unsigned int length;
-};
-
-//
-// struct re_long_set
-// provides data for sets [...] containing
-// wide characters
-struct re_set_long : public re_syntax_base
-{
- unsigned int csingles, cranges, cequivalents;
- boost::uint_fast32_t cclasses;
- bool isnot;
-};
-
-//
-// struct re_set
-// provides a map of bools for sets containing
-// narrow, single byte characters.
-struct re_set : public re_syntax_base
-{
- unsigned char _map[256];
-};
-
-//
-// struct re_jump
-// provides alternative next destination
-struct re_jump : public re_syntax_base
-{
- offset_type alt;
- unsigned char _map[256];
-};
-
-//
-// struct re_repeat
-// provides repeat expressions
-struct re_repeat : public re_jump
-{
- unsigned min, max;
- int id;
- bool leading;
- bool greedy;
- bool singleton;
-};
-
-
-//
-// enum re_jump_size_type
-// provides compiled size of re_jump
-// allowing for trailing alignment
-// provide this so we know how many
-// bytes to insert
-enum re_jump_size_type
-{
- re_jump_size = (sizeof(re_jump) + padding_mask) & ~(padding_mask),
- re_repeater_size = (sizeof(re_repeat) + padding_mask) & ~(padding_mask)
-};
-
-} // namespace re_detail
-
-//
-// class basic_regex
-// handles error codes and flags
-
-class BOOST_REGEX_DECL regbase
-{
-public:
- enum flag_type_
- {
- escape_in_lists = 1, // '\' special inside [...]
- char_classes = escape_in_lists << 1, // [[:CLASS:]] allowed
- intervals = char_classes << 1, // {x,y} allowed
- limited_ops = intervals << 1, // all of + ? and | are normal characters
- newline_alt = limited_ops << 1, // \n is the same as |
- bk_plus_qm = newline_alt << 1, // uses \+ and \?
- bk_braces = bk_plus_qm << 1, // uses \{ and \}
- bk_parens = bk_braces << 1, // uses \( and \)
- bk_refs = bk_parens << 1, // \d allowed
- bk_vbar = bk_refs << 1, // uses \|
-
- use_except = bk_vbar << 1, // exception on error
- failbit = use_except << 1, // error flag
- literal = failbit << 1, // all characters are literals
- icase = literal << 1, // characters are matched regardless of case
- nocollate = icase << 1, // don't use locale specific collation
-
- basic = char_classes | intervals | limited_ops | bk_braces | bk_parens | bk_refs,
- extended = char_classes | intervals | bk_refs,
- normal = escape_in_lists | char_classes | intervals | bk_refs | nocollate,
- emacs = bk_braces | bk_parens | bk_refs | bk_vbar,
- awk = extended | escape_in_lists,
- grep = basic | newline_alt,
- egrep = extended | newline_alt,
- sed = basic,
- perl = normal
- };
- typedef unsigned int flag_type;
-
- enum restart_info
- {
- restart_any = 0,
- restart_word = 1,
- restart_line = 2,
- restart_buf = 3,
- restart_continue = 4,
- restart_lit = 5,
- restart_fixed_lit = 6
- };
-
- flag_type BOOST_REGEX_CALL flags()const
- {
- return _flags;
- }
-
- regbase();
- regbase(const regbase& b);
-protected:
- flag_type _flags;
-};
-
-//
-// some forward declarations:
-namespace re_detail{
-template <class iterator, class Allocator>
-class _priv_match_data;
-
-#if defined(BOOST_NO_STD_ITERATOR_TRAITS) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
-
-template <class T>
-struct regex_iterator_traits
-{
- typedef typename T::iterator_category iterator_category;
- typedef typename T::value_type value_type;
-#if !defined(BOOST_NO_STD_ITERATOR)
- typedef typename T::difference_type difference_type;
- typedef typename T::pointer pointer;
- typedef typename T::reference reference;
-#else
- typedef std::ptrdiff_t difference_type;
- typedef value_type* pointer;
- typedef value_type& reference;
-#endif
-};
-
-template <class T>
-struct pointer_iterator_traits
-{
- typedef std::ptrdiff_t difference_type;
- typedef T value_type;
- typedef T* pointer;
- typedef T& reference;
- typedef std::random_access_iterator_tag iterator_category;
-};
-template <class T>
-struct const_pointer_iterator_traits
-{
- typedef std::ptrdiff_t difference_type;
- typedef T value_type;
- typedef const T* pointer;
- typedef const T& reference;
- typedef std::random_access_iterator_tag iterator_category;
-};
-
-template<>
-struct regex_iterator_traits<char*> : pointer_iterator_traits<char>{};
-template<>
-struct regex_iterator_traits<const char*> : const_pointer_iterator_traits<char>{};
-template<>
-struct regex_iterator_traits<wchar_t*> : pointer_iterator_traits<wchar_t>{};
-template<>
-struct regex_iterator_traits<const wchar_t*> : const_pointer_iterator_traits<wchar_t>{};
-
-#if defined(__SGI_STL_PORT) && defined(__STL_DEBUG)
-template<>
-struct regex_iterator_traits<std::string::iterator> : pointer_iterator_traits<char>{};
-template<>
-struct regex_iterator_traits<std::string::const_iterator> : const_pointer_iterator_traits<char>{};
-#ifndef BOOST_NO_STD_WSTRING
-template<>
-struct regex_iterator_traits<std::wstring::iterator> : pointer_iterator_traits<wchar_t>{};
-template<>
-struct regex_iterator_traits<std::wstring::const_iterator> : const_pointer_iterator_traits<wchar_t>{};
-#endif // BOOST_NO_WSTRING
-#endif // stport
-
-#else
-
-template <class T>
-struct regex_iterator_traits : public std::iterator_traits<T> {};
-
-#endif
-
-template <class I>
-struct def_alloc_param_traits
-{
- typedef typename regex_iterator_traits<I>::value_type const_value_type;
- typedef typename remove_cv<const_value_type>::type type;
-};
-template <>
-struct def_alloc_param_traits<const char*>
-{
- typedef char type;
-};
-template <>
-struct def_alloc_param_traits<const wchar_t*>
-{
- typedef wchar_t type;
-};
-
-}
-
-template <class iterator, class Allocator =
-#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1300))
-BOOST_DEFAULT_ALLOCATOR(typename re_detail::def_alloc_param_traits<iterator>::type) >
-#else
-BOOST_DEFAULT_ALLOCATOR(re_detail::def_alloc_param_traits<iterator>::type) >
-#endif
-class match_results;
-
-//
-// class reg_expression
-// represents the compiled
-// regular expression:
-//
-
-#ifdef BOOST_REGEX_NO_FWD
-template <class charT, class traits = regex_traits<charT>, class Allocator = BOOST_DEFAULT_ALLOCATOR(charT) >
-#else
-template <class charT, class traits, class Allocator >
-#endif
-class reg_expression : public regbase
-{
-public:
- typedef typename traits::size_type traits_size_type;
- typedef typename traits::uchar_type traits_uchar_type;
- typedef typename traits::string_type traits_string_type;
- // typedefs:
- typedef charT char_type;
- typedef traits traits_type;
-
- // locale_type
- // placeholder for actual locale type used by the
- // traits class to localise *this.
- typedef typename traits::locale_type locale_type;
- // value_type
- typedef charT value_type;
- // reference, const_reference
- typedef charT& reference;
- typedef const charT& const_reference;
- // iterator, const_iterator
- typedef const charT* const_iterator;
- typedef const_iterator iterator;
- // difference_type
- typedef typename Allocator::difference_type difference_type;
- // size_type
- typedef typename Allocator::size_type size_type;
- // allocator_type
- typedef Allocator allocator_type;
- typedef Allocator alloc_type;
- // flag_type
- typedef regbase::flag_type flag_type;
-
-public:
- explicit reg_expression(const Allocator& a = Allocator());
- explicit reg_expression(const charT* p, flag_type f = regbase::normal, const Allocator& a = Allocator());
- reg_expression(const charT* p1, const charT* p2, flag_type f = regbase::normal, const Allocator& a = Allocator());
- reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a = Allocator());
- reg_expression(const reg_expression&);
- ~reg_expression();
- reg_expression& BOOST_REGEX_CALL operator=(const reg_expression&);
- reg_expression& BOOST_REGEX_CALL operator=(const charT* ptr)
- {
- set_expression(ptr, regbase::normal | regbase::use_except);
- return *this;
- }
-
- //
- // assign:
- reg_expression& assign(const reg_expression& that)
- { return *this = that; }
- reg_expression& assign(const charT* ptr, flag_type f = regbase::normal)
- {
- set_expression(ptr, f | regbase::use_except);
- return *this;
- }
-
- reg_expression& assign(const charT* first,
- const charT* last,
- flag_type f = regbase::normal)
- {
- set_expression(first, last, f | regbase::use_except);
- return *this;
- }
-#ifndef BOOST_NO_MEMBER_TEMPLATES
-
- template <class ST, class SA>
- unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal)
- { return set_expression(p.data(), p.data() + p.size(), f); }
-
- template <class ST, class SA>
- explicit reg_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
- : data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) { set_expression(p, f | regbase::use_except); }
-
- template <class I>
- reg_expression(I first, I last, flag_type f = regbase::normal, const Allocator& al = Allocator())
- : data(al), pkmp(0), error_code_(REG_EMPTY), _expression(0)
- {
- size_type len = last-first;
- scoped_array<charT> a(new charT[len]);
- std::copy(first, last, a.get());
- set_expression(a.get(), a.get() + len, f | regbase::use_except);
- }
-
- template <class ST, class SA>
- reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT, ST, SA>& p)
- {
- set_expression(p.c_str(), p.c_str() + p.size(), regbase::normal | regbase::use_except);
- return *this;
- }
-
- template <class string_traits, class A>
- reg_expression& BOOST_REGEX_CALL assign(
- const std::basic_string<charT, string_traits, A>& s,
- flag_type f = regbase::normal)
- {
- set_expression(s.c_str(), s.c_str() + s.size(), f | regbase::use_except);
- return *this;
- }
-
- template <class fwd_iterator>
- reg_expression& BOOST_REGEX_CALL assign(fwd_iterator first,
- fwd_iterator last,
- flag_type f = regbase::normal)
- {
- size_type len = last-first;
- scoped_array<charT> a(new charT[len]);
- std::copy(first, last, a.get());
- set_expression(a.get(), a.get() + len, f | regbase::use_except);
- return *this;
- }
-#else
- unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal)
- { return set_expression(p.data(), p.data() + p.size(), f | regbase::use_except); }
-
- reg_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
- : data(a), pkmp(0) { set_expression(p, f | regbase::use_except); }
-
- reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT>& p)
- {
- set_expression(p.c_str(), p.c_str() + p.size(), regbase::normal | regbase::use_except);
- return *this;
- }
-
- reg_expression& BOOST_REGEX_CALL assign(
- const std::basic_string<charT>& s,
- flag_type f = regbase::normal)
- {
- set_expression(s.c_str(), s.c_str() + s.size(), f | regbase::use_except);
- return *this;
- }
-
-#endif
-
-
- //
- // allocator access:
- Allocator BOOST_REGEX_CALL get_allocator()const;
- //
- // locale:
- locale_type BOOST_REGEX_CALL imbue(locale_type l){ return traits_inst.imbue(l); }
- locale_type BOOST_REGEX_CALL getloc()const{ return traits_inst.getloc(); }
- //
- // flags:
- flag_type BOOST_REGEX_CALL getflags()const
- { return flags(); }
- //
- // str:
- std::basic_string<charT> BOOST_REGEX_CALL str()const
- {
- std::basic_string<charT> result;
- if(this->error_code() == 0)
- result = std::basic_string<charT>(_expression, _expression_len);
- return result;
- }
- //
- // begin, end:
- const_iterator BOOST_REGEX_CALL begin()const
- { return (this->error_code() ? 0 : _expression); }
- const_iterator BOOST_REGEX_CALL end()const
- { return (this->error_code() ? 0 : _expression + _expression_len); }
- //
- // swap:
- void BOOST_REGEX_CALL swap(reg_expression&)throw();
- //
- // size:
- size_type BOOST_REGEX_CALL size()const
- { return (this->error_code() ? 0 : _expression_len); }
- //
- // max_size:
- size_type BOOST_REGEX_CALL max_size()const
- { return UINT_MAX; }
- //
- // empty:
- bool BOOST_REGEX_CALL empty()const
- { return 0 != this->error_code(); }
-
- unsigned BOOST_REGEX_CALL mark_count()const { return (this->error_code() ? 0 : marks); }
- bool BOOST_REGEX_CALL operator==(const reg_expression&)const;
- bool BOOST_REGEX_CALL operator<(const reg_expression&)const;
- //
- // The following are deprecated as public interfaces
- // but are available for compatibility with earlier versions.
- allocator_type BOOST_REGEX_CALL allocator()const;
- const charT* BOOST_REGEX_CALL expression()const { return (this->error_code() ? 0 : _expression); }
- unsigned int BOOST_REGEX_CALL set_expression(const charT* p, const charT* end, flag_type f = regbase::normal);
- unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regbase::normal) { return set_expression(p, p + traits_type::length(p), f); }
- //
- // this should be private but template friends don't work:
- const traits_type& get_traits()const { return traits_inst; }
- unsigned int BOOST_REGEX_CALL error_code()const
- {
- return error_code_;
- }
-
-private:
- traits_type traits_inst;
- re_detail::raw_storage<Allocator> data;
- unsigned _restart_type;
- unsigned marks;
- int repeats;
- unsigned char* startmap;
- std::size_t _expression_len;
- std::size_t _leading_len;
- const charT* _leading_string;
- std::size_t _leading_string_len;
- re_detail::kmp_info<charT>* pkmp;
- unsigned error_code_;
- charT* _expression;
-
- void BOOST_REGEX_CALL compile_maps();
- void BOOST_REGEX_CALL compile_map(re_detail::re_syntax_base* node, unsigned char* _map, unsigned int* pnull, unsigned char mask, re_detail::re_syntax_base* terminal = 0)const;
- bool BOOST_REGEX_CALL probe_start(re_detail::re_syntax_base* node, charT c, re_detail::re_syntax_base* terminal)const;
- bool BOOST_REGEX_CALL probe_start_null(re_detail::re_syntax_base* node, re_detail::re_syntax_base* terminal)const;
- void BOOST_REGEX_CALL fixup_apply(re_detail::re_syntax_base* b, unsigned cbraces);
- void BOOST_REGEX_CALL move_offsets(re_detail::re_syntax_base* j, unsigned size);
- re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set(const charT*& first, const charT* last);
- re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_aux(re_detail::jstack<traits_string_type, Allocator>& singles, re_detail::jstack<traits_string_type, Allocator>& ranges, re_detail::jstack<boost::uint_fast32_t, Allocator>& classes, re_detail::jstack<traits_string_type, Allocator>& equivalents, bool isnot, const re_detail::_narrow_type&);
- re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_aux(re_detail::jstack<traits_string_type, Allocator>& singles, re_detail::jstack<traits_string_type, Allocator>& ranges, re_detail::jstack<boost::uint_fast32_t, Allocator>& classes, re_detail::jstack<traits_string_type, Allocator>& equivalents, bool isnot, const re_detail::_wide_type&);
- re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_simple(re_detail::re_syntax_base* dat, unsigned long cls, bool isnot = false);
- unsigned int BOOST_REGEX_CALL parse_inner_set(const charT*& first, const charT* last);
-
- re_detail::re_syntax_base* BOOST_REGEX_CALL add_simple(re_detail::re_syntax_base* dat, re_detail::syntax_element_type type, unsigned int size = sizeof(re_detail::re_syntax_base));
- re_detail::re_syntax_base* BOOST_REGEX_CALL add_literal(re_detail::re_syntax_base* dat, charT c);
- charT BOOST_REGEX_CALL parse_escape(const charT*& first, const charT* last);
- void BOOST_REGEX_CALL parse_range(const charT*& first, const charT* last, unsigned& min, unsigned& max);
- bool BOOST_REGEX_CALL skip_space(const charT*& first, const charT* last);
- unsigned int BOOST_REGEX_CALL probe_restart(re_detail::re_syntax_base* dat);
- unsigned int BOOST_REGEX_CALL fixup_leading_rep(re_detail::re_syntax_base* dat, re_detail::re_syntax_base* end);
- void BOOST_REGEX_CALL fail(unsigned int err);
-
-protected:
- static int BOOST_REGEX_CALL repeat_count(const reg_expression& e)
- { return e.repeats; }
- static unsigned int BOOST_REGEX_CALL restart_type(const reg_expression& e)
- { return e._restart_type; }
- static const re_detail::re_syntax_base* BOOST_REGEX_CALL first(const reg_expression& e)
- { return (const re_detail::re_syntax_base*)e.data.data(); }
- static const unsigned char* BOOST_REGEX_CALL get_map(const reg_expression& e)
- { return e.startmap; }
- static std::size_t BOOST_REGEX_CALL leading_length(const reg_expression& e)
- { return e._leading_len; }
- static const re_detail::kmp_info<charT>* get_kmp(const reg_expression& e)
- { return e.pkmp; }
- static bool BOOST_REGEX_CALL can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_wide_type&);
- static bool BOOST_REGEX_CALL can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_narrow_type&);
-};
-
-template <class charT, class traits, class Allocator>
-inline void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::swap(reg_expression& that)throw()
-{
- // this is not as efficient as it should be,
- // however swapping traits classes is problematic
- // so just use 'brute force' method for now:
- reg_expression<charT, traits, Allocator> e(that);
- that = *this;
- *this = e;
-}
-
-
-//
-// class match_results and match_results_base
-// handles what matched where
-
-template <class iterator>
-struct sub_match
-{
- typedef typename re_detail::regex_iterator_traits<iterator>::value_type value_type;
-#if defined(BOOST_NO_STD_ITERATOR_TRAITS) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
- typedef std::ptrdiff_t difference_type;
-#else
- typedef typename re_detail::regex_iterator_traits<iterator>::difference_type difference_type;
-#endif
- typedef iterator iterator_type;
-
- iterator first;
- iterator second;
- bool matched;
-
- operator std::basic_string<value_type> ()const
- {
- std::basic_string<value_type> result;
- std::size_t len = boost::re_detail::distance((iterator)first, (iterator)second);
- result.reserve(len);
- iterator i = first;
- while(i != second)
- {
- result.append(1, *i);
- ++i;
- }
- return result;
- }
- #ifdef BOOST_OLD_REGEX_H
- //
- // the following are deprecated, do not use!!
- //
- operator int()const;
- operator unsigned int()const;
- operator short()const
- {
- return (short)(int)(*this);
- }
- operator unsigned short()const
- {
- return (unsigned short)(unsigned int)(*this);
- }
- #endif
- sub_match() { matched = false; }
- sub_match(iterator i) : first(i), second(i), matched(false) {}
-
- bool operator==(const sub_match& that)const
- {
- return (first == that.first) && (second == that.second) && (matched == that.matched);
- }
- bool BOOST_REGEX_CALL operator !=(const sub_match& that)const
- { return !(*this == that); }
-
- difference_type BOOST_REGEX_CALL length()const
- {
- difference_type n = boost::re_detail::distance((iterator)first, (iterator)second);
- return n;
- }
-};
-
-#ifdef BOOST_OLD_REGEX_H
-namespace re_detail{
-template <class iterator, class charT>
-int do_toi(iterator i, iterator j, char c, int radix)
-{
- std::string s(i, j);
- char* p;
- int result = std::strtol(s.c_str(), &p, radix);
-#ifndef BOOST_NO_EXCEPTIONS
- if(*p)throw bad_pattern("Bad sub-expression");
-#endif
- BOOST_REGEX_NOEH_ASSERT(0 == *p)
- return result;
-}
-
-//
-// helper:
-template <class I, class charT>
-int do_toi(I& i, I j, charT c)
-{
- int result = 0;
- while((i != j) && (isdigit(*i)))
- {
- result = result*10 + (*i - '0');
- ++i;
- }
- return result;
-}
-}
-
-
-template <class iterator>
-sub_match<iterator>::operator int()const
-{
- iterator i = first;
- iterator j = second;
-#ifndef BOOST_NO_EXCEPTIONS
- if(i == j)throw bad_pattern("Bad sub-expression");