forked from boostorg/regex
Make cpp_regex_traits all inline.
This commit is contained in:
@ -29,13 +29,13 @@
|
||||
#include <boost/regex/pattern_except.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED
|
||||
#include <boost/regex/v4/regex_traits_defaults.hpp>
|
||||
#include <boost/regex/v5/regex_traits_defaults.hpp>
|
||||
#endif
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
#include <boost/regex/pending/static_mutex.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_REGEX_PRIMARY_TRANSFORM
|
||||
#include <boost/regex/v4/primary_transform.hpp>
|
||||
#include <boost/regex/v5/primary_transform.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_REGEX_OBJECT_CACHE_HPP
|
||||
#include <boost/regex/pending/object_cache.hpp>
|
||||
@ -355,7 +355,7 @@ typename cpp_regex_traits_char_layer<charT>::string_type
|
||||
// specialized version for narrow characters:
|
||||
//
|
||||
template <>
|
||||
class BOOST_REGEX_DECL cpp_regex_traits_char_layer<char> : public cpp_regex_traits_base<char>
|
||||
class cpp_regex_traits_char_layer<char> : public cpp_regex_traits_base<char>
|
||||
{
|
||||
typedef std::string string_type;
|
||||
public:
|
||||
@ -1129,6 +1129,92 @@ static_mutex& cpp_regex_traits<charT>::get_mutex_inst()
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace BOOST_REGEX_DETAIL_NS {
|
||||
|
||||
inline void cpp_regex_traits_char_layer<char>::init()
|
||||
{
|
||||
// we need to start by initialising our syntax map so we know which
|
||||
// character is used for which purpose:
|
||||
std::memset(m_char_map, 0, sizeof(m_char_map));
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
#ifndef __IBMCPP__
|
||||
std::messages<char>::catalog cat = static_cast<std::messages<char>::catalog>(-1);
|
||||
#else
|
||||
std::messages<char>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1);
|
||||
#endif
|
||||
std::string cat_name(cpp_regex_traits<char>::get_catalog_name());
|
||||
if ((!cat_name.empty()) && (m_pmessages != 0))
|
||||
{
|
||||
cat = this->m_pmessages->open(
|
||||
cat_name,
|
||||
this->m_locale);
|
||||
if ((int)cat < 0)
|
||||
{
|
||||
std::string m("Unable to open message catalog: ");
|
||||
std::runtime_error err(m + cat_name);
|
||||
boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err);
|
||||
}
|
||||
}
|
||||
//
|
||||
// if we have a valid catalog then load our messages:
|
||||
//
|
||||
if ((int)cat >= 0)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
for (regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
|
||||
{
|
||||
string_type mss = this->m_pmessages->get(cat, 0, i, get_default_syntax(i));
|
||||
for (string_type::size_type j = 0; j < mss.size(); ++j)
|
||||
{
|
||||
m_char_map[static_cast<unsigned char>(mss[j])] = i;
|
||||
}
|
||||
}
|
||||
this->m_pmessages->close(cat);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->m_pmessages->close(cat);
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
for (regex_constants::syntax_type j = 1; j < regex_constants::syntax_max; ++j)
|
||||
{
|
||||
const char* ptr = get_default_syntax(j);
|
||||
while (ptr && *ptr)
|
||||
{
|
||||
m_char_map[static_cast<unsigned char>(*ptr)] = j;
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
}
|
||||
#endif
|
||||
//
|
||||
// finish off by calculating our escape types:
|
||||
//
|
||||
unsigned char i = 'A';
|
||||
do
|
||||
{
|
||||
if (m_char_map[i] == 0)
|
||||
{
|
||||
if (this->m_pctype->is(std::ctype_base::lower, i))
|
||||
m_char_map[i] = regex_constants::escape_type_class;
|
||||
else if (this->m_pctype->is(std::ctype_base::upper, i))
|
||||
m_char_map[i] = regex_constants::escape_type_not_class;
|
||||
}
|
||||
} while (0xFF != i++);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
} // boost
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
|
Reference in New Issue
Block a user