forked from boostorg/regex
Added new docs,
Moved source more into line with the std lib proposal. [SVN r18292]
This commit is contained in:
@@ -64,7 +64,7 @@ public:
|
||||
typedef typename Allocator::size_type size_type;
|
||||
typedef Allocator allocator_type;
|
||||
typedef Allocator alloc_type;
|
||||
typedef regbase::flag_type flag_type;
|
||||
typedef regex_constants::syntax_option_type flag_type;
|
||||
// locale_type
|
||||
// placeholder for actual locale type used by the
|
||||
// traits class to localise *this.
|
||||
@@ -72,15 +72,15 @@ public:
|
||||
|
||||
public:
|
||||
explicit reg_expression(const Allocator& a = Allocator());
|
||||
explicit reg_expression(const charT* p, flag_type f = regbase::normal, const Allocator& a = Allocator());
|
||||
reg_expression(const charT* p1, const charT* p2, flag_type f = regbase::normal, const Allocator& a = Allocator());
|
||||
explicit reg_expression(const charT* p, flag_type f = regex_constants::normal, const Allocator& a = Allocator());
|
||||
reg_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal, const Allocator& a = Allocator());
|
||||
reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a = Allocator());
|
||||
reg_expression(const reg_expression&);
|
||||
~reg_expression();
|
||||
reg_expression& BOOST_REGEX_CALL operator=(const reg_expression&);
|
||||
reg_expression& BOOST_REGEX_CALL operator=(const charT* ptr)
|
||||
{
|
||||
set_expression(ptr, regbase::normal | regbase::use_except);
|
||||
set_expression(ptr, regex_constants::normal | regex_constants::use_except);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -88,84 +88,84 @@ public:
|
||||
// assign:
|
||||
reg_expression& assign(const reg_expression& that)
|
||||
{ return *this = that; }
|
||||
reg_expression& assign(const charT* ptr, flag_type f = regbase::normal)
|
||||
reg_expression& assign(const charT* ptr, flag_type f = regex_constants::normal)
|
||||
{
|
||||
set_expression(ptr, f | regbase::use_except);
|
||||
set_expression(ptr, f | regex_constants::use_except);
|
||||
return *this;
|
||||
}
|
||||
|
||||
reg_expression& assign(const charT* first,
|
||||
const charT* last,
|
||||
flag_type f = regbase::normal)
|
||||
flag_type f = regex_constants::normal)
|
||||
{
|
||||
set_expression(first, last, f | regbase::use_except);
|
||||
set_expression(first, last, f | regex_constants::use_except);
|
||||
return *this;
|
||||
}
|
||||
#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !(defined(__IBMCPP__) && (__IBMCPP__ <= 502))
|
||||
|
||||
template <class ST, class SA>
|
||||
unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal)
|
||||
unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
|
||||
{ return set_expression(p.data(), p.data() + p.size(), f); }
|
||||
|
||||
template <class ST, class SA>
|
||||
explicit reg_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
|
||||
: data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) { set_expression(p, f | regbase::use_except); }
|
||||
explicit reg_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
|
||||
: data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) { set_expression(p, f | regex_constants::use_except); }
|
||||
|
||||
template <class I>
|
||||
reg_expression(I first, I last, flag_type f = regbase::normal, const Allocator& al = Allocator())
|
||||
reg_expression(I first, I last, flag_type f = regex_constants::normal, const Allocator& al = Allocator())
|
||||
: data(al), pkmp(0), error_code_(REG_EMPTY), _expression(0)
|
||||
{
|
||||
size_type len = last-first;
|
||||
scoped_array<charT> a(new charT[len]);
|
||||
std::copy(first, last, a.get());
|
||||
set_expression(a.get(), a.get() + len, f | regbase::use_except);
|
||||
set_expression(a.get(), a.get() + len, f | regex_constants::use_except);
|
||||
}
|
||||
|
||||
template <class ST, class SA>
|
||||
reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT, ST, SA>& p)
|
||||
{
|
||||
set_expression(p.c_str(), p.c_str() + p.size(), regbase::normal | regbase::use_except);
|
||||
set_expression(p.c_str(), p.c_str() + p.size(), regex_constants::normal | regex_constants::use_except);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class string_traits, class A>
|
||||
reg_expression& BOOST_REGEX_CALL assign(
|
||||
const std::basic_string<charT, string_traits, A>& s,
|
||||
flag_type f = regbase::normal)
|
||||
flag_type f = regex_constants::normal)
|
||||
{
|
||||
set_expression(s.c_str(), s.c_str() + s.size(), f | regbase::use_except);
|
||||
set_expression(s.c_str(), s.c_str() + s.size(), f | regex_constants::use_except);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class fwd_iterator>
|
||||
reg_expression& BOOST_REGEX_CALL assign(fwd_iterator first,
|
||||
fwd_iterator last,
|
||||
flag_type f = regbase::normal)
|
||||
flag_type f = regex_constants::normal)
|
||||
{
|
||||
size_type len = last-first;
|
||||
scoped_array<charT> a(new charT[len]);
|
||||
std::copy(first, last, a.get());
|
||||
set_expression(a.get(), a.get() + len, f | regbase::use_except);
|
||||
set_expression(a.get(), a.get() + len, f | regex_constants::use_except);
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal)
|
||||
{ return set_expression(p.data(), p.data() + p.size(), f | regbase::use_except); }
|
||||
unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT>& p, flag_type f = regex_constants::normal)
|
||||
{ return set_expression(p.data(), p.data() + p.size(), f | regex_constants::use_except); }
|
||||
|
||||
reg_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
|
||||
: data(a), pkmp(0) { set_expression(p, f | regbase::use_except); }
|
||||
reg_expression(const std::basic_string<charT>& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
|
||||
: data(a), pkmp(0) { set_expression(p, f | regex_constants::use_except); }
|
||||
|
||||
reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT>& p)
|
||||
{
|
||||
set_expression(p.c_str(), p.c_str() + p.size(), regbase::normal | regbase::use_except);
|
||||
set_expression(p.c_str(), p.c_str() + p.size(), regex_constants::normal | regex_constants::use_except);
|
||||
return *this;
|
||||
}
|
||||
|
||||
reg_expression& BOOST_REGEX_CALL assign(
|
||||
const std::basic_string<charT>& s,
|
||||
flag_type f = regbase::normal)
|
||||
flag_type f = regex_constants::normal)
|
||||
{
|
||||
set_expression(s.c_str(), s.c_str() + s.size(), f | regbase::use_except);
|
||||
set_expression(s.c_str(), s.c_str() + s.size(), f | regex_constants::use_except);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -234,8 +234,8 @@ public:
|
||||
// but are available for compatibility with earlier versions.
|
||||
allocator_type BOOST_REGEX_CALL allocator()const;
|
||||
const charT* BOOST_REGEX_CALL expression()const { return (this->error_code() ? 0 : _expression); }
|
||||
unsigned int BOOST_REGEX_CALL set_expression(const charT* p, const charT* end, flag_type f = regbase::normal);
|
||||
unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regbase::normal) { return set_expression(p, p + traits_type::length(p), f); }
|
||||
unsigned int BOOST_REGEX_CALL set_expression(const charT* p, const charT* end, flag_type f = regex_constants::normal);
|
||||
unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regex_constants::normal) { return set_expression(p, p + traits_type::length(p), f); }
|
||||
//
|
||||
// this should be private but template friends don't work:
|
||||
const traits_type& get_traits()const { return traits_inst; }
|
||||
@@ -336,9 +336,9 @@ public:
|
||||
typedef typename reg_expression<charT, traits, Allocator>::size_type size_type;
|
||||
explicit basic_regex(const Allocator& a = Allocator())
|
||||
: reg_expression<charT, traits, Allocator>(a){}
|
||||
explicit basic_regex(const charT* p, flag_type f = regbase::normal, const Allocator& a = Allocator())
|
||||
explicit basic_regex(const charT* p, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
|
||||
: reg_expression<charT, traits, Allocator>(p,f,a){}
|
||||
basic_regex(const charT* p1, const charT* p2, flag_type f = regbase::normal, const Allocator& a = Allocator())
|
||||
basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
|
||||
: reg_expression<charT, traits, Allocator>(p1,p2,f,a){}
|
||||
basic_regex(const charT* p, size_type len, flag_type f, const Allocator& a = Allocator())
|
||||
: reg_expression<charT, traits, Allocator>(p,len,f,a){}
|
||||
@@ -357,11 +357,11 @@ public:
|
||||
}
|
||||
#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !(defined(__IBMCPP__) && (__IBMCPP__ <= 502))
|
||||
template <class ST, class SA>
|
||||
explicit basic_regex(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
|
||||
explicit basic_regex(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
|
||||
: reg_expression<charT, traits, Allocator>(p,f,a){}
|
||||
|
||||
template <class I>
|
||||
basic_regex(I first, I last, flag_type f = regbase::normal, const Allocator& al = Allocator())
|
||||
basic_regex(I first, I last, flag_type f = regex_constants::normal, const Allocator& al = Allocator())
|
||||
: reg_expression<charT, traits, Allocator>(first, last, f, a){}
|
||||
|
||||
template <class ST, class SA>
|
||||
@@ -371,7 +371,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
basic_regex(const std::basic_string<charT>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
|
||||
basic_regex(const std::basic_string<charT>& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
|
||||
: reg_expression<charT, traits, Allocator>(p,f,a){}
|
||||
|
||||
basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string<charT>& p)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace boost{
|
||||
namespace regex_constants{
|
||||
#endif
|
||||
|
||||
typedef enum _match_flags
|
||||
@@ -54,12 +55,14 @@ typedef enum _match_flags
|
||||
match_all = match_stop << 1, // must find the whole of input even if match_any is set
|
||||
match_perl = match_all << 1, // Use perl matching rules
|
||||
match_posix = match_perl << 1, // Use POSIX matching rules
|
||||
match_max = match_posix,
|
||||
match_nosubs = match_posix << 1, // don't trap marked subs
|
||||
match_max = match_nosubs,
|
||||
|
||||
format_all = 0, // enable all extentions to sytax
|
||||
format_perl = 0, // perl style replacement
|
||||
format_default = 0, // ditto.
|
||||
format_sed = match_max << 1, // sed style replacement.
|
||||
format_perl = format_sed << 1, // perl style replacement.
|
||||
format_no_copy = format_perl << 1, // don't copy non-matching segments.
|
||||
format_all = format_sed << 1, // enable all extentions to sytax.
|
||||
format_no_copy = format_all << 1, // don't copy non-matching segments.
|
||||
format_first_only = format_no_copy << 1, // Only replace first occurance.
|
||||
format_is_if = format_first_only << 1 // internal use only.
|
||||
|
||||
@@ -67,7 +70,6 @@ typedef enum _match_flags
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
|
||||
typedef unsigned long match_flag_type;
|
||||
} // namespace boost
|
||||
#else
|
||||
typedef match_flags match_flag_type;
|
||||
|
||||
@@ -87,10 +89,43 @@ inline match_flags& operator|=(match_flags& m1, match_flags m2)
|
||||
{ m1 = m1|m2; return m1; }
|
||||
inline match_flags& operator^=(match_flags& m1, match_flags m2)
|
||||
{ m1 = m1^m2; return m1; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // namespace regex_constants
|
||||
//
|
||||
// import names into boost for backwards compatiblity:
|
||||
//
|
||||
using regex_constants::match_flag_type;
|
||||
using regex_constants::match_default;
|
||||
using regex_constants::match_not_bol;
|
||||
using regex_constants::match_not_eol;
|
||||
using regex_constants::match_not_bob;
|
||||
using regex_constants::match_not_eob;
|
||||
using regex_constants::match_not_bow;
|
||||
using regex_constants::match_not_eow;
|
||||
using regex_constants::match_not_dot_newline;
|
||||
using regex_constants::match_not_dot_null;
|
||||
using regex_constants::match_prev_avail;
|
||||
using regex_constants::match_init;
|
||||
using regex_constants::match_any;
|
||||
using regex_constants::match_not_null;
|
||||
using regex_constants::match_continuous;
|
||||
using regex_constants::match_partial;
|
||||
using regex_constants::match_stop;
|
||||
using regex_constants::match_all;
|
||||
using regex_constants::match_perl;
|
||||
using regex_constants::match_posix;
|
||||
using regex_constants::match_nosubs;
|
||||
using regex_constants::match_max;
|
||||
using regex_constants::format_all;
|
||||
using regex_constants::format_sed;
|
||||
using regex_constants::format_perl;
|
||||
using regex_constants::format_no_copy;
|
||||
using regex_constants::format_first_only;
|
||||
using regex_constants::format_is_if;
|
||||
|
||||
} // namespace boost
|
||||
#endif // __cplusplus
|
||||
#endif // BOOST_MSVC
|
||||
|
||||
#endif
|
||||
#endif // include guard
|
||||
|
||||
@@ -65,7 +65,7 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
|
||||
const charT* p = reinterpret_cast<const charT*>(set_+1);
|
||||
iterator ptr;
|
||||
unsigned int i;
|
||||
bool icase = e.flags() & regbase::icase;
|
||||
bool icase = e.flags() & regex_constants::icase;
|
||||
|
||||
if(next == last) return next;
|
||||
|
||||
@@ -119,7 +119,7 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
|
||||
// try and match a range, NB only a single character can match
|
||||
if(set_->cranges)
|
||||
{
|
||||
if(e.flags() & regbase::nocollate)
|
||||
if((e.flags() & regex_constants::collate) == 0)
|
||||
s1 = s2;
|
||||
else
|
||||
traits_inst.transform(s1, s2);
|
||||
|
||||
@@ -44,11 +44,11 @@ perl_matcher<BidiIterator, Allocator, traits, Allocator2>::perl_matcher(BidiIter
|
||||
|
||||
pstate = 0;
|
||||
m_match_flags = f;
|
||||
icase = re.flags() & regbase::icase;
|
||||
icase = re.flags() & regex_constants::icase;
|
||||
estimate_max_state_count(static_cast<category*>(0));
|
||||
if(!(m_match_flags & (match_perl|match_posix)))
|
||||
{
|
||||
if(re.flags() & regbase::perlex)
|
||||
if(re.flags() & regex_constants::perlex)
|
||||
m_match_flags |= match_perl;
|
||||
else
|
||||
m_match_flags |= match_posix;
|
||||
@@ -104,7 +104,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match()
|
||||
position = base;
|
||||
search_base = base;
|
||||
state_count = 0;
|
||||
m_presult->set_size(re.mark_count(), base, last);
|
||||
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), base, last);
|
||||
m_presult->set_base(base);
|
||||
if(m_match_flags & match_posix)
|
||||
m_result = *m_presult;
|
||||
@@ -156,7 +156,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find()
|
||||
position = base;
|
||||
search_base = base;
|
||||
pstate = access::first(re);
|
||||
m_presult->set_size(re.mark_count(), base, last);
|
||||
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), base, last);
|
||||
m_presult->set_base(base);
|
||||
m_match_flags |= match_init;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find()
|
||||
++position;
|
||||
}
|
||||
// reset $` start:
|
||||
m_presult->set_size(re.mark_count(), search_base, last);
|
||||
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), search_base, last);
|
||||
if(base != search_base)
|
||||
m_match_flags |= match_prev_avail;
|
||||
}
|
||||
@@ -242,7 +242,8 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_endmark()
|
||||
int index = static_cast<const re_brace*>(pstate)->index;
|
||||
if(index > 0)
|
||||
{
|
||||
m_presult->set_second(position, index);
|
||||
if((m_match_flags & match_nosubs) == 0)
|
||||
m_presult->set_second(position, index);
|
||||
}
|
||||
else if(index < 0)
|
||||
{
|
||||
@@ -706,7 +707,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_lit
|
||||
int len = info->len;
|
||||
const char_type* x = info->pstr;
|
||||
int j = 0;
|
||||
bool icase = re.flags() & regbase::icase;
|
||||
bool icase = re.flags() & regex_constants::icase;
|
||||
while (position != last)
|
||||
{
|
||||
while((j > -1) && (x[j] != traits_inst.translate(*position, icase)))
|
||||
|
||||
@@ -311,8 +311,11 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
|
||||
default:
|
||||
{
|
||||
assert(index > 0);
|
||||
push_matched_paren(index, (*m_presult)[index]);
|
||||
m_presult->set_first(position, index);
|
||||
if((m_match_flags & match_nosubs) == 0)
|
||||
{
|
||||
push_matched_paren(index, (*m_presult)[index]);
|
||||
m_presult->set_first(position, index);
|
||||
}
|
||||
pstate = pstate->next.p;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -105,12 +105,19 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
|
||||
default:
|
||||
{
|
||||
assert(index > 0);
|
||||
backup_subex<BidiIterator> sub(*m_presult, index);
|
||||
m_presult->set_first(position, index);
|
||||
pstate = pstate->next.p;
|
||||
r = match_all_states();
|
||||
if(r == false)
|
||||
sub.restore(*m_presult);
|
||||
if((m_match_flags & match_nosubs) == 0)
|
||||
{
|
||||
backup_subex<BidiIterator> sub(*m_presult, index);
|
||||
m_presult->set_first(position, index);
|
||||
pstate = pstate->next.p;
|
||||
r = match_all_states();
|
||||
if(r == false)
|
||||
sub.restore(*m_presult);
|
||||
}
|
||||
else
|
||||
{
|
||||
pstate = pstate->next.p;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,18 +52,24 @@ public:
|
||||
failbit = use_except << 1, // error flag
|
||||
literal = failbit << 1, // all characters are literals
|
||||
icase = literal << 1, // characters are matched regardless of case
|
||||
nocollate = icase << 1, // don't use locale specific collation
|
||||
perlex = nocollate << 1, // perl extensions
|
||||
nocollate = 0, // don't use locale specific collation (deprecated)
|
||||
collate = icase << 1, // use locale specific collation
|
||||
perlex = collate << 1, // perl extensions
|
||||
nosubs = perlex << 1, // don't mark sub-expressions
|
||||
optimize = 0, // not really supported
|
||||
|
||||
basic = char_classes | intervals | limited_ops | bk_braces | bk_parens | bk_refs,
|
||||
extended = char_classes | intervals | bk_refs,
|
||||
basic = char_classes | intervals | limited_ops | bk_braces | bk_parens | bk_refs | collate,
|
||||
extended = char_classes | intervals | bk_refs | collate,
|
||||
normal = perlex | escape_in_lists | char_classes | intervals | bk_refs | nocollate,
|
||||
emacs = bk_braces | bk_parens | bk_refs | bk_vbar,
|
||||
awk = extended | escape_in_lists,
|
||||
grep = basic | newline_alt,
|
||||
egrep = extended | newline_alt,
|
||||
sed = basic,
|
||||
perl = normal
|
||||
perl = normal,
|
||||
ECMAScript = normal,
|
||||
JavaScript = normal,
|
||||
JScript = normal
|
||||
};
|
||||
typedef unsigned int flag_type;
|
||||
|
||||
@@ -91,6 +97,51 @@ protected:
|
||||
flag_type _flags;
|
||||
};
|
||||
|
||||
//
|
||||
// provide std lib proposal compatible constants:
|
||||
//
|
||||
namespace regex_constants{
|
||||
|
||||
enum flag_type_
|
||||
{
|
||||
escape_in_lists = ::boost::regbase::escape_in_lists,
|
||||
char_classes = ::boost::regbase::char_classes,
|
||||
intervals = ::boost::regbase::intervals,
|
||||
limited_ops = ::boost::regbase::limited_ops,
|
||||
newline_alt = ::boost::regbase::newline_alt,
|
||||
bk_plus_qm = ::boost::regbase::bk_plus_qm,
|
||||
bk_braces = ::boost::regbase::bk_braces,
|
||||
bk_parens = ::boost::regbase::bk_parens,
|
||||
bk_refs = ::boost::regbase::bk_refs,
|
||||
bk_vbar = ::boost::regbase::bk_vbar,
|
||||
|
||||
use_except = ::boost::regbase::use_except,
|
||||
failbit = ::boost::regbase::failbit,
|
||||
literal = ::boost::regbase::literal,
|
||||
icase = ::boost::regbase::icase,
|
||||
nocollate = ::boost::regbase::nocollate,
|
||||
collate = ::boost::regbase::collate,
|
||||
perlex = ::boost::regbase::perlex,
|
||||
nosubs = ::boost::regbase::nosubs,
|
||||
optimize = ::boost::regbase::optimize,
|
||||
|
||||
basic = ::boost::regbase::basic,
|
||||
extended = ::boost::regbase::extended,
|
||||
normal = ::boost::regbase::normal,
|
||||
emacs = ::boost::regbase::emacs,
|
||||
awk = ::boost::regbase::awk,
|
||||
grep = ::boost::regbase::grep,
|
||||
egrep = ::boost::regbase::egrep,
|
||||
sed = basic,
|
||||
perl = normal,
|
||||
ECMAScript = normal,
|
||||
JavaScript = normal,
|
||||
JScript = normal
|
||||
};
|
||||
typedef ::boost::regbase::flag_type syntax_option_type;
|
||||
|
||||
} // namespace regex_constants
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
|
||||
@@ -145,6 +145,9 @@ typedef match_results<std::wstring::const_iterator> wsmatch;
|
||||
#ifndef BOOST_REGEX_V4_REGEX_GREP_HPP
|
||||
#include <boost/regex/v4/regex_grep.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP
|
||||
#include <boost/regex/v4/regex_replace.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_REGEX_V4_REGEX_MERGE_HPP
|
||||
#include <boost/regex/v4/regex_merge.hpp>
|
||||
#endif
|
||||
|
||||
@@ -51,7 +51,7 @@ bool BOOST_REGEX_CALL re_maybe_set_member(charT c,
|
||||
const reg_expression<charT, traits_type, Allocator>& e)
|
||||
{
|
||||
const charT* p = reinterpret_cast<const charT*>(set_+1);
|
||||
bool icase = e.flags() & regbase::icase;
|
||||
bool icase = e.flags() & regex_constants::icase;
|
||||
charT col = e.get_traits().translate(c, icase);
|
||||
for(unsigned int i = 0; i < set_->csingles; ++i)
|
||||
{
|
||||
@@ -91,21 +91,21 @@ template <class charT, class traits, class Allocator>
|
||||
reg_expression<charT, traits, Allocator>::reg_expression(const charT* p, flag_type f, const Allocator& a)
|
||||
: data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0)
|
||||
{
|
||||
set_expression(p, f | regbase::use_except);
|
||||
set_expression(p, f | regex_constants::use_except);
|
||||
}
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
reg_expression<charT, traits, Allocator>::reg_expression(const charT* p1, const charT* p2, flag_type f, const Allocator& a)
|
||||
: data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0)
|
||||
{
|
||||
set_expression(p1, p2, f | regbase::use_except);
|
||||
set_expression(p1, p2, f | regex_constants::use_except);
|
||||
}
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
reg_expression<charT, traits, Allocator>::reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a)
|
||||
: data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0)
|
||||
{
|
||||
set_expression(p, p + len, f | regbase::use_except);
|
||||
set_expression(p, p + len, f | regex_constants::use_except);
|
||||
}
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
@@ -118,11 +118,11 @@ reg_expression<charT, traits, Allocator>::reg_expression(const reg_expression<ch
|
||||
if(e.error_code() == 0)
|
||||
{
|
||||
const charT* pe = e.expression();
|
||||
set_expression(pe, pe + e._expression_len, e.flags() | regbase::use_except);
|
||||
set_expression(pe, pe + e._expression_len, e.flags() | regex_constants::use_except);
|
||||
}
|
||||
else
|
||||
{
|
||||
_flags = e.flags() & ~(regbase::use_except);
|
||||
_flags = e.flags() & ~(regex_constants::use_except);
|
||||
fail(e.error_code());
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ reg_expression<charT, traits, Allocator>& BOOST_REGEX_CALL reg_expression<charT,
|
||||
_flags = use_except;
|
||||
fail(e.error_code());
|
||||
if(error_code() == 0)
|
||||
set_expression(e._expression, e._expression + e._expression_len, e.flags() | regbase::use_except);
|
||||
set_expression(e._expression, e._expression + e._expression_len, e.flags() | regex_constants::use_except);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -498,12 +498,12 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
|
||||
case re_detail::syntax_element_literal:
|
||||
// only the first character of the literal can match:
|
||||
// note these have already been translated:
|
||||
if(*reinterpret_cast<charT*>(static_cast<re_detail::re_literal*>(node)+1) == traits_inst.translate(cc, (_flags & regbase::icase)))
|
||||
if(*reinterpret_cast<charT*>(static_cast<re_detail::re_literal*>(node)+1) == traits_inst.translate(cc, (_flags & regex_constants::icase)))
|
||||
return true;
|
||||
return false;
|
||||
case re_detail::syntax_element_end_line:
|
||||
// next character (if there is one!) must be a newline:
|
||||
if(traits_inst.is_separator(traits_inst.translate(cc, (_flags & regbase::icase))))
|
||||
if(traits_inst.is_separator(traits_inst.translate(cc, (_flags & regex_constants::icase))))
|
||||
return true;
|
||||
return false;
|
||||
case re_detail::syntax_element_wild:
|
||||
@@ -512,10 +512,10 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
|
||||
return true;
|
||||
case re_detail::syntax_element_within_word:
|
||||
case re_detail::syntax_element_word_start:
|
||||
return traits_inst.is_class(traits_inst.translate(cc, (_flags & regbase::icase)), traits_type::char_class_word);
|
||||
return traits_inst.is_class(traits_inst.translate(cc, (_flags & regex_constants::icase)), traits_type::char_class_word);
|
||||
case re_detail::syntax_element_word_end:
|
||||
// what follows must not be a word character,
|
||||
return traits_inst.is_class(traits_inst.translate(cc, (_flags & regbase::icase)), traits_type::char_class_word) ? false : true;
|
||||
return traits_inst.is_class(traits_inst.translate(cc, (_flags & regex_constants::icase)), traits_type::char_class_word) ? false : true;
|
||||
case re_detail::syntax_element_buffer_end:
|
||||
// we can be null, nothing must follow,
|
||||
// NB we assume that this is followed by
|
||||
@@ -527,7 +527,7 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
|
||||
// NB we assume that this is followed by
|
||||
// re_detail::syntax_element_match, if its not then we can
|
||||
// never match anything anyway!!
|
||||
return traits_inst.is_separator(traits_inst.translate(cc, (_flags & regbase::icase)));
|
||||
return traits_inst.is_separator(traits_inst.translate(cc, (_flags & regex_constants::icase)));
|
||||
case re_detail::syntax_element_backref:
|
||||
// there's no easy way to determine this
|
||||
// which is not to say it can't be done!
|
||||
@@ -540,7 +540,7 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
|
||||
return re_detail::re_maybe_set_member(cc, static_cast<const re_detail::re_set_long*>(node), *this) || (re_detail::re_is_set_member(static_cast<const charT*>(&cc), static_cast<const charT*>(&cc+1), static_cast<re_detail::re_set_long*>(node), *this) != &cc);
|
||||
case re_detail::syntax_element_set:
|
||||
// set all the elements that are set in corresponding set:
|
||||
c = (traits_size_type)(traits_uchar_type)traits_inst.translate(cc, (_flags & regbase::icase));
|
||||
c = (traits_size_type)(traits_uchar_type)traits_inst.translate(cc, (_flags & regex_constants::icase));
|
||||
return static_cast<re_detail::re_set*>(node)->_map[c] != 0;
|
||||
case re_detail::syntax_element_jump:
|
||||
if(static_cast<re_detail::re_jump*>(node)->alt.p < node)
|
||||
@@ -583,7 +583,7 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
|
||||
else
|
||||
return probe_start(node->next.p, cc, static_cast<re_detail::re_jump*>(node)->alt.p);
|
||||
case re_detail::syntax_element_combining:
|
||||
return !traits_inst.is_combining(traits_inst.translate(cc, (_flags & regbase::icase)));
|
||||
return !traits_inst.is_combining(traits_inst.translate(cc, (_flags & regex_constants::icase)));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -777,7 +777,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
return 0;
|
||||
}
|
||||
boost::uint_fast32_t id = traits_inst.lookup_classname(base+2, first-2);
|
||||
if(_flags & regbase::icase)
|
||||
if(_flags & regex_constants::icase)
|
||||
{
|
||||
if((id == traits_type::char_class_upper) || (id == traits_type::char_class_lower))
|
||||
{
|
||||
@@ -819,7 +819,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
unsigned i = 0;
|
||||
while(i < len)
|
||||
{
|
||||
s[i] = traits_inst.translate(s[i], (_flags & regbase::icase));
|
||||
s[i] = traits_inst.translate(s[i], (_flags & regex_constants::icase));
|
||||
++i;
|
||||
}
|
||||
traits_string_type s2;
|
||||
@@ -901,7 +901,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
l = last_dash;
|
||||
continue;
|
||||
case traits_type::syntax_slash:
|
||||
if(_flags & regbase::escape_in_lists)
|
||||
if(_flags & regex_constants::escape_in_lists)
|
||||
{
|
||||
++first;
|
||||
if(first == last)
|
||||
@@ -994,7 +994,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
std::size_t len = s.size();
|
||||
while(i < len)
|
||||
{
|
||||
s[i] = traits_inst.translate(s[i], (_flags & regbase::icase));
|
||||
s[i] = traits_inst.translate(s[i], (_flags & regex_constants::icase));
|
||||
++i;
|
||||
}
|
||||
started = true;
|
||||
@@ -1025,7 +1025,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
result = compile_set_aux(singles, ranges, classes, equivalents, isnot, width_type());
|
||||
#ifdef __BORLANDC__
|
||||
// delayed throw:
|
||||
if((result == 0) && (_flags & regbase::use_except))
|
||||
if((result == 0) && (_flags & regex_constants::use_except))
|
||||
fail(error_code());
|
||||
#endif
|
||||
return result;
|
||||
@@ -1040,7 +1040,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
unsigned int cranges = 0;
|
||||
boost::uint_fast32_t cclasses = 0;
|
||||
unsigned int cequivalents = 0;
|
||||
bool nocollate_state = flags() & regbase::nocollate;
|
||||
bool nocollate_state = !(flags() & regex_constants::collate);
|
||||
bool singleton = true;
|
||||
|
||||
while(singles.empty() == false)
|
||||
@@ -1074,7 +1074,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
// delay throw to later:
|
||||
#ifdef __BORLANDC__
|
||||
boost::uint_fast32_t f = _flags;
|
||||
_flags &= ~regbase::use_except;
|
||||
_flags &= ~regex_constants::use_except;
|
||||
#endif
|
||||
fail(REG_ERANGE);
|
||||
#ifdef __BORLANDC__
|
||||
@@ -1129,12 +1129,12 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
{
|
||||
traits_string_type c1, c2, c3, c4;
|
||||
|
||||
if(flags() & regbase::nocollate)
|
||||
if((flags() & regex_constants::collate) == 0)
|
||||
c1 = ranges.peek();
|
||||
else
|
||||
traits_inst.transform(c1, ranges.peek());
|
||||
ranges.pop();
|
||||
if(flags() & regbase::nocollate)
|
||||
if((flags() & regex_constants::collate) == 0)
|
||||
c2 = ranges.peek();
|
||||
else
|
||||
traits_inst.transform(c2, ranges.peek());
|
||||
@@ -1148,7 +1148,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
// delay throw to later:
|
||||
#ifdef __BORLANDC__
|
||||
boost::uint_fast32_t f = _flags;
|
||||
_flags &= ~regbase::use_except;
|
||||
_flags &= ~regex_constants::use_except;
|
||||
#endif
|
||||
fail(REG_ERANGE);
|
||||
#ifdef __BORLANDC__
|
||||
@@ -1159,7 +1159,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
for(unsigned int i = 0; i < 256; ++i)
|
||||
{
|
||||
c4 = (charT)i;
|
||||
if(flags() & regbase::nocollate)
|
||||
if((flags() & regex_constants::collate) == 0)
|
||||
c3 = c4;
|
||||
else
|
||||
traits_inst.transform(c3, c4);
|
||||
@@ -1191,7 +1191,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
for(unsigned int i = 0; i < 256; ++i)
|
||||
{
|
||||
if(traits_inst.is_class(charT(i), flags))
|
||||
dat->_map[(traits_uchar_type)traits_inst.translate((charT)i, (_flags & regbase::icase))] = re_detail::mask_all;
|
||||
dat->_map[(traits_uchar_type)traits_inst.translate((charT)i, (_flags & regex_constants::icase))] = re_detail::mask_all;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1317,7 +1317,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
|
||||
#endif
|
||||
#ifdef __OpenBSD__
|
||||
// strxfrm not working on OpenBSD??
|
||||
f |= regbase::nocollate;
|
||||
f &= ~regex_constants::collate;
|
||||
#endif
|
||||
|
||||
if(p == expression())
|
||||
@@ -1357,11 +1357,11 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
|
||||
++marks;
|
||||
dat = 0;
|
||||
|
||||
if(_flags & regbase::literal)
|
||||
if(_flags & regex_constants::literal)
|
||||
{
|
||||
while(ptr != end)
|
||||
{
|
||||
dat = add_literal(dat, traits_inst.translate(*ptr, (_flags & regbase::icase)));
|
||||
dat = add_literal(dat, traits_inst.translate(*ptr, (_flags & regex_constants::icase)));
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
@@ -1384,8 +1384,16 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
|
||||
open_bracked_jump:
|
||||
// extend:
|
||||
dat = add_simple(dat, re_detail::syntax_element_startmark, sizeof(re_detail::re_brace));
|
||||
markid.push(marks);
|
||||
static_cast<re_detail::re_brace*>(dat)->index = marks++;
|
||||
if(_flags & nosubs)
|
||||
{
|
||||
markid.push(0);
|
||||
static_cast<re_detail::re_brace*>(dat)->index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
markid.push(marks);
|
||||
static_cast<re_detail::re_brace*>(dat)->index = marks++;
|
||||
}
|
||||
mark.push(data.index(dat));
|
||||
++ptr;
|
||||
//
|
||||
@@ -1811,7 +1819,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
|
||||
dat = compile_set(ptr, end);
|
||||
if(dat == 0)
|
||||
{
|
||||
if((_flags & regbase::failbit) == 0)
|
||||
if((_flags & regex_constants::failbit) == 0)
|
||||
fail(REG_EBRACK);
|
||||
return error_code();
|
||||
}
|
||||
@@ -1963,7 +1971,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
|
||||
fixup_apply(static_cast<re_detail::re_syntax_base*>(data.data()), marks);
|
||||
|
||||
// check for error during fixup:
|
||||
if(_flags & regbase::failbit)
|
||||
if(_flags & regex_constants::failbit)
|
||||
return error_code();
|
||||
|
||||
//
|
||||
@@ -1985,7 +1993,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
|
||||
{
|
||||
charT* p1 = reinterpret_cast<charT*>(reinterpret_cast<char*>(sbase) + sizeof(re_detail::re_literal));
|
||||
charT* p2 = p1 + static_cast<re_detail::re_literal*>(sbase)->length;
|
||||
pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator<traits>(_flags®base::icase, &traits_inst), data.allocator());
|
||||
pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator<traits>(_flags®ex_constants::icase, &traits_inst), data.allocator());
|
||||
}
|
||||
}
|
||||
return error_code();
|
||||
@@ -2022,7 +2030,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
{
|
||||
// add another charT to the list:
|
||||
std::ptrdiff_t pos = reinterpret_cast<unsigned char*>(dat) - reinterpret_cast<unsigned char*>(data.data());
|
||||
*reinterpret_cast<charT*>(data.extend(sizeof(charT))) = traits_inst.translate(c, (_flags & regbase::icase));
|
||||
*reinterpret_cast<charT*>(data.extend(sizeof(charT))) = traits_inst.translate(c, (_flags & regex_constants::icase));
|
||||
dat = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<unsigned char*>(data.data()) + pos);
|
||||
++(static_cast<re_detail::re_literal*>(dat)->length);
|
||||
}
|
||||
@@ -2031,7 +2039,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
|
||||
// extend:
|
||||
dat = add_simple(dat, re_detail::syntax_element_literal, sizeof(re_detail::re_literal) + sizeof(charT));
|
||||
static_cast<re_detail::re_literal*>(dat)->length = 1;
|
||||
*reinterpret_cast<charT*>(reinterpret_cast<re_detail::re_literal*>(dat)+1) = traits_inst.translate(c, (_flags & regbase::icase));
|
||||
*reinterpret_cast<charT*>(reinterpret_cast<re_detail::re_literal*>(dat)+1) = traits_inst.translate(c, (_flags & regex_constants::icase));
|
||||
}
|
||||
return dat;
|
||||
}
|
||||
@@ -2082,7 +2090,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_le
|
||||
leading_lit = false;
|
||||
const charT* p1 = _leading_string;
|
||||
const charT* p2 = _leading_string + _leading_string_len;
|
||||
pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator<traits>(_flags®base::icase, &traits_inst), data.allocator());
|
||||
pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator<traits>(_flags®ex_constants::icase, &traits_inst), data.allocator());
|
||||
}
|
||||
leading_lit = false;
|
||||
break;
|
||||
@@ -2140,16 +2148,16 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fail(unsigned in
|
||||
error_code_ = err;
|
||||
if(err)
|
||||
{
|
||||
_flags |= regbase::failbit;
|
||||
_flags |= regex_constants::failbit;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(_flags & regbase::use_except)
|
||||
if(_flags & regex_constants::use_except)
|
||||
{
|
||||
re_detail::raise_error(traits_inst, err);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
_flags &= ~regbase::failbit;
|
||||
_flags &= ~regex_constants::failbit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ expand_sub:
|
||||
continue;
|
||||
}
|
||||
case traits_type::syntax_open_bracket:
|
||||
if(flags & (format_sed|format_perl))
|
||||
if(0 == (flags & format_all))
|
||||
{
|
||||
*out = *fmt;
|
||||
++out;
|
||||
@@ -351,7 +351,7 @@ expand_sub:
|
||||
continue;
|
||||
}
|
||||
case traits_type::syntax_close_bracket:
|
||||
if(flags & (format_sed|format_perl))
|
||||
if(0 == (flags & format_all))
|
||||
{
|
||||
*out = *fmt;
|
||||
++out;
|
||||
@@ -375,7 +375,7 @@ expand_sub:
|
||||
continue;
|
||||
case traits_type::syntax_question:
|
||||
{
|
||||
if(flags & (format_sed|format_perl))
|
||||
if(0 == (flags & format_all))
|
||||
{
|
||||
*out = *fmt;
|
||||
++out;
|
||||
|
||||
@@ -42,7 +42,7 @@ inline unsigned int regex_grep(Predicate foo,
|
||||
const reg_expression<charT, traits, Allocator>& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
if(e.flags() & regbase::failbit)
|
||||
if(e.flags() & regex_constants::failbit)
|
||||
return false;
|
||||
typedef detail::rebind_allocator<sub_match<BidiIterator>, Allocator> binder;
|
||||
typedef typename binder::type match_allocator_type;
|
||||
|
||||
@@ -33,17 +33,14 @@ namespace boost{
|
||||
#endif
|
||||
|
||||
template <class OutputIterator, class Iterator, class traits, class Allocator, class charT>
|
||||
OutputIterator regex_merge(OutputIterator out,
|
||||
inline OutputIterator regex_merge(OutputIterator out,
|
||||
Iterator first,
|
||||
Iterator last,
|
||||
const reg_expression<charT, traits, Allocator>& e,
|
||||
const charT* fmt,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
Iterator l = first;
|
||||
re_detail::merge_out_predicate<OutputIterator, Iterator, charT, Allocator, traits> oi(out, l, fmt, flags, e.get_traits());
|
||||
regex_grep(oi, first, last, e, flags);
|
||||
return (flags & format_no_copy) ? out : re_detail::re_copy_out(out, l, last);
|
||||
return regex_replace(out, first, last, e, fmt, flags);
|
||||
}
|
||||
|
||||
template <class OutputIterator, class Iterator, class traits, class Allocator, class charT>
|
||||
@@ -58,27 +55,21 @@ inline OutputIterator regex_merge(OutputIterator out,
|
||||
}
|
||||
|
||||
template <class traits, class Allocator, class charT>
|
||||
std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
|
||||
inline std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
|
||||
const reg_expression<charT, traits, Allocator>& e,
|
||||
const charT* fmt,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
std::basic_string<charT> result;
|
||||
re_detail::string_out_iterator<std::basic_string<charT> > i(result);
|
||||
regex_merge(i, s.begin(), s.end(), e, fmt, flags);
|
||||
return result;
|
||||
return regex_replace(s, e, fmt, flags);
|
||||
}
|
||||
|
||||
template <class traits, class Allocator, class charT>
|
||||
std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
|
||||
inline std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
|
||||
const reg_expression<charT, traits, Allocator>& e,
|
||||
const std::basic_string<charT>& fmt,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
std::basic_string<charT> result;
|
||||
re_detail::string_out_iterator<std::basic_string<charT> > i(result);
|
||||
regex_merge(i, s.begin(), s.end(), e, fmt.c_str(), flags);
|
||||
return result;
|
||||
return regex_replace(s, e, fmt, flags);
|
||||
}
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2002
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Dr John Maddock makes no representations
|
||||
* about the suitability of this software for any purpose.
|
||||
* It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_format.hpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Provides formatting output routines for search and replace
|
||||
* operations. Note this is an internal header file included
|
||||
* by regex.hpp, do not include on its own.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP
|
||||
#define BOOST_REGEX_V4_REGEX_REPLACE_HPP
|
||||
|
||||
|
||||
namespace boost{
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma option push -a8 -b -Vx -Ve -pc -w-8037
|
||||
#endif
|
||||
|
||||
template <class OutputIterator, class Iterator, class traits, class Allocator, class charT>
|
||||
OutputIterator regex_replace(OutputIterator out,
|
||||
Iterator first,
|
||||
Iterator last,
|
||||
const reg_expression<charT, traits, Allocator>& e,
|
||||
const charT* fmt,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
Iterator l = first;
|
||||
re_detail::merge_out_predicate<OutputIterator, Iterator, charT, Allocator, traits> oi(out, l, fmt, flags, e.get_traits());
|
||||
regex_grep(oi, first, last, e, flags);
|
||||
return (flags & format_no_copy) ? out : re_detail::re_copy_out(out, l, last);
|
||||
}
|
||||
|
||||
template <class OutputIterator, class Iterator, class traits, class Allocator, class charT>
|
||||
inline OutputIterator regex_replace(OutputIterator out,
|
||||
Iterator first,
|
||||
Iterator last,
|
||||
const reg_expression<charT, traits, Allocator>& e,
|
||||
const std::basic_string<charT>& fmt,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
return regex_replace(out, first, last, e, fmt.c_str(), flags);
|
||||
}
|
||||
|
||||
template <class traits, class Allocator, class charT>
|
||||
std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
|
||||
const reg_expression<charT, traits, Allocator>& e,
|
||||
const charT* fmt,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
std::basic_string<charT> result;
|
||||
re_detail::string_out_iterator<std::basic_string<charT> > i(result);
|
||||
regex_replace(i, s.begin(), s.end(), e, fmt, flags);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class traits, class Allocator, class charT>
|
||||
std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
|
||||
const reg_expression<charT, traits, Allocator>& e,
|
||||
const std::basic_string<charT>& fmt,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
std::basic_string<charT> result;
|
||||
re_detail::string_out_iterator<std::basic_string<charT> > i(result);
|
||||
regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma option pop
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_REGEX_V4_REGEX_REPLACE_HPP
|
||||
|
||||
@@ -36,7 +36,7 @@ bool regex_search(BidiIterator first, BidiIterator last,
|
||||
const reg_expression<charT, traits, Allocator2>& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
if(e.flags() & regbase::failbit)
|
||||
if(e.flags() & regex_constants::failbit)
|
||||
return false;
|
||||
|
||||
re_detail::perl_matcher<BidiIterator, Allocator, traits, Allocator2> matcher(first, last, m, e, flags);
|
||||
@@ -103,6 +103,89 @@ inline bool regex_search(const std::basic_string<wchar_t>& s,
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
template <class BidiIterator, class charT, class traits, class Allocator2>
|
||||
bool regex_search(BidiIterator first, BidiIterator last,
|
||||
const reg_expression<charT, traits, Allocator2>& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
if(e.flags() & regex_constants::failbit)
|
||||
return false;
|
||||
|
||||
match_results<BidiIterator> m;
|
||||
typedef typename match_results<BidiIterator>::allocator_type match_alloc_type;
|
||||
re_detail::perl_matcher<BidiIterator, match_alloc_type, traits, Allocator2> matcher(first, last, m, e, flags);
|
||||
return matcher.find();
|
||||
}
|
||||
|
||||
template <class charT, class traits, class Allocator2>
|
||||
inline bool regex_search(const charT* str,
|
||||
const reg_expression<charT, traits, Allocator2>& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
return regex_search(str, str + traits::length(str), e, flags);
|
||||
}
|
||||
|
||||
template <class ST, class SA, class charT, class traits, class Allocator2>
|
||||
inline bool regex_search(const std::basic_string<charT, ST, SA>& s,
|
||||
const reg_expression<charT, traits, Allocator2>& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
return regex_search(s.begin(), s.end(), e, flags);
|
||||
}
|
||||
#else // non-template function overloads
|
||||
inline bool regex_search(const char* first, const char* last,
|
||||
const regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
cmatch m;
|
||||
return regex_search(first, last, m, e, flags);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
inline bool regex_search(const wchar_t* first, const wchar_t* last,
|
||||
const wregex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
wcmatch m;
|
||||
return regex_search(first, last, m, e, flags);
|
||||
}
|
||||
#endif
|
||||
inline bool regex_search(const char* str,
|
||||
const regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
cmatch m;
|
||||
return regex_search(str, str + regex::traits_type::length(str), m, e, flags);
|
||||
}
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
inline bool regex_search(const wchar_t* str,
|
||||
const wregex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
wcmatch m;
|
||||
return regex_search(str, str + wregex::traits_type::length(str), m, e, flags);
|
||||
}
|
||||
#endif
|
||||
inline bool regex_search(const std::string& s,
|
||||
const regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
smatch m;
|
||||
return regex_search(s.begin(), s.end(), m, e, flags);
|
||||
}
|
||||
#if !defined(BOOST_NO_WREGEX)
|
||||
inline bool regex_search(const std::basic_string<wchar_t>& s,
|
||||
const wregex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
wsmatch m;
|
||||
return regex_search(s.begin(), s.end(), m, e, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma option pop
|
||||
#endif
|
||||
|
||||
@@ -205,6 +205,57 @@ bool operator >= (typename re_detail::regex_iterator_traits<RandomAccessIterator
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(s) <= 0; }
|
||||
|
||||
// comparison to const charT& part 1:
|
||||
template <class RandomAccessIterator>
|
||||
bool operator == (const sub_match<RandomAccessIterator>& m,
|
||||
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) == 0; }
|
||||
template <class RandomAccessIterator>
|
||||
bool operator != (const sub_match<RandomAccessIterator>& m,
|
||||
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) != 0; }
|
||||
template <class RandomAccessIterator>
|
||||
bool operator > (const sub_match<RandomAccessIterator>& m,
|
||||
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) > 0; }
|
||||
template <class RandomAccessIterator>
|
||||
bool operator < (const sub_match<RandomAccessIterator>& m,
|
||||
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) < 0; }
|
||||
template <class RandomAccessIterator>
|
||||
bool operator >= (const sub_match<RandomAccessIterator>& m,
|
||||
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) >= 0; }
|
||||
template <class RandomAccessIterator>
|
||||
bool operator <= (const sub_match<RandomAccessIterator>& m,
|
||||
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) <= 0; }
|
||||
// comparison to const charT* part 2:
|
||||
template <class RandomAccessIterator>
|
||||
bool operator == (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) == 0; }
|
||||
template <class RandomAccessIterator>
|
||||
bool operator != (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) != 0; }
|
||||
template <class RandomAccessIterator>
|
||||
bool operator < (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) > 0; }
|
||||
template <class RandomAccessIterator>
|
||||
bool operator > (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) < 0; }
|
||||
template <class RandomAccessIterator>
|
||||
bool operator <= (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) >= 0; }
|
||||
template <class RandomAccessIterator>
|
||||
bool operator >= (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) <= 0; }
|
||||
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
template <class charT, class traits, class RandomAccessIterator>
|
||||
std::basic_ostream<charT, traits>&
|
||||
|
||||
Reference in New Issue
Block a user