Chris@16: /* Chris@16: * Chris@16: * Copyright (c) 1998-2004 John Maddock Chris@16: * Copyright 2011 Garmin Ltd. or its subsidiaries Chris@16: * Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: * Chris@16: */ Chris@16: Chris@16: /* Chris@16: * LOCATION: see http://www.boost.org/ for most recent version. Chris@16: * FILE basic_regex.cpp Chris@16: * VERSION see Chris@16: * DESCRIPTION: Declares template class basic_regex. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_REGEX_V4_BASIC_REGEX_HPP Chris@16: #define BOOST_REGEX_V4_BASIC_REGEX_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(push) Chris@16: #pragma warning(disable: 4103) Chris@16: #endif Chris@16: #ifdef BOOST_HAS_ABI_HEADERS Chris@16: # include BOOST_ABI_PREFIX Chris@16: #endif Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: Chris@16: namespace boost{ Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(push) Chris@16: #pragma warning(disable : 4251 4231 4800) Chris@16: #if BOOST_MSVC < 1600 Chris@16: #pragma warning(disable : 4660) Chris@16: #endif Chris@16: #endif Chris@16: Chris@16: namespace re_detail{ Chris@16: Chris@16: // Chris@16: // forward declaration, we will need this one later: Chris@16: // Chris@16: template Chris@16: class basic_regex_parser; Chris@16: Chris@16: template Chris@16: void bubble_down_one(I first, I last) Chris@16: { Chris@16: if(first != last) Chris@16: { Chris@16: I next = last - 1; Chris@16: while((next != first) && (*next < *(next-1))) Chris@16: { Chris@16: (next-1)->swap(*next); Chris@16: --next; Chris@16: } Chris@16: } Chris@16: } Chris@16: Chris@16: template Chris@16: inline int hash_value_from_capture_name(Iterator i, Iterator j) Chris@16: { Chris@16: std::size_t r = boost::hash_range(i, j); Chris@16: r %= ((std::numeric_limits::max)() - 10001); Chris@16: r += 10000; Chris@16: return static_cast(r); Chris@16: } Chris@16: Chris@16: class named_subexpressions Chris@16: { Chris@16: public: Chris@16: struct name Chris@16: { Chris@16: template Chris@16: name(const charT* i, const charT* j, int idx) Chris@16: : index(idx) Chris@16: { Chris@16: hash = hash_value_from_capture_name(i, j); Chris@16: } Chris@16: name(int h, int idx) Chris@16: : index(idx), hash(h) Chris@16: { Chris@16: } Chris@16: int index; Chris@16: int hash; Chris@16: bool operator < (const name& other)const Chris@16: { Chris@16: return hash < other.hash; Chris@16: } Chris@16: bool operator == (const name& other)const Chris@16: { Chris@16: return hash == other.hash; Chris@16: } Chris@16: void swap(name& other) Chris@16: { Chris@16: std::swap(index, other.index); Chris@16: std::swap(hash, other.hash); Chris@16: } Chris@16: }; Chris@16: Chris@16: typedef std::vector::const_iterator const_iterator; Chris@16: typedef std::pair range_type; Chris@16: Chris@16: named_subexpressions(){} Chris@16: Chris@16: template Chris@16: void set_name(const charT* i, const charT* j, int index) Chris@16: { Chris@16: m_sub_names.push_back(name(i, j, index)); Chris@16: bubble_down_one(m_sub_names.begin(), m_sub_names.end()); Chris@16: } Chris@16: template Chris@16: int get_id(const charT* i, const charT* j)const Chris@16: { Chris@16: name t(i, j, 0); Chris@16: typename std::vector::const_iterator pos = std::lower_bound(m_sub_names.begin(), m_sub_names.end(), t); Chris@16: if((pos != m_sub_names.end()) && (*pos == t)) Chris@16: { Chris@16: return pos->index; Chris@16: } Chris@16: return -1; Chris@16: } Chris@16: template Chris@16: range_type equal_range(const charT* i, const charT* j)const Chris@16: { Chris@16: name t(i, j, 0); Chris@16: return std::equal_range(m_sub_names.begin(), m_sub_names.end(), t); Chris@16: } Chris@16: int get_id(int h)const Chris@16: { Chris@16: name t(h, 0); Chris@16: std::vector::const_iterator pos = std::lower_bound(m_sub_names.begin(), m_sub_names.end(), t); Chris@16: if((pos != m_sub_names.end()) && (*pos == t)) Chris@16: { Chris@16: return pos->index; Chris@16: } Chris@16: return -1; Chris@16: } Chris@16: range_type equal_range(int h)const Chris@16: { Chris@16: name t(h, 0); Chris@16: return std::equal_range(m_sub_names.begin(), m_sub_names.end(), t); Chris@16: } Chris@16: private: Chris@16: std::vector m_sub_names; Chris@16: }; Chris@16: Chris@16: // Chris@16: // class regex_data: Chris@16: // represents the data we wish to expose to the matching algorithms. Chris@16: // Chris@16: template Chris@16: struct regex_data : public named_subexpressions Chris@16: { Chris@16: typedef regex_constants::syntax_option_type flag_type; Chris@16: typedef std::size_t size_type; Chris@16: Chris@16: regex_data(const ::boost::shared_ptr< Chris@16: ::boost::regex_traits_wrapper >& t) Chris@16: : m_ptraits(t), m_expression(0), m_expression_len(0) {} Chris@16: regex_data() Chris@16: : m_ptraits(new ::boost::regex_traits_wrapper()), m_expression(0), m_expression_len(0) {} Chris@16: Chris@16: ::boost::shared_ptr< Chris@16: ::boost::regex_traits_wrapper Chris@16: > m_ptraits; // traits class instance Chris@16: flag_type m_flags; // flags with which we were compiled Chris@16: int m_status; // error code (0 implies OK). Chris@16: const charT* m_expression; // the original expression Chris@16: std::ptrdiff_t m_expression_len; // the length of the original expression Chris@16: size_type m_mark_count; // the number of marked sub-expressions Chris@16: re_detail::re_syntax_base* m_first_state; // the first state of the machine Chris@16: unsigned m_restart_type; // search optimisation type Chris@16: unsigned char m_startmap[1 << CHAR_BIT]; // which characters can start a match Chris@16: unsigned int m_can_be_null; // whether we can match a null string Chris@16: re_detail::raw_storage m_data; // the buffer in which our states are constructed Chris@16: typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character Chris@16: std::vector< Chris@16: std::pair< Chris@16: std::size_t, std::size_t> > m_subs; // Position of sub-expressions within the *string*. Chris@16: bool m_has_recursions; // whether we have recursive expressions; Chris@16: }; Chris@16: // Chris@16: // class basic_regex_implementation Chris@16: // pimpl implementation class for basic_regex. Chris@16: // Chris@16: template Chris@16: class basic_regex_implementation Chris@16: : public regex_data Chris@16: { Chris@16: public: Chris@16: typedef regex_constants::syntax_option_type flag_type; Chris@16: typedef std::ptrdiff_t difference_type; Chris@16: typedef std::size_t size_type; Chris@16: typedef typename traits::locale_type locale_type; Chris@16: typedef const charT* const_iterator; Chris@16: Chris@16: basic_regex_implementation(){} Chris@16: basic_regex_implementation(const ::boost::shared_ptr< Chris@16: ::boost::regex_traits_wrapper >& t) Chris@16: : regex_data(t) {} Chris@16: void assign(const charT* arg_first, Chris@16: const charT* arg_last, Chris@16: flag_type f) Chris@16: { Chris@16: regex_data* pdat = this; Chris@16: basic_regex_parser parser(pdat); Chris@16: parser.parse(arg_first, arg_last, f); Chris@16: } Chris@16: Chris@16: locale_type BOOST_REGEX_CALL imbue(locale_type l) Chris@16: { Chris@16: return this->m_ptraits->imbue(l); Chris@16: } Chris@16: locale_type BOOST_REGEX_CALL getloc()const Chris@16: { Chris@16: return this->m_ptraits->getloc(); Chris@16: } Chris@16: std::basic_string BOOST_REGEX_CALL str()const Chris@16: { Chris@16: std::basic_string result; Chris@16: if(this->m_status == 0) Chris@16: result = std::basic_string(this->m_expression, this->m_expression_len); Chris@16: return result; Chris@16: } Chris@16: const_iterator BOOST_REGEX_CALL expression()const Chris@16: { Chris@16: return this->m_expression; Chris@16: } Chris@16: std::pair BOOST_REGEX_CALL subexpression(std::size_t n)const Chris@16: { Chris@101: const std::pair& pi = this->m_subs.at(n); Chris@16: std::pair p(expression() + pi.first, expression() + pi.second); Chris@16: return p; Chris@16: } Chris@16: // Chris@16: // begin, end: Chris@16: const_iterator BOOST_REGEX_CALL begin()const Chris@16: { Chris@16: return (this->m_status ? 0 : this->m_expression); Chris@16: } Chris@16: const_iterator BOOST_REGEX_CALL end()const Chris@16: { Chris@16: return (this->m_status ? 0 : this->m_expression + this->m_expression_len); Chris@16: } Chris@16: flag_type BOOST_REGEX_CALL flags()const Chris@16: { Chris@16: return this->m_flags; Chris@16: } Chris@16: size_type BOOST_REGEX_CALL size()const Chris@16: { Chris@16: return this->m_expression_len; Chris@16: } Chris@16: int BOOST_REGEX_CALL status()const Chris@16: { Chris@16: return this->m_status; Chris@16: } Chris@16: size_type BOOST_REGEX_CALL mark_count()const Chris@16: { Chris@101: return this->m_mark_count - 1; Chris@16: } Chris@16: const re_detail::re_syntax_base* get_first_state()const Chris@16: { Chris@16: return this->m_first_state; Chris@16: } Chris@16: unsigned get_restart_type()const Chris@16: { Chris@16: return this->m_restart_type; Chris@16: } Chris@16: const unsigned char* get_map()const Chris@16: { Chris@16: return this->m_startmap; Chris@16: } Chris@16: const ::boost::regex_traits_wrapper& get_traits()const Chris@16: { Chris@16: return *(this->m_ptraits); Chris@16: } Chris@16: bool can_be_null()const Chris@16: { Chris@16: return this->m_can_be_null; Chris@16: } Chris@16: const regex_data& get_data()const Chris@16: { Chris@16: basic_regex_implementation const* p = this; Chris@16: return *static_cast*>(p); Chris@16: } Chris@16: }; Chris@16: Chris@16: } // namespace re_detail Chris@16: // Chris@16: // class basic_regex: Chris@16: // represents the compiled Chris@16: // regular expression: Chris@16: // Chris@16: Chris@16: #ifdef BOOST_REGEX_NO_FWD Chris@16: template > Chris@16: #else Chris@16: template Chris@16: #endif Chris@16: class basic_regex : public regbase Chris@16: { Chris@16: public: Chris@16: // typedefs: Chris@16: typedef std::size_t traits_size_type; Chris@16: typedef typename traits::string_type traits_string_type; Chris@16: typedef charT char_type; Chris@16: typedef traits traits_type; Chris@16: Chris@16: typedef charT value_type; Chris@16: typedef charT& reference; Chris@16: typedef const charT& const_reference; Chris@16: typedef const charT* const_iterator; Chris@16: typedef const_iterator iterator; Chris@16: typedef std::ptrdiff_t difference_type; Chris@16: typedef std::size_t size_type; Chris@16: typedef regex_constants::syntax_option_type flag_type; Chris@16: // locale_type Chris@16: // placeholder for actual locale type used by the Chris@16: // traits class to localise *this. Chris@16: typedef typename traits::locale_type locale_type; Chris@16: Chris@16: public: Chris@16: explicit basic_regex(){} Chris@16: explicit basic_regex(const charT* p, flag_type f = regex_constants::normal) Chris@16: { Chris@16: assign(p, f); Chris@16: } Chris@16: basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) Chris@16: { Chris@16: assign(p1, p2, f); Chris@16: } Chris@16: basic_regex(const charT* p, size_type len, flag_type f) Chris@16: { Chris@16: assign(p, len, f); Chris@16: } Chris@16: basic_regex(const basic_regex& that) Chris@16: : m_pimpl(that.m_pimpl) {} Chris@16: ~basic_regex(){} Chris@16: basic_regex& BOOST_REGEX_CALL operator=(const basic_regex& that) Chris@16: { Chris@16: return assign(that); Chris@16: } Chris@16: basic_regex& BOOST_REGEX_CALL operator=(const charT* ptr) Chris@16: { Chris@16: return assign(ptr); Chris@16: } Chris@16: Chris@16: // Chris@16: // assign: Chris@16: basic_regex& assign(const basic_regex& that) Chris@16: { Chris@16: m_pimpl = that.m_pimpl; Chris@16: return *this; Chris@16: } Chris@16: basic_regex& assign(const charT* p, flag_type f = regex_constants::normal) Chris@16: { Chris@16: return assign(p, p + traits::length(p), f); Chris@16: } Chris@16: basic_regex& assign(const charT* p, size_type len, flag_type f) Chris@16: { Chris@16: return assign(p, p + len, f); Chris@16: } Chris@16: private: Chris@16: basic_regex& do_assign(const charT* p1, Chris@16: const charT* p2, Chris@16: flag_type f); Chris@16: public: Chris@16: basic_regex& assign(const charT* p1, Chris@16: const charT* p2, Chris@16: flag_type f = regex_constants::normal) Chris@16: { Chris@16: return do_assign(p1, p2, f); Chris@16: } Chris@16: #if !defined(BOOST_NO_MEMBER_TEMPLATES) Chris@16: Chris@16: template Chris@16: unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regex_constants::normal) Chris@16: { Chris@16: return set_expression(p.data(), p.data() + p.size(), f); Chris@16: } Chris@16: Chris@16: template Chris@16: explicit basic_regex(const std::basic_string& p, flag_type f = regex_constants::normal) Chris@16: { Chris@16: assign(p, f); Chris@16: } Chris@16: Chris@16: template Chris@16: basic_regex(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal) Chris@16: { Chris@16: typedef typename traits::string_type seq_type; Chris@16: seq_type a(arg_first, arg_last); Chris@16: if(a.size()) Chris@16: assign(static_cast(&*a.begin()), static_cast(&*a.begin() + a.size()), f); Chris@16: else Chris@16: assign(static_cast(0), static_cast(0), f); Chris@16: } Chris@16: Chris@16: template Chris@16: basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string& p) Chris@16: { Chris@16: return assign(p.data(), p.data() + p.size(), regex_constants::normal); Chris@16: } Chris@16: Chris@16: template Chris@16: basic_regex& BOOST_REGEX_CALL assign( Chris@16: const std::basic_string& s, Chris@16: flag_type f = regex_constants::normal) Chris@16: { Chris@16: return assign(s.data(), s.data() + s.size(), f); Chris@16: } Chris@16: Chris@16: template Chris@16: basic_regex& BOOST_REGEX_CALL assign(InputIterator arg_first, Chris@16: InputIterator arg_last, Chris@16: flag_type f = regex_constants::normal) Chris@16: { Chris@16: typedef typename traits::string_type seq_type; Chris@16: seq_type a(arg_first, arg_last); Chris@16: if(a.size()) Chris@16: { Chris@16: const charT* p1 = &*a.begin(); Chris@16: const charT* p2 = &*a.begin() + a.size(); Chris@16: return assign(p1, p2, f); Chris@16: } Chris@16: return assign(static_cast(0), static_cast(0), f); Chris@16: } Chris@16: #else Chris@16: unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regex_constants::normal) Chris@16: { Chris@16: return set_expression(p.data(), p.data() + p.size(), f); Chris@16: } Chris@16: Chris@16: basic_regex(const std::basic_string& p, flag_type f = regex_constants::normal) Chris@16: { Chris@16: assign(p, f); Chris@16: } Chris@16: Chris@16: basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string& p) Chris@16: { Chris@16: return assign(p.data(), p.data() + p.size(), regex_constants::normal); Chris@16: } Chris@16: Chris@16: basic_regex& BOOST_REGEX_CALL assign( Chris@16: const std::basic_string& s, Chris@16: flag_type f = regex_constants::normal) Chris@16: { Chris@16: return assign(s.data(), s.data() + s.size(), f); Chris@16: } Chris@16: Chris@16: #endif Chris@16: Chris@16: // Chris@16: // locale: Chris@16: locale_type BOOST_REGEX_CALL imbue(locale_type l); Chris@16: locale_type BOOST_REGEX_CALL getloc()const Chris@16: { Chris@16: return m_pimpl.get() ? m_pimpl->getloc() : locale_type(); Chris@16: } Chris@16: // Chris@16: // getflags: Chris@16: // retained for backwards compatibility only, "flags" Chris@16: // is now the preferred name: Chris@16: flag_type BOOST_REGEX_CALL getflags()const Chris@16: { Chris@16: return flags(); Chris@16: } Chris@16: flag_type BOOST_REGEX_CALL flags()const Chris@16: { Chris@16: return m_pimpl.get() ? m_pimpl->flags() : 0; Chris@16: } Chris@16: // Chris@16: // str: Chris@16: std::basic_string BOOST_REGEX_CALL str()const Chris@16: { Chris@16: return m_pimpl.get() ? m_pimpl->str() : std::basic_string(); Chris@16: } Chris@16: // Chris@16: // begin, end, subexpression: Chris@16: std::pair BOOST_REGEX_CALL subexpression(std::size_t n)const Chris@16: { Chris@16: if(!m_pimpl.get()) Chris@16: boost::throw_exception(std::logic_error("Can't access subexpressions in an invalid regex.")); Chris@16: return m_pimpl->subexpression(n); Chris@16: } Chris@16: const_iterator BOOST_REGEX_CALL begin()const Chris@16: { Chris@16: return (m_pimpl.get() ? m_pimpl->begin() : 0); Chris@16: } Chris@16: const_iterator BOOST_REGEX_CALL end()const Chris@16: { Chris@16: return (m_pimpl.get() ? m_pimpl->end() : 0); Chris@16: } Chris@16: // Chris@16: // swap: Chris@16: void BOOST_REGEX_CALL swap(basic_regex& that)throw() Chris@16: { Chris@16: m_pimpl.swap(that.m_pimpl); Chris@16: } Chris@16: // Chris@16: // size: Chris@16: size_type BOOST_REGEX_CALL size()const Chris@16: { Chris@16: return (m_pimpl.get() ? m_pimpl->size() : 0); Chris@16: } Chris@16: // Chris@16: // max_size: Chris@16: size_type BOOST_REGEX_CALL max_size()const Chris@16: { Chris@16: return UINT_MAX; Chris@16: } Chris@16: // Chris@16: // empty: Chris@16: bool BOOST_REGEX_CALL empty()const Chris@16: { Chris@16: return (m_pimpl.get() ? 0 != m_pimpl->status() : true); Chris@16: } Chris@16: Chris@16: size_type BOOST_REGEX_CALL mark_count()const Chris@16: { Chris@16: return (m_pimpl.get() ? m_pimpl->mark_count() : 0); Chris@16: } Chris@16: Chris@16: int status()const Chris@16: { Chris@16: return (m_pimpl.get() ? m_pimpl->status() : regex_constants::error_empty); Chris@16: } Chris@16: Chris@16: int BOOST_REGEX_CALL compare(const basic_regex& that) const Chris@16: { Chris@16: if(m_pimpl.get() == that.m_pimpl.get()) Chris@16: return 0; Chris@16: if(!m_pimpl.get()) Chris@16: return -1; Chris@16: if(!that.m_pimpl.get()) Chris@16: return 1; Chris@16: if(status() != that.status()) Chris@16: return status() - that.status(); Chris@16: if(flags() != that.flags()) Chris@16: return flags() - that.flags(); Chris@16: return str().compare(that.str()); Chris@16: } Chris@16: bool BOOST_REGEX_CALL operator==(const basic_regex& e)const Chris@16: { Chris@16: return compare(e) == 0; Chris@16: } Chris@16: bool BOOST_REGEX_CALL operator != (const basic_regex& e)const Chris@16: { Chris@16: return compare(e) != 0; Chris@16: } Chris@16: bool BOOST_REGEX_CALL operator<(const basic_regex& e)const Chris@16: { Chris@16: return compare(e) < 0; Chris@16: } Chris@16: bool BOOST_REGEX_CALL operator>(const basic_regex& e)const Chris@16: { Chris@16: return compare(e) > 0; Chris@16: } Chris@16: bool BOOST_REGEX_CALL operator<=(const basic_regex& e)const Chris@16: { Chris@16: return compare(e) <= 0; Chris@16: } Chris@16: bool BOOST_REGEX_CALL operator>=(const basic_regex& e)const Chris@16: { Chris@16: return compare(e) >= 0; Chris@16: } Chris@16: Chris@16: // Chris@16: // The following are deprecated as public interfaces Chris@16: // but are available for compatibility with earlier versions. Chris@16: const charT* BOOST_REGEX_CALL expression()const Chris@16: { Chris@16: return (m_pimpl.get() && !m_pimpl->status() ? m_pimpl->expression() : 0); Chris@16: } Chris@16: unsigned int BOOST_REGEX_CALL set_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) Chris@16: { Chris@16: assign(p1, p2, f | regex_constants::no_except); Chris@16: return status(); Chris@16: } Chris@16: unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regex_constants::normal) Chris@16: { Chris@16: assign(p, f | regex_constants::no_except); Chris@16: return status(); Chris@16: } Chris@16: unsigned int BOOST_REGEX_CALL error_code()const Chris@16: { Chris@16: return status(); Chris@16: } Chris@16: // Chris@16: // private access methods: Chris@16: // Chris@16: const re_detail::re_syntax_base* get_first_state()const Chris@16: { Chris@16: BOOST_ASSERT(0 != m_pimpl.get()); Chris@16: return m_pimpl->get_first_state(); Chris@16: } Chris@16: unsigned get_restart_type()const Chris@16: { Chris@16: BOOST_ASSERT(0 != m_pimpl.get()); Chris@16: return m_pimpl->get_restart_type(); Chris@16: } Chris@16: const unsigned char* get_map()const Chris@16: { Chris@16: BOOST_ASSERT(0 != m_pimpl.get()); Chris@16: return m_pimpl->get_map(); Chris@16: } Chris@16: const ::boost::regex_traits_wrapper& get_traits()const Chris@16: { Chris@16: BOOST_ASSERT(0 != m_pimpl.get()); Chris@16: return m_pimpl->get_traits(); Chris@16: } Chris@16: bool can_be_null()const Chris@16: { Chris@16: BOOST_ASSERT(0 != m_pimpl.get()); Chris@16: return m_pimpl->can_be_null(); Chris@16: } Chris@16: const re_detail::regex_data& get_data()const Chris@16: { Chris@16: BOOST_ASSERT(0 != m_pimpl.get()); Chris@16: return m_pimpl->get_data(); Chris@16: } Chris@16: boost::shared_ptr get_named_subs()const Chris@16: { Chris@16: return m_pimpl; Chris@16: } Chris@16: Chris@16: private: Chris@16: shared_ptr > m_pimpl; Chris@16: }; Chris@16: Chris@16: // Chris@16: // out of line members; Chris@16: // these are the only members that mutate the basic_regex object, Chris@16: // and are designed to provide the strong exception guarentee Chris@16: // (in the event of a throw, the state of the object remains unchanged). Chris@16: // Chris@16: template Chris@16: basic_regex& basic_regex::do_assign(const charT* p1, Chris@16: const charT* p2, Chris@16: flag_type f) Chris@16: { Chris@16: shared_ptr > temp; Chris@16: if(!m_pimpl.get()) Chris@16: { Chris@16: temp = shared_ptr >(new re_detail::basic_regex_implementation()); Chris@16: } Chris@16: else Chris@16: { Chris@16: temp = shared_ptr >(new re_detail::basic_regex_implementation(m_pimpl->m_ptraits)); Chris@16: } Chris@16: temp->assign(p1, p2, f); Chris@16: temp.swap(m_pimpl); Chris@16: return *this; Chris@16: } Chris@16: Chris@16: template Chris@16: typename basic_regex::locale_type BOOST_REGEX_CALL basic_regex::imbue(locale_type l) Chris@16: { Chris@16: shared_ptr > temp(new re_detail::basic_regex_implementation()); Chris@16: locale_type result = temp->imbue(l); Chris@16: temp.swap(m_pimpl); Chris@16: return result; Chris@16: } Chris@16: Chris@16: // Chris@16: // non-members: Chris@16: // Chris@16: template Chris@16: void swap(basic_regex& e1, basic_regex& e2) Chris@16: { Chris@16: e1.swap(e2); Chris@16: } Chris@16: Chris@16: #ifndef BOOST_NO_STD_LOCALE Chris@16: template Chris@16: std::basic_ostream& Chris@16: operator << (std::basic_ostream& os, Chris@16: const basic_regex& e) Chris@16: { Chris@16: return (os << e.str()); Chris@16: } Chris@16: #else Chris@16: template Chris@16: std::ostream& operator << (std::ostream& os, const basic_regex& e) Chris@16: { Chris@16: return (os << e.str()); Chris@16: } Chris@16: #endif Chris@16: Chris@16: // Chris@16: // class reg_expression: Chris@16: // this is provided for backwards compatibility only, Chris@16: // it is deprecated, no not use! Chris@16: // Chris@16: #ifdef BOOST_REGEX_NO_FWD Chris@16: template > Chris@16: #else Chris@16: template Chris@16: #endif Chris@16: class reg_expression : public basic_regex Chris@16: { Chris@16: public: Chris@16: typedef typename basic_regex::flag_type flag_type; Chris@16: typedef typename basic_regex::size_type size_type; Chris@16: explicit reg_expression(){} Chris@16: explicit reg_expression(const charT* p, flag_type f = regex_constants::normal) Chris@16: : basic_regex(p, f){} Chris@16: reg_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) Chris@16: : basic_regex(p1, p2, f){} Chris@16: reg_expression(const charT* p, size_type len, flag_type f) Chris@16: : basic_regex(p, len, f){} Chris@16: reg_expression(const reg_expression& that) Chris@16: : basic_regex(that) {} Chris@16: ~reg_expression(){} Chris@16: reg_expression& BOOST_REGEX_CALL operator=(const reg_expression& that) Chris@16: { Chris@16: return this->assign(that); Chris@16: } Chris@16: Chris@16: #if !defined(BOOST_NO_MEMBER_TEMPLATES) Chris@16: template Chris@16: explicit reg_expression(const std::basic_string& p, flag_type f = regex_constants::normal) Chris@16: : basic_regex(p, f) Chris@16: { Chris@16: } Chris@16: Chris@16: template Chris@16: reg_expression(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal) Chris@16: : basic_regex(arg_first, arg_last, f) Chris@16: { Chris@16: } Chris@16: Chris@16: template Chris@16: reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string& p) Chris@16: { Chris@16: this->assign(p); Chris@16: return *this; Chris@16: } Chris@16: #else Chris@16: explicit reg_expression(const std::basic_string& p, flag_type f = regex_constants::normal) Chris@16: : basic_regex(p, f) Chris@16: { Chris@16: } Chris@16: Chris@16: reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string& p) Chris@16: { Chris@16: this->assign(p); Chris@16: return *this; Chris@16: } Chris@16: #endif Chris@16: Chris@16: }; Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning (pop) Chris@16: #endif Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(push) Chris@16: #pragma warning(disable: 4103) Chris@16: #endif Chris@16: #ifdef BOOST_HAS_ABI_HEADERS Chris@16: # include BOOST_ABI_SUFFIX Chris@16: #endif Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: Chris@16: #endif Chris@16: