#include <boost/regex/v4/primary_transform.hpp>
#endif
#ifndef BOOST_REGEX_OBJECT_CACHE_HPP
-#include <boost/regex/pending/object_cache.hpp>
+#include <boost/regex/v4/object_cache.hpp>
#endif
-#include <istream>
-#include <ios>
#include <climits>
+#include <ios>
+#include <istream>
#ifdef BOOST_MSVC
#pragma warning(push)
parser_buf() : base_type() { setbuf(0, 0); }
const charT* getnext() { return this->gptr(); }
protected:
- std::basic_streambuf<charT, traits>* setbuf(char_type* s, streamsize n);
- typename parser_buf<charT, traits>::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which);
- typename parser_buf<charT, traits>::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which);
+ std::basic_streambuf<charT, traits>* setbuf(char_type* s, streamsize n) BOOST_OVERRIDE;
+ typename parser_buf<charT, traits>::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which) BOOST_OVERRIDE;
+ typename parser_buf<charT, traits>::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) BOOST_OVERRIDE;
private:
parser_buf& operator=(const parser_buf&);
parser_buf(const parser_buf&);
//
// class cpp_regex_traits_char_layer:
-// implements methods that require specialisation for narrow characters:
+// implements methods that require specialization for narrow characters:
//
template <class charT>
class cpp_regex_traits_char_layer : public cpp_regex_traits_base<charT>
typename std::messages<charT>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1);
#endif
std::string cat_name(cpp_regex_traits<charT>::get_catalog_name());
- if(cat_name.size() && (this->m_pmessages != 0))
+ if((!cat_name.empty()) && (this->m_pmessages != 0))
{
cat = this->m_pmessages->open(
cat_name,
}
//
-// specialised version for narrow characters:
+// 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:
// we work around this elsewhere, but just assert here that
// we adhere to gcc's (buggy) preconditions...
//
- BOOST_ASSERT(*p2 == 0);
+ BOOST_REGEX_ASSERT(*p2 == 0);
string_type result;
#if defined(_CPPLIB_VER)
//
#ifndef BOOST_NO_EXCEPTIONS
}catch(...){}
#endif
- while(result.size() && (charT(0) == *result.rbegin()))
+ while((!result.empty()) && (charT(0) == *result.rbegin()))
result.erase(result.size() - 1);
if(result.empty())
{
// we work around this elsewhere, but just assert here that
// we adhere to gcc's (buggy) preconditions...
//
- BOOST_ASSERT(*p2 == 0);
+ BOOST_REGEX_ASSERT(*p2 == 0);
//
// swallowing all exceptions here is a bad idea
// however at least one std lib will always throw
#else
//
// some implementations (Dinkumware) append unnecessary trailing \0's:
- while(result.size() && (charT(0) == *result.rbegin()))
+ while((!result.empty()) && (charT(0) == *result.rbegin()))
result.erase(result.size() - 1);
#endif
//
result2.append(1, static_cast<charT>(1 + static_cast<uchar_type>(result[i]))).append(1, charT('b') - 1);
}
}
- BOOST_ASSERT(std::find(result2.begin(), result2.end(), charT(0)) == result2.end());
+ BOOST_REGEX_ASSERT(std::find(result2.begin(), result2.end(), charT(0)) == result2.end());
#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
cpp_regex_traits_implementation<charT>::lookup_collatename(const charT* p1, const charT* p2) const
{
typedef typename std::map<string_type, string_type>::const_iterator iter_type;
- if(m_custom_collate_names.size())
+ if(!m_custom_collate_names.empty())
{
iter_type pos = m_custom_collate_names.find(string_type(p1, p2));
if(pos != m_custom_collate_names.end())
name = lookup_default_collate_name(name);
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
&& !BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x0551)
- if(name.size())
+ if(!name.empty())
return string_type(name.begin(), name.end());
#else
- if(name.size())
+ if(!name.empty())
{
string_type result;
typedef std::string::const_iterator iter;
typename std::messages<charT>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1);
#endif
std::string cat_name(cpp_regex_traits<charT>::get_catalog_name());
- if(cat_name.size() && (this->m_pmessages != 0))
+ if((!cat_name.empty()) && (this->m_pmessages != 0))
{
cat = this->m_pmessages->open(
cat_name,
for(unsigned int j = 0; j <= 13; ++j)
{
string_type s(this->m_pmessages->get(cat, 0, j+300, null_string));
- if(s.size())
+ if(!s.empty())
this->m_custom_class_names[s] = masks[j];
}
}
::boost::BOOST_REGEX_DETAIL_NS::char_class_xdigit,
};
#endif
- if(m_custom_class_names.size())
+ if(!m_custom_class_names.empty())
{
typedef typename std::map<std::basic_string<charT>, char_class_type>::const_iterator map_iter;
map_iter pos = m_custom_class_names.find(string_type(p1, p2));
return pos->second;
}
std::size_t state_id = 1 + BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
- BOOST_ASSERT(state_id < sizeof(masks) / sizeof(masks[0]));
+ BOOST_REGEX_ASSERT(state_id < sizeof(masks) / sizeof(masks[0]));
return masks[state_id];
}
}
#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
#endif
#endif
-
-