forked from boostorg/regex
Add module support and tests. (#174)
This commit is contained in:
@ -25,10 +25,12 @@
|
||||
#include <boost/regex/v5/states.hpp>
|
||||
#include <boost/regex/v5/regex_raw_buffer.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
@ -67,7 +69,12 @@ void bubble_down_one(I first, I last)
|
||||
}
|
||||
}
|
||||
|
||||
static const int hash_value_mask = 1 << (std::numeric_limits<int>::digits - 1);
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
static
|
||||
#else
|
||||
inline
|
||||
#endif
|
||||
const int hash_value_mask = 1 << (std::numeric_limits<int>::digits - 1);
|
||||
|
||||
template <class Iterator>
|
||||
inline int hash_value_from_capture_name(Iterator i, Iterator j)
|
||||
@ -315,7 +322,7 @@ public:
|
||||
// represents the compiled
|
||||
// regular expression:
|
||||
//
|
||||
|
||||
BOOST_REGEX_MODULE_EXPORT
|
||||
#ifdef BOOST_REGEX_NO_FWD
|
||||
template <class charT, class traits = regex_traits<charT> >
|
||||
#else
|
||||
@ -652,22 +659,38 @@ private:
|
||||
// and are designed to provide the strong exception guarantee
|
||||
// (in the event of a throw, the state of the object remains unchanged).
|
||||
//
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <class charT, class F, class Traits>
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits> > create_implemenation(const charT* p1, const charT* p2, F f, std::shared_ptr<boost::regex_traits_wrapper<Traits> > ptraits)
|
||||
{
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits> > result;
|
||||
if (!ptraits.get())
|
||||
{
|
||||
result = std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits>());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits>(ptraits));
|
||||
}
|
||||
result->assign(p1, p2, f);
|
||||
return result;
|
||||
}
|
||||
#ifdef BOOST_REGEX_AS_MODULE
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<char, basic_regex<char>::traits_type> >
|
||||
create_implemenation(const char* p1, const char* p2, basic_regex<char>::flag_type f, std::shared_ptr<boost::regex_traits_wrapper<basic_regex<char>::traits_type> > ptraits);
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<wchar_t, basic_regex<wchar_t>::traits_type> >
|
||||
create_implemenation(const wchar_t* p1, const wchar_t* p2, basic_regex<wchar_t>::flag_type f, std::shared_ptr<boost::regex_traits_wrapper<basic_regex<wchar_t>::traits_type> > ptraits);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class charT, class traits>
|
||||
basic_regex<charT, traits>& basic_regex<charT, traits>::do_assign(const charT* p1,
|
||||
const charT* p2,
|
||||
flag_type f)
|
||||
{
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> > temp;
|
||||
if(!m_pimpl.get())
|
||||
{
|
||||
temp = std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>());
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>(m_pimpl->m_ptraits));
|
||||
}
|
||||
temp->assign(p1, p2, f);
|
||||
temp.swap(m_pimpl);
|
||||
m_pimpl = detail::create_implemenation(p1, p2, f, m_pimpl.get() ? m_pimpl->m_ptraits : std::shared_ptr<boost::regex_traits_wrapper<traits> >());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -683,13 +706,13 @@ typename basic_regex<charT, traits>::locale_type basic_regex<charT, traits>::im
|
||||
//
|
||||
// non-members:
|
||||
//
|
||||
template <class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits>
|
||||
void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2)
|
||||
{
|
||||
e1.swap(e2);
|
||||
}
|
||||
|
||||
template <class charT, class traits, class traits2>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits, class traits2>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator << (std::basic_ostream<charT, traits>& os,
|
||||
const basic_regex<charT, traits2>& e)
|
||||
|
Reference in New Issue
Block a user