forked from boostorg/regex
Added MFC/ATL wrappers.
Added support for unsigned versions in MSVC builds. More compiler-specific workarounds. [SVN r24351]
This commit is contained in:
1 parent
b0027d4b86
commit
f1ef6b6e9a
72 files changed
+2136
-1169
No files matched your search
@@ -69,6 +69,16 @@
|
||||
#define UNICODE
|
||||
#endif
|
||||
|
||||
//
|
||||
// Fix for gcc prior to 3.4: std::ctype<wchar_t> doesn't allow
|
||||
// masks to be combined, for example:
|
||||
// std::use_facet<std::ctype<wchar_t> >.is(std::ctype_base::lower|std::ctype_base::upper, L'a');
|
||||
// returns *false*.
|
||||
//
|
||||
#ifdef __GLIBCPP__
|
||||
# define BOOST_REGEX_BUGGY_CTYPE_FACET
|
||||
#endif
|
||||
|
||||
//
|
||||
// If there isn't good enough wide character support then there will
|
||||
// be no wide character regular expressions:
|
||||
@@ -127,13 +137,26 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1300) && !defined(BOOST_REGEX_V3) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
|
||||
# define BOOST_REGEX_HAS_SHORT_WCHAR_T
|
||||
namespace boost{ typedef __wchar_t regex_wchar_type; }
|
||||
#else
|
||||
namespace boost{ typedef wchar_t regex_wchar_type; }
|
||||
#endif
|
||||
//
|
||||
// define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users
|
||||
// code may be built with wchar_t as unsigned short: basically when we're building
|
||||
// with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
|
||||
// of the non-inline functions in the library, so that users can still link to the lib,
|
||||
// irrespective of whether their own code is built with /Zc:wchar_t.
|
||||
//
|
||||
#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS)
|
||||
# define BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||
# ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4251 4231 4660)
|
||||
# endif
|
||||
# ifdef _DLL
|
||||
# include <string>
|
||||
extern template class __declspec(dllimport) std::basic_string<unsigned short>;
|
||||
# endif
|
||||
# ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -58,6 +58,15 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#if __BORLANDC__ < 0x600
|
||||
//
|
||||
// string workarounds:
|
||||
//
|
||||
#include <cstring>
|
||||
#undef strcmp
|
||||
#undef strcpy
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,303 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2002
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE boost/regex/config/cstring.hpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex narrow character string fixes.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_REGEX_CONFIG_CSTRING_HPP
|
||||
#define BOOST_REGEX_CONFIG_CSTRING_HPP
|
||||
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#ifndef __sgi
|
||||
#ifdef __KCC
|
||||
#include <ios>
|
||||
#endif
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace std{
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma option push -w-8008 -w-8066 -w-8004
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
|
||||
// Any function that is a macro is converted into an inline function:
|
||||
#ifdef memcmp
|
||||
inline int boost_memcmp(const void * p1, const void * p2, size_t s)
|
||||
{ return memcmp(p1, p2, s); }
|
||||
#undef memcmp
|
||||
inline int memcmp(const void * p1, const void * p2, size_t s)
|
||||
{ return boost_memcmp(p1, p2, s); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::memcmp;
|
||||
#endif
|
||||
|
||||
#ifdef memcpy
|
||||
inline void *boost_memcpy(void * p1, const void *p2, size_t s)
|
||||
{ return memcpy(p1, p2, s); }
|
||||
#undef memcpy
|
||||
inline void *memcpy(void * p1, const void *p2, size_t s)
|
||||
{ return boost_memcpy(p1, p2, s); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::memcpy;
|
||||
#endif
|
||||
|
||||
#ifdef memmove
|
||||
inline void *(memmove)(void *, const void *, size_t)
|
||||
{ return memmove(p1,p2,s); }
|
||||
#undef memmove
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::memmove;
|
||||
#endif
|
||||
|
||||
#ifdef memset
|
||||
inline void *(boost_memset)(void *p, int a, size_t b)
|
||||
{ return memset(p,a,b); }
|
||||
#undef memset
|
||||
inline void *(memset)(void *p, int a, size_t b)
|
||||
{ return boost_memset(p,a,b); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::memset;
|
||||
#endif
|
||||
|
||||
#ifdef strcat
|
||||
inline char *(boost_strcat)(char *p1, const char *p2)
|
||||
{ return strcat(p1,p2); }
|
||||
#undef strcat
|
||||
inline char *(strcat)(char *p1, const char *p2)
|
||||
{ return boost_strcat(p1,p2); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::strcat;
|
||||
#endif
|
||||
|
||||
#ifdef strcmp
|
||||
inline int (boost_strcmp)(const char *p1, const char *p2)
|
||||
{ return strcmp(p1,p2); }
|
||||
#undef strcmp
|
||||
inline int (strcmp)(const char *p1, const char *p2)
|
||||
{ return boost_strcmp(p1,p2); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::strcmp;
|
||||
#endif
|
||||
|
||||
#ifdef strcoll
|
||||
inline int (boost_strcoll) (const char *p1, const char *p2)
|
||||
{ return strcoll(p1,p2); }
|
||||
#undef strcoll
|
||||
inline int (strcoll) (const char *p1, const char *p2)
|
||||
{ return boost_strcoll(p1,p2); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::strcoll;
|
||||
#endif
|
||||
|
||||
#ifdef strcpy
|
||||
inline char *(boost_strcpy)(char *p1, const char *p2)
|
||||
{ return strcpy(p1,p2); }
|
||||
#undef strcpy
|
||||
inline char *(strcpy)(char *p1, const char *p2)
|
||||
{ return boost_strcpy(p1,p2); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::strcpy;
|
||||
#endif
|
||||
|
||||
#ifdef strlen
|
||||
inline size_t (boost_strlen)(const char *p)
|
||||
{ return strlen(p); }
|
||||
#undef strlen
|
||||
inline size_t (strlen)(const char *p)
|
||||
{ return boost_strlen(p); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::strlen;
|
||||
#endif
|
||||
|
||||
#ifdef strxfrm
|
||||
inline size_t (boost_strxfrm)(char *p1, const char *p2, size_t s)
|
||||
{ return strxfrm(p1,p2,s); }
|
||||
#undef strxfrm
|
||||
inline size_t (strxfrm)(char *p1, const char *p2, size_t s)
|
||||
{ return boost_strxfrm(p1,p2,s); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::strxfrm;
|
||||
#endif
|
||||
|
||||
#ifdef isalnum
|
||||
inline int (boost_isalnum)(int i)
|
||||
{ return isalnum(i); }
|
||||
#undef isalnum
|
||||
inline int (isalnum)(int i)
|
||||
{ return boost_isalnum(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::isalnum;
|
||||
#endif
|
||||
|
||||
#ifdef isalpha
|
||||
inline int (boost_isalpha)(int i)
|
||||
{ return isalpha(i); }
|
||||
#undef isalpha
|
||||
inline int (isalpha)(int i)
|
||||
{ return boost_isalpha(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::isalpha;
|
||||
#endif
|
||||
|
||||
#ifdef iscntrl
|
||||
inline int (boost_iscntrl)(int i)
|
||||
{ return iscntrl(i); }
|
||||
#undef iscntrl
|
||||
inline int (iscntrl)(int i)
|
||||
{ return boost_iscntrl(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::iscntrl;
|
||||
#endif
|
||||
|
||||
#ifdef isdigit
|
||||
inline int (boost_isdigit)(int i)
|
||||
{ return isdigit(i); }
|
||||
#undef isdigit
|
||||
inline int (isdigit)(int i)
|
||||
{ return boost_isdigit(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::isdigit;
|
||||
#endif
|
||||
|
||||
#ifdef isgraph
|
||||
inline int (boost_isgraph)(int i)
|
||||
{ return isgraph(i); }
|
||||
#undef isgraph
|
||||
inline int (isgraph)(int i)
|
||||
{ return boost_isgraph(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::isgraph;
|
||||
#endif
|
||||
|
||||
#ifdef islower
|
||||
inline int (boost_islower)(int i)
|
||||
{ return islower(i); }
|
||||
#undef islower
|
||||
inline int (islower)(int i)
|
||||
{ return boost_islower(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::islower;
|
||||
#endif
|
||||
|
||||
#ifdef isprint
|
||||
inline int (boost_isprint)(int i)
|
||||
{ return isprint(i); }
|
||||
#undef isprint
|
||||
inline int (isprint)(int i)
|
||||
{ return boost_isprint(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::isprint;
|
||||
#endif
|
||||
|
||||
#ifdef ispunct
|
||||
inline int (boost_ispunct)(int i)
|
||||
{ return ispunct(i); }
|
||||
#undef ispunct
|
||||
inline int (ispunct)(int i)
|
||||
{ return boost_ispunct(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::ispunct;
|
||||
#endif
|
||||
|
||||
#ifdef isspace
|
||||
inline int (isspace)(int i)
|
||||
{ return isspace(i); }
|
||||
#undef isspace
|
||||
inline int (boost_isspace)(int i)
|
||||
{ return boost_isspace(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::isspace;
|
||||
#endif
|
||||
|
||||
#ifdef isupper
|
||||
inline int (isupper)(int i)
|
||||
{ return isupper(i); }
|
||||
#undef isupper
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::isupper;
|
||||
#endif
|
||||
|
||||
#ifdef isxdigit
|
||||
inline int (isxdigit)(int i)
|
||||
{ return isxdigit(i); }
|
||||
#undef isxdigit
|
||||
inline int (boost_isxdigit)(int i)
|
||||
{ return boost_isxdigit(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::isxdigit;
|
||||
#endif
|
||||
|
||||
#ifdef tolower
|
||||
inline int (boost_tolower)(int i)
|
||||
{ return tolower(i); }
|
||||
#undef tolower
|
||||
inline int (tolower)(int i)
|
||||
{ return boost_tolower(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::tolower;
|
||||
#endif
|
||||
|
||||
#ifdef toupper
|
||||
inline int (boost_toupper)(int i)
|
||||
{ return toupper(i); }
|
||||
#undef toupper
|
||||
inline int (toupper)(int i)
|
||||
{ return boost_toupper(i); }
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::toupper;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#undef memcmp
|
||||
#undef memcpy
|
||||
#undef memmove
|
||||
#undef memset
|
||||
#undef strcat
|
||||
#undef strcmp
|
||||
#undef strcoll
|
||||
#undef strcpy
|
||||
#undef strlen
|
||||
#undef strxfrm
|
||||
#undef isalnum
|
||||
#undef isalpha
|
||||
#undef iscntrl
|
||||
#undef isdigit
|
||||
#undef isgraph
|
||||
#undef islower
|
||||
#undef isprint
|
||||
#undef ispunct
|
||||
#undef isspace
|
||||
#undef isupper
|
||||
#undef isxdigit
|
||||
#undef tolower
|
||||
#undef toupper
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma option pop
|
||||
#endif
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // __sgi
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE mfc.hpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Overloads and helpers for using MFC/ATL string types with Boost.Regex.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_REGEX_MFC_HPP
|
||||
#define BOOST_REGEX_MFC_HPP
|
||||
|
||||
#include <atlsimpstr.h>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
//
|
||||
// define the types used for TCHAR's:
|
||||
typedef basic_regex<TCHAR> tregex;
|
||||
typedef match_results<TCHAR const*> tmatch;
|
||||
typedef regex_iterator<TCHAR const*> tregex_iterator;
|
||||
typedef regex_token_iterator<TCHAR const*> tregex_token_iterator;
|
||||
|
||||
#if _MSC_VER >= 1310
|
||||
#define SIMPLE_STRING_PARAM class B, bool b
|
||||
#define SIMPLE_STRING_ARG_LIST B, b
|
||||
#else
|
||||
#define SIMPLE_STRING_PARAM class B
|
||||
#define SIMPLE_STRING_ARG_LIST B
|
||||
#endif
|
||||
|
||||
//
|
||||
// define regex creation functions:
|
||||
//
|
||||
template <SIMPLE_STRING_PARAM>
|
||||
inline basic_regex<B>
|
||||
make_regex(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, ::boost::regex_constants::syntax_option_type f = boost::regex_constants::normal)
|
||||
{
|
||||
basic_regex<B> result(s.GetString(), s.GetString() + s.GetLength(), f);
|
||||
return result;
|
||||
}
|
||||
//
|
||||
// regex_match overloads:
|
||||
//
|
||||
template <SIMPLE_STRING_PARAM, class A, class T>
|
||||
inline bool regex_match(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
|
||||
match_results<const B*, A>& what,
|
||||
const basic_regex<B, T>& e,
|
||||
boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
|
||||
{
|
||||
return ::boost::regex_match(s.GetString(),
|
||||
s.GetString() + s.GetLength(),
|
||||
what,
|
||||
e,
|
||||
f);
|
||||
}
|
||||
|
||||
template <SIMPLE_STRING_PARAM, class T>
|
||||
inline bool regex_match(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
|
||||
const basic_regex<B, T>& e,
|
||||
boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
|
||||
{
|
||||
return ::boost::regex_match(s.GetString(),
|
||||
s.GetString() + s.GetLength(),
|
||||
e,
|
||||
f);
|
||||
}
|
||||
//
|
||||
// regex_search overloads:
|
||||
//
|
||||
template <SIMPLE_STRING_PARAM, class A, class T>
|
||||
inline bool regex_search(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
|
||||
match_results<const B*, A>& what,
|
||||
const basic_regex<B, T>& e,
|
||||
boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
|
||||
{
|
||||
return ::boost::regex_search(s.GetString(),
|
||||
s.GetString() + s.GetLength(),
|
||||
what,
|
||||
e,
|
||||
f);
|
||||
}
|
||||
|
||||
template <SIMPLE_STRING_PARAM, class T>
|
||||
inline bool regex_search(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
|
||||
const basic_regex<B, T>& e,
|
||||
boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
|
||||
{
|
||||
return ::boost::regex_search(s.GetString(),
|
||||
s.GetString() + s.GetLength(),
|
||||
e,
|
||||
f);
|
||||
}
|
||||
//
|
||||
// regex_iterator creation:
|
||||
//
|
||||
template <SIMPLE_STRING_PARAM>
|
||||
inline regex_iterator<B const*>
|
||||
make_regex_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
|
||||
{
|
||||
regex_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, f);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <SIMPLE_STRING_PARAM>
|
||||
inline regex_token_iterator<B const*>
|
||||
make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, int sub = 0, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
|
||||
{
|
||||
regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, sub, f);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <SIMPLE_STRING_PARAM>
|
||||
inline regex_token_iterator<B const*>
|
||||
make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, const std::vector<int>& subs, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
|
||||
{
|
||||
regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <SIMPLE_STRING_PARAM, std::size_t N>
|
||||
inline regex_token_iterator<B const*>
|
||||
make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, const int (& subs)[N], ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
|
||||
{
|
||||
regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class OutputIterator, class BidirectionalIterator, class traits,
|
||||
SIMPLE_STRING_PARAM>
|
||||
OutputIterator regex_replace(OutputIterator out,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
const basic_regex<B, traits>& e,
|
||||
const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& fmt,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
return regex_replace(out, first, last, e, fmt.GetString(), flags);
|
||||
}
|
||||
|
||||
namespace re_detail{
|
||||
|
||||
template <SIMPLE_STRING_PARAM>
|
||||
class mfc_string_out_iterator
|
||||
{
|
||||
ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>* out;
|
||||
public:
|
||||
mfc_string_out_iterator(ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s) : out(&s) {}
|
||||
mfc_string_out_iterator& operator++() { return *this; }
|
||||
mfc_string_out_iterator& operator++(int) { return *this; }
|
||||
mfc_string_out_iterator& operator*() { return *this; }
|
||||
mfc_string_out_iterator& operator=(B v)
|
||||
{
|
||||
out->AppendChar(v);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template <class traits, SIMPLE_STRING_PARAM>
|
||||
ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST> regex_replace(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
|
||||
const basic_regex<B, traits>& e,
|
||||
const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& fmt,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST> result(s.GetManager());
|
||||
re_detail::mfc_string_out_iterator<SIMPLE_STRING_ARG_LIST> i(result);
|
||||
regex_replace(i, s.GetString(), s.GetString() + s.GetLength(), e, fmt.GetString(), flags);
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace boost.
|
||||
|
||||
#endif
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
{
|
||||
return getoffset(addr, m_pdata->m_data.data());
|
||||
}
|
||||
std::ptrdiff_t getoffset(void* addr, void* base)
|
||||
std::ptrdiff_t getoffset(const void* addr, const void* base)
|
||||
{
|
||||
return static_cast<const char*>(addr) - static_cast<const char*>(base);
|
||||
}
|
||||
@@ -328,7 +328,7 @@ template <class charT, class traits>
|
||||
inline re_syntax_base* basic_regex_creator<charT, traits>::append_set(
|
||||
const basic_char_set<charT, traits>& char_set)
|
||||
{
|
||||
typedef mpl::bool_<sizeof(charT) == 1> truth_type;
|
||||
typedef mpl::bool_< (sizeof(charT) == 1) > truth_type;
|
||||
return char_set.has_digraphs()
|
||||
? append_set(char_set, static_cast<mpl::false_*>(0))
|
||||
: append_set(char_set, static_cast<truth_type*>(0));
|
||||
@@ -403,8 +403,10 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
|
||||
if(flags() & regex_constants::collate)
|
||||
{
|
||||
// we need to transform our range into sort keys:
|
||||
s1 = this->m_traits.transform(&c1.first, (c1.second ? &c1.second +1 : &c1.second));
|
||||
s2 = this->m_traits.transform(&c2.first, (c2.second ? &c2.second +1 : &c2.second));
|
||||
charT a1[3] = { c1.first, c1.second, charT(0), };
|
||||
charT a2[3] = { c2.first, c2.second, charT(0), };
|
||||
s1 = this->m_traits.transform(a1, (a1[1] ? a1+2 : a1+1));
|
||||
s2 = this->m_traits.transform(a2, (a2[1] ? a2+2 : a2+1));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -445,7 +447,7 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
|
||||
string_type s;
|
||||
if(first->second)
|
||||
{
|
||||
charT cs[2] = { first->first, first->second, };
|
||||
charT cs[3] = { first->first, first->second, charT(0), };
|
||||
s = m_traits.transform_primary(cs, cs+2);
|
||||
}
|
||||
else
|
||||
@@ -506,8 +508,10 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
|
||||
if(flags() & regex_constants::collate)
|
||||
{
|
||||
// we need to transform our range into sort keys:
|
||||
string_type s1 = this->m_traits.transform(&c1, &c1 +1);
|
||||
string_type s2 = this->m_traits.transform(&c2, &c2 +1);
|
||||
charT c3[2] = { c1, charT(0), };
|
||||
string_type s1 = this->m_traits.transform(c3, c3+1);
|
||||
c3[0] = c2;
|
||||
string_type s2 = this->m_traits.transform(c3, c3+1);
|
||||
if(s1 > s2)
|
||||
{
|
||||
// Oops error:
|
||||
@@ -515,8 +519,8 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
|
||||
}
|
||||
for(unsigned i = 0; i < (1u << CHAR_BIT); ++i)
|
||||
{
|
||||
charT c3 = static_cast<charT>(i);
|
||||
string_type s3 = this->m_traits.transform(&c3, &c3 +1);
|
||||
charT c3[] = { static_cast<charT>(i), charT(0), };
|
||||
string_type s3 = this->m_traits.transform(c3, c3 +1);
|
||||
if((s1 <= s3) && (s3 <= s2))
|
||||
result->_map[i] = true;
|
||||
}
|
||||
@@ -565,8 +569,8 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
|
||||
return 0; // invalid or unsupported equivalence class
|
||||
for(unsigned i = 0; i < (1u << CHAR_BIT); ++i)
|
||||
{
|
||||
charT c(static_cast<charT>(i));
|
||||
string_type s2 = this->m_traits.transform_primary(&c, &c+1);
|
||||
charT c[2] = { (static_cast<charT>(i)), charT(0), };
|
||||
string_type s2 = this->m_traits.transform_primary(c, c+1);
|
||||
if(s == s2)
|
||||
result->_map[i] = true;
|
||||
}
|
||||
|
||||
@@ -517,10 +517,10 @@ bool basic_regex_parser<charT, traits>::parse_match_any()
|
||||
++m_position;
|
||||
static_cast<re_dot*>(
|
||||
this->append_state(syntax_element_wild, sizeof(re_dot))
|
||||
)->mask = this->flags() & regbase::no_mod_s
|
||||
)->mask = static_cast<unsigned char>(this->flags() & regbase::no_mod_s
|
||||
? re_detail::force_not_newline
|
||||
: this->flags() & regbase::mod_s ?
|
||||
re_detail::force_newline : re_detail::dont_care;
|
||||
re_detail::force_newline : re_detail::dont_care);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1134,6 +1134,25 @@ digraph<charT> basic_regex_parser<charT, traits>::get_next_set_literal(basic_cha
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// does a value fit in the specified charT type?
|
||||
//
|
||||
template <class charT>
|
||||
bool valid_value(charT, int v, const mpl::true_&)
|
||||
{
|
||||
return (v >> (sizeof(charT) * CHAR_BIT)) == 0;
|
||||
}
|
||||
template <class charT>
|
||||
bool valid_value(charT, int v, const mpl::false_&)
|
||||
{
|
||||
return true; // v will alsways fit in a charT
|
||||
}
|
||||
template <class charT>
|
||||
bool valid_value(charT c, int v)
|
||||
{
|
||||
return valid_value(c, v, mpl::bool_<(sizeof(charT) < sizeof(int))>());
|
||||
}
|
||||
|
||||
template <class charT, class traits>
|
||||
charT basic_regex_parser<charT, traits>::unescape_character()
|
||||
{
|
||||
@@ -1219,7 +1238,7 @@ charT basic_regex_parser<charT, traits>::unescape_character()
|
||||
std::ptrdiff_t len = (std::min)(static_cast<std::ptrdiff_t>(2), m_end - m_position);
|
||||
int i = this->m_traits.toi(m_position, m_position + len, 16);
|
||||
if((i < 0)
|
||||
|| (i >> (sizeof(charT) * CHAR_BIT)))
|
||||
|| !valid_value(charT(0), i))
|
||||
{
|
||||
fail(regex_constants::error_escape, m_position - m_base);
|
||||
return result;
|
||||
|
||||
@@ -112,14 +112,14 @@ struct BOOST_REGEX_DECL c_regex_traits<wchar_t>
|
||||
return (std::towlower)(c);
|
||||
}
|
||||
|
||||
string_type BOOST_REGEX_CALL transform(const wchar_t* p1, const wchar_t* p2) const;
|
||||
string_type BOOST_REGEX_CALL transform_primary(const wchar_t* p1, const wchar_t* p2) const;
|
||||
static string_type BOOST_REGEX_CALL transform(const wchar_t* p1, const wchar_t* p2);
|
||||
static string_type BOOST_REGEX_CALL transform_primary(const wchar_t* p1, const wchar_t* p2);
|
||||
|
||||
char_class_type BOOST_REGEX_CALL lookup_classname(const wchar_t* p1, const wchar_t* p2) const;
|
||||
string_type BOOST_REGEX_CALL lookup_collatename(const wchar_t* p1, const wchar_t* p2) const;
|
||||
static char_class_type BOOST_REGEX_CALL lookup_classname(const wchar_t* p1, const wchar_t* p2);
|
||||
static string_type BOOST_REGEX_CALL lookup_collatename(const wchar_t* p1, const wchar_t* p2);
|
||||
|
||||
bool BOOST_REGEX_CALL isctype(wchar_t, char_class_type) const;
|
||||
int BOOST_REGEX_CALL value(wchar_t, int) const;
|
||||
static bool BOOST_REGEX_CALL isctype(wchar_t, char_class_type);
|
||||
static int BOOST_REGEX_CALL value(wchar_t, int);
|
||||
|
||||
locale_type imbue(locale_type l)
|
||||
{ return l; }
|
||||
@@ -132,6 +132,57 @@ private:
|
||||
c_regex_traits& operator=(const c_regex_traits&);
|
||||
};
|
||||
|
||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||
//
|
||||
// Provide an unsigned short version as well, so the user can link to this
|
||||
// no matter whether they build with /Zc:wchar_t or not (MSVC specific).
|
||||
//
|
||||
template<>
|
||||
struct BOOST_REGEX_DECL c_regex_traits<unsigned short>
|
||||
{
|
||||
c_regex_traits(){}
|
||||
typedef unsigned short char_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::basic_string<unsigned short> string_type;
|
||||
struct locale_type{};
|
||||
typedef boost::uint32_t char_class_type;
|
||||
|
||||
static size_type length(const char_type* p)
|
||||
{
|
||||
return (std::wcslen)((const wchar_t*)p);
|
||||
}
|
||||
|
||||
unsigned short translate(unsigned short c) const
|
||||
{
|
||||
return c;
|
||||
}
|
||||
unsigned short translate_nocase(unsigned short c) const
|
||||
{
|
||||
return (std::towlower)((wchar_t)c);
|
||||
}
|
||||
|
||||
static string_type BOOST_REGEX_CALL transform(const unsigned short* p1, const unsigned short* p2);
|
||||
static string_type BOOST_REGEX_CALL transform_primary(const unsigned short* p1, const unsigned short* p2);
|
||||
|
||||
static char_class_type BOOST_REGEX_CALL lookup_classname(const unsigned short* p1, const unsigned short* p2);
|
||||
static string_type BOOST_REGEX_CALL lookup_collatename(const unsigned short* p1, const unsigned short* p2);
|
||||
|
||||
static bool BOOST_REGEX_CALL isctype(unsigned short, char_class_type);
|
||||
static int BOOST_REGEX_CALL value(unsigned short, int);
|
||||
|
||||
locale_type imbue(locale_type l)
|
||||
{ return l; }
|
||||
locale_type getloc()const
|
||||
{ return locale_type(); }
|
||||
|
||||
private:
|
||||
// this type is not copyable:
|
||||
c_regex_traits(const c_regex_traits&);
|
||||
c_regex_traits& operator=(const c_regex_traits&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOOST_NO_WREGEX
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
|
||||
#ifndef BOOST_RE_PAT_EXCEPT_HPP
|
||||
#include <boost/regex/pattern_except.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED
|
||||
#include <boost/regex/v4/regex_traits_defaults.hpp>
|
||||
#endif
|
||||
@@ -319,6 +322,27 @@ private:
|
||||
void init();
|
||||
};
|
||||
|
||||
#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET
|
||||
enum
|
||||
{
|
||||
char_class_space=1<<0,
|
||||
char_class_print=1<<1,
|
||||
char_class_cntrl=1<<2,
|
||||
char_class_upper=1<<3,
|
||||
char_class_lower=1<<4,
|
||||
char_class_alpha=1<<5,
|
||||
char_class_digit=1<<6,
|
||||
char_class_punct=1<<7,
|
||||
char_class_xdigit=1<<8,
|
||||
char_class_alnum=char_class_alpha|char_class_digit,
|
||||
char_class_graph=char_class_alnum|char_class_punct,
|
||||
char_class_blank=1<<9,
|
||||
char_class_word=1<<10,
|
||||
char_class_unicode=1<<11
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// class cpp_regex_traits_implementation:
|
||||
// provides pimpl implementation for cpp_regex_traits.
|
||||
@@ -329,6 +353,7 @@ class cpp_regex_traits_implementation : public cpp_regex_traits_char_layer<charT
|
||||
public:
|
||||
typedef typename cpp_regex_traits<charT>::char_class_type char_class_type;
|
||||
typedef typename std::ctype<charT>::mask native_mask_type;
|
||||
#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET
|
||||
BOOST_STATIC_CONSTANT(char_class_type, mask_blank = 1u << 16);
|
||||
BOOST_STATIC_CONSTANT(char_class_type, mask_word = 1u << 17);
|
||||
BOOST_STATIC_CONSTANT(char_class_type, mask_unicode = 1u << 18);
|
||||
@@ -361,7 +386,7 @@ public:
|
||||
| std::ctype<charT>::upper
|
||||
| std::ctype<charT>::xdigit);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
//BOOST_STATIC_ASSERT(0 == (mask_base & (mask_word | mask_unicode)));
|
||||
|
||||
|
||||
@@ -391,10 +416,7 @@ public:
|
||||
}
|
||||
string_type lookup_collatename(const charT* p1, const charT* p2) const;
|
||||
string_type transform_primary(const charT* p1, const charT* p2) const;
|
||||
string_type transform(const charT* p1, const charT* p2) const
|
||||
{
|
||||
return this->m_pcollate->transform(p1, p2);
|
||||
}
|
||||
string_type transform(const charT* p1, const charT* p2) const;
|
||||
re_detail::parser_buf<charT> m_sbuf; // buffer for parsing numbers.
|
||||
std::basic_istream<charT> m_is; // stream for parsing numbers.
|
||||
private:
|
||||
@@ -407,8 +429,13 @@ private:
|
||||
// helpers:
|
||||
//
|
||||
char_class_type lookup_classname_imp(const charT* p1, const charT* p2) const;
|
||||
#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET
|
||||
public:
|
||||
bool isctype(charT c, char_class_type m)const;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET
|
||||
#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
|
||||
|
||||
template <class charT>
|
||||
@@ -425,12 +452,23 @@ template <class charT>
|
||||
typename cpp_regex_traits_implementation<charT>::char_class_type const cpp_regex_traits_implementation<charT>::mask_base;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template <class charT>
|
||||
typename cpp_regex_traits_implementation<charT>::string_type
|
||||
cpp_regex_traits_implementation<charT>::transform_primary(const charT* p1, const charT* p2) const
|
||||
{
|
||||
//
|
||||
// PRECONDITIONS:
|
||||
//
|
||||
// A bug in gcc 3.2 (and maybe other versions as well) treats
|
||||
// p1 as a null terminated string, for efficiency reasons
|
||||
// we work around this elsewhere, but just assert here that
|
||||
// we adhere to gcc's (buggy) preconditions...
|
||||
//
|
||||
BOOST_ASSERT(*p2 == 0);
|
||||
|
||||
string_type result;
|
||||
//
|
||||
// swallowing all exceptions here is a bad idea
|
||||
@@ -478,6 +516,50 @@ typename cpp_regex_traits_implementation<charT>::string_type
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class charT>
|
||||
typename cpp_regex_traits_implementation<charT>::string_type
|
||||
cpp_regex_traits_implementation<charT>::transform(const charT* p1, const charT* p2) const
|
||||
{
|
||||
//
|
||||
// PRECONDITIONS:
|
||||
//
|
||||
// A bug in gcc 3.2 (and maybe other versions as well) treats
|
||||
// p1 as a null terminated string, for efficiency reasons
|
||||
// we work around this elsewhere, but just assert here that
|
||||
// we adhere to gcc's (buggy) preconditions...
|
||||
//
|
||||
BOOST_ASSERT(*p2 == 0);
|
||||
//
|
||||
// swallowing all exceptions here is a bad idea
|
||||
// however at least one std lib will always throw
|
||||
// std::bad_alloc for certain arguments...
|
||||
//
|
||||
string_type result;
|
||||
try{
|
||||
result = this->m_pcollate->transform(p1, p2);
|
||||
//
|
||||
// Borland's STLPort version returns a NULL-terminated
|
||||
// string that has garbage at the end - each call to
|
||||
// std::collate<wchar_t>::transform returns a different string!
|
||||
// So as a workaround, we'll truncate the string at the first NULL
|
||||
// which _seems_ to work....
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
|
||||
result.erase(result.find(charT(0)));
|
||||
#else
|
||||
//
|
||||
// some implementations (Dinkumware) append unnecessary trailing \0's:
|
||||
while(result.size() && (charT(0) == *result.rbegin()))
|
||||
result.erase(result.size() - 1);
|
||||
#endif
|
||||
BOOST_ASSERT(result.find(charT(0)) == string_type::npos);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template <class charT>
|
||||
typename cpp_regex_traits_implementation<charT>::string_type
|
||||
cpp_regex_traits_implementation<charT>::lookup_collatename(const charT* p1, const charT* p2) const
|
||||
@@ -575,6 +657,7 @@ cpp_regex_traits_implementation<charT>::cpp_regex_traits_implementation(const st
|
||||
//
|
||||
// Custom class names:
|
||||
//
|
||||
#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET
|
||||
static const char_class_type masks[] =
|
||||
{
|
||||
std::ctype<charT>::alnum,
|
||||
@@ -592,6 +675,25 @@ cpp_regex_traits_implementation<charT>::cpp_regex_traits_implementation(const st
|
||||
cpp_regex_traits_implementation<charT>::mask_word,
|
||||
cpp_regex_traits_implementation<charT>::mask_unicode,
|
||||
};
|
||||
#else
|
||||
static const char_class_type masks[] =
|
||||
{
|
||||
::boost::re_detail::char_class_alnum,
|
||||
::boost::re_detail::char_class_alpha,
|
||||
::boost::re_detail::char_class_cntrl,
|
||||
::boost::re_detail::char_class_digit,
|
||||
::boost::re_detail::char_class_graph,
|
||||
::boost::re_detail::char_class_lower,
|
||||
::boost::re_detail::char_class_print,
|
||||
::boost::re_detail::char_class_punct,
|
||||
::boost::re_detail::char_class_space,
|
||||
::boost::re_detail::char_class_upper,
|
||||
::boost::re_detail::char_class_xdigit,
|
||||
::boost::re_detail::char_class_blank,
|
||||
::boost::re_detail::char_class_word,
|
||||
::boost::re_detail::char_class_unicode,
|
||||
};
|
||||
#endif
|
||||
static const string_type null_string;
|
||||
for(unsigned int j = 0; j <= 13; ++j)
|
||||
{
|
||||
@@ -611,6 +713,7 @@ template <class charT>
|
||||
typename cpp_regex_traits_implementation<charT>::char_class_type
|
||||
cpp_regex_traits_implementation<charT>::lookup_classname_imp(const charT* p1, const charT* p2) const
|
||||
{
|
||||
#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET
|
||||
static const char_class_type masks[] =
|
||||
{
|
||||
0,
|
||||
@@ -634,6 +737,31 @@ typename cpp_regex_traits_implementation<charT>::char_class_type
|
||||
std::ctype<char>::alnum | cpp_regex_traits_implementation<charT>::mask_word,
|
||||
std::ctype<char>::xdigit,
|
||||
};
|
||||
#else
|
||||
static const char_class_type masks[] =
|
||||
{
|
||||
0,
|
||||
::boost::re_detail::char_class_alnum,
|
||||
::boost::re_detail::char_class_alpha,
|
||||
::boost::re_detail::char_class_blank,
|
||||
::boost::re_detail::char_class_cntrl,
|
||||
::boost::re_detail::char_class_digit,
|
||||
::boost::re_detail::char_class_digit,
|
||||
::boost::re_detail::char_class_graph,
|
||||
::boost::re_detail::char_class_lower,
|
||||
::boost::re_detail::char_class_lower,
|
||||
::boost::re_detail::char_class_print,
|
||||
::boost::re_detail::char_class_punct,
|
||||
::boost::re_detail::char_class_space,
|
||||
::boost::re_detail::char_class_space,
|
||||
::boost::re_detail::char_class_upper,
|
||||
::boost::re_detail::char_class_unicode,
|
||||
::boost::re_detail::char_class_upper,
|
||||
::boost::re_detail::char_class_alnum | ::boost::re_detail::char_class_word,
|
||||
::boost::re_detail::char_class_alnum | ::boost::re_detail::char_class_word,
|
||||
::boost::re_detail::char_class_xdigit,
|
||||
};
|
||||
#endif
|
||||
if(m_custom_class_names.size())
|
||||
{
|
||||
typedef typename std::map<std::basic_string<charT>, char_class_type>::const_iterator map_iter;
|
||||
@@ -646,6 +774,26 @@ typename cpp_regex_traits_implementation<charT>::char_class_type
|
||||
return masks[id];
|
||||
}
|
||||
|
||||
#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET
|
||||
template <class charT>
|
||||
bool cpp_regex_traits_implementation<charT>::isctype(const charT c, char_class_type mask) const
|
||||
{
|
||||
return
|
||||
((mask & ::boost::re_detail::char_class_space) && (m_pctype->is(std::ctype<charT>::space, c)))
|
||||
|| ((mask & ::boost::re_detail::char_class_print) && (m_pctype->is(std::ctype<charT>::print, c)))
|
||||
|| ((mask & ::boost::re_detail::char_class_cntrl) && (m_pctype->is(std::ctype<charT>::cntrl, c)))
|
||||
|| ((mask & ::boost::re_detail::char_class_upper) && (m_pctype->is(std::ctype<charT>::upper, c)))
|
||||
|| ((mask & ::boost::re_detail::char_class_lower) && (m_pctype->is(std::ctype<charT>::lower, c)))
|
||||
|| ((mask & ::boost::re_detail::char_class_alpha) && (m_pctype->is(std::ctype<charT>::alpha, c)))
|
||||
|| ((mask & ::boost::re_detail::char_class_digit) && (m_pctype->is(std::ctype<charT>::digit, c)))
|
||||
|| ((mask & ::boost::re_detail::char_class_punct) && (m_pctype->is(std::ctype<charT>::punct, c)))
|
||||
|| ((mask & ::boost::re_detail::char_class_xdigit) && (m_pctype->is(std::ctype<charT>::xdigit, c)))
|
||||
|| ((mask & ::boost::re_detail::char_class_blank) && (m_pctype->is(std::ctype<charT>::space, c)) && !::boost::re_detail::is_separator(c))
|
||||
|| ((mask & ::boost::re_detail::char_class_word) && (c == '_'))
|
||||
|| ((mask & ::boost::re_detail::char_class_unicode) && ::boost::re_detail::is_extended(c));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
template <class charT>
|
||||
boost::shared_ptr<cpp_regex_traits_implementation<charT> > create_cpp_regex_traits(const std::locale& l BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(charT))
|
||||
@@ -707,23 +855,7 @@ public:
|
||||
}
|
||||
string_type transform(const charT* p1, const charT* p2) const
|
||||
{
|
||||
//
|
||||
// swallowing all exceptions here is a bad idea
|
||||
// however at least one std lib will always throw
|
||||
// std::bad_alloc for certain arguments...
|
||||
//
|
||||
string_type result;
|
||||
try{
|
||||
result = m_pimpl->m_pcollate->transform(p1, p2);
|
||||
//
|
||||
// some implementations append unnecessary trailing \0's:
|
||||
while(result.size() && (charT(0) == *result.rbegin()))
|
||||
result.erase(result.size() - 1);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
return result;
|
||||
return m_pimpl->transform(p1, p2);
|
||||
}
|
||||
string_type transform_primary(const charT* p1, const charT* p2) const
|
||||
{
|
||||
@@ -739,6 +871,7 @@ public:
|
||||
}
|
||||
bool isctype(charT c, char_class_type f) const
|
||||
{
|
||||
#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET
|
||||
typedef typename std::ctype<charT>::mask ctype_mask;
|
||||
if((f & re_detail::cpp_regex_traits_implementation<charT>::mask_base)
|
||||
&& (m_pimpl->m_pctype->is(
|
||||
@@ -753,6 +886,9 @@ public:
|
||||
&& !re_detail::is_separator(c))
|
||||
return true;
|
||||
return false;
|
||||
#else
|
||||
return m_pimpl->isctype(c, f);
|
||||
#endif
|
||||
}
|
||||
int toi(const charT*& p1, const charT* p2, int radix)const;
|
||||
int value(charT c, int radix)const
|
||||
|
||||
@@ -166,7 +166,10 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
|
||||
if((e.m_flags & regex_constants::collate) == 0)
|
||||
s1.assign(1, col);
|
||||
else
|
||||
s1 = traits_inst.transform(&col, &col + 1);
|
||||
{
|
||||
charT a[2] = { col, charT(0), };
|
||||
s1 = traits_inst.transform(a, a + 1);
|
||||
}
|
||||
for(i = 0; i < set_->cranges; ++i)
|
||||
{
|
||||
if(STR_COMP(s1, p) >= 0)
|
||||
@@ -191,7 +194,8 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
|
||||
// try and match an equivalence class, NB only a single character can match
|
||||
if(set_->cequivalents)
|
||||
{
|
||||
s1 = traits_inst.transform_primary(&col, &col +1);
|
||||
charT a[2] = { col, charT(0), };
|
||||
s1 = traits_inst.transform_primary(a, a +1);
|
||||
for(i = 0; i < set_->cequivalents; ++i)
|
||||
{
|
||||
if(STR_COMP(s1, p) == 0)
|
||||
@@ -350,7 +354,7 @@ private:
|
||||
bool match_backstep();
|
||||
bool match_assert_backref();
|
||||
bool match_toggle_case();
|
||||
bool backtrack_till_match(unsigned count);
|
||||
bool backtrack_till_match(std::size_t count);
|
||||
|
||||
// find procs stored in s_find_vtable:
|
||||
bool find_restart_any();
|
||||
|
||||
@@ -74,7 +74,7 @@ perl_matcher<BidiIterator, Allocator, traits>::perl_matcher(BidiIterator first,
|
||||
const char_type w = static_cast<char_type>('w');
|
||||
m_word_mask = traits_inst.lookup_classname(&w, &w+1);
|
||||
// find bitmask to use for matching '.':
|
||||
match_any_mask = (f & match_not_dot_newline) ? re_detail::test_not_newline : re_detail::test_newline;
|
||||
match_any_mask = static_cast<unsigned char>((f & match_not_dot_newline) ? re_detail::test_not_newline : re_detail::test_newline);
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
|
||||
@@ -436,10 +436,17 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_dot_repeat_fast()
|
||||
// start by working out how much we can skip:
|
||||
//
|
||||
const re_repeat* rep = static_cast<const re_repeat*>(pstate);
|
||||
unsigned count = (std::min)(static_cast<unsigned>(::boost::re_detail::distance(position, last)), (rep->greedy ? rep->max : rep->min));
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4267)
|
||||
#endif
|
||||
std::size_t count = (std::min)(static_cast<std::size_t>(::boost::re_detail::distance(position, last)), static_cast<std::size_t>(rep->greedy ? rep->max : rep->min));
|
||||
if(rep->min > count)
|
||||
return false; // not enough text left to match
|
||||
std::advance(position, count);
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
if((rep->leading) && (count < rep->max) && (rep->greedy))
|
||||
restart = position;
|
||||
if(rep->greedy)
|
||||
@@ -740,7 +747,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_long_set_repeat()
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::backtrack_till_match(unsigned count)
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::backtrack_till_match(std::size_t count)
|
||||
{
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
|
||||
@@ -107,6 +107,18 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T)
|
||||
#define BOOST_REGEX_CHAR_T unsigned short
|
||||
#ifdef BOOST_REGEX_US_INSTANTIATE
|
||||
# define BOOST_REGEX_INSTANTIATE
|
||||
#endif
|
||||
#include <boost/regex/v4/instances.hpp>
|
||||
#undef BOOST_REGEX_CHAR_T
|
||||
#ifdef BOOST_REGEX_INSTANTIATE
|
||||
# undef BOOST_REGEX_INSTANTIATE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
#ifdef BOOST_REGEX_NO_FWD
|
||||
|
||||
@@ -108,6 +108,9 @@ private:
|
||||
const char_type* m_end; // format string end
|
||||
match_flag_type m_flags; // format flags to use
|
||||
output_state m_state; // what to do with the next character
|
||||
private:
|
||||
basic_regex_formatter(const basic_regex_formatter&);
|
||||
basic_regex_formatter& operator=(const basic_regex_formatter&);
|
||||
};
|
||||
|
||||
template <class OutputIterator, class Results, class traits>
|
||||
|
||||
@@ -68,6 +68,8 @@ public:
|
||||
what.set_base(base);
|
||||
return result;
|
||||
}
|
||||
private:
|
||||
regex_iterator_implementation& operator=(const regex_iterator_implementation&);
|
||||
};
|
||||
|
||||
template <class BidirectionalIterator,
|
||||
|
||||
@@ -152,6 +152,8 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
regex_token_iterator_implementation& operator=(const regex_token_iterator_implementation&);
|
||||
};
|
||||
|
||||
template <class BidirectionalIterator,
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
#ifndef BOOST_REGEX_ERROR_TYPE_HPP
|
||||
#include <boost/regex/v4/error_type.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED
|
||||
#include <boost/regex/v4/regex_traits_defaults.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
# ifndef BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED
|
||||
# include <boost/regex/v4/cpp_regex_traits.hpp>
|
||||
@@ -156,6 +159,10 @@ struct regex_traits_wrapper
|
||||
::boost::re_detail::has_boost_extensions_tag<BaseT>::value
|
||||
>::type
|
||||
{
|
||||
regex_traits_wrapper(){}
|
||||
private:
|
||||
regex_traits_wrapper(const regex_traits_wrapper&);
|
||||
regex_traits_wrapper& operator=(const regex_traits_wrapper&);
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
@@ -250,6 +250,7 @@ int global_value(charT c)
|
||||
template <class charT, class traits>
|
||||
int global_toi(const charT*& p1, const charT* p2, int radix, const traits& t)
|
||||
{
|
||||
(void)t; // warning suppression
|
||||
int next_value = t.value(*p1, radix);
|
||||
if((p1 == p2) || (next_value < 0) || (next_value >= radix))
|
||||
return -1;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <limits>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
@@ -61,23 +61,38 @@ BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale();
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char, lcid_type);
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t, lcid_type);
|
||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type id);
|
||||
#endif
|
||||
#endif
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char, lcid_type);
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(wchar_t, lcid_type);
|
||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(unsigned short ca, lcid_type id);
|
||||
#endif
|
||||
#endif
|
||||
BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name);
|
||||
BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type id, int i, const std::string& def);
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type id, int i, const std::wstring& def);
|
||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||
BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::basic_string<unsigned short>& def);
|
||||
#endif
|
||||
#endif
|
||||
BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const char* p1, const char* p2);
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type id, const wchar_t* p1, const wchar_t* p2);
|
||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||
BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_transform(lcid_type id, const unsigned short* p1, const unsigned short* p2);
|
||||
#endif
|
||||
#endif
|
||||
BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type);
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type);
|
||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type id);
|
||||
#endif
|
||||
#endif
|
||||
BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type);
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
@@ -86,6 +101,9 @@ BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type);
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type, boost::uint32_t mask, char c);
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type, boost::uint32_t mask, wchar_t c);
|
||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, unsigned short c);
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
// class w32_regex_traits_base:
|
||||
|
||||
Reference in new issue
Block a user