Added new docs,

Moved source more into line with the std lib proposal.


[SVN r18292]
This commit is contained in:
John Maddock
2003-04-23 10:49:57 +00:00
parent c233f06654
commit c8f2ed3bdb
111 changed files with 17582 additions and 7758 deletions
+23 -19
View File
@@ -52,26 +52,28 @@ flag_info flag_data[] = {
{ BOOST_RE_STR("REG_NOTEOL"), 10, REG_NOTEOL, 1 },
{ BOOST_RE_STR("REG_STARTEND"), 12, REG_STARTEND, 1 },
{ BOOST_RE_STR("basic"), 5, regbase::basic, 2 },
{ BOOST_RE_STR("escape_in_lists"), 15, regbase::escape_in_lists, 2 },
{ BOOST_RE_STR("char_classes"), 12, regbase::char_classes, 2 },
{ BOOST_RE_STR("intervals"), 9, regbase::intervals, 2 },
{ BOOST_RE_STR("limited_ops"), 11, regbase::limited_ops, 2 },
{ BOOST_RE_STR("newline_alt"), 11, regbase::newline_alt, 2 },
{ BOOST_RE_STR("bk_plus_qm"), 10, regbase::bk_plus_qm, 2 },
{ BOOST_RE_STR("bk_braces"), 9, regbase::bk_braces, 2 },
{ BOOST_RE_STR("bk_parens"), 9, regbase::bk_parens, 2 },
{ BOOST_RE_STR("bk_refs"), 7, regbase::bk_refs, 2 },
{ BOOST_RE_STR("bk_vbar"), 7, regbase::bk_vbar, 2 },
{ BOOST_RE_STR("use_except"), 10, regbase::use_except, 2 },
{ BOOST_RE_STR("literal"), 7, regbase::literal, 2 },
{ BOOST_RE_STR("basic"), 5, regex_constants::basic, 2 },
{ BOOST_RE_STR("escape_in_lists"), 15, regex_constants::escape_in_lists, 2 },
{ BOOST_RE_STR("char_classes"), 12, regex_constants::char_classes, 2 },
{ BOOST_RE_STR("intervals"), 9, regex_constants::intervals, 2 },
{ BOOST_RE_STR("limited_ops"), 11, regex_constants::limited_ops, 2 },
{ BOOST_RE_STR("newline_alt"), 11, regex_constants::newline_alt, 2 },
{ BOOST_RE_STR("bk_plus_qm"), 10, regex_constants::bk_plus_qm, 2 },
{ BOOST_RE_STR("bk_braces"), 9, regex_constants::bk_braces, 2 },
{ BOOST_RE_STR("bk_parens"), 9, regex_constants::bk_parens, 2 },
{ BOOST_RE_STR("bk_refs"), 7, regex_constants::bk_refs, 2 },
{ BOOST_RE_STR("bk_vbar"), 7, regex_constants::bk_vbar, 2 },
{ BOOST_RE_STR("use_except"), 10, regex_constants::use_except, 2 },
{ BOOST_RE_STR("literal"), 7, regex_constants::literal, 2 },
{ BOOST_RE_STR("nosubs"), 6, regex_constants::nosubs, 2 },
{ BOOST_RE_STR("optimize"), 8, regex_constants::optimize, 2 },
#ifndef BOOST_REGEX_V3
{ BOOST_RE_STR("perlex"), 6, regbase::perlex, 2 },
{ BOOST_RE_STR("perlex"), 6, regex_constants::perlex, 2 },
#endif
{ BOOST_RE_STR("normal"), 6, regbase::normal, 2 },
{ BOOST_RE_STR("basic"), 5, regbase::basic, 2 },
{ BOOST_RE_STR("extended"), 8, regbase::extended, 2 },
{ BOOST_RE_STR("perl"), 6, regbase::perl, 2 },
{ BOOST_RE_STR("normal"), 6, regex_constants::normal, 2 },
{ BOOST_RE_STR("basic"), 5, regex_constants::basic, 2 },
{ BOOST_RE_STR("extended"), 8, regex_constants::extended, 2 },
{ BOOST_RE_STR("perl"), 6, regex_constants::perl, 2 },
{ BOOST_RE_STR("match_default"), 13, match_default, 3 },
{ BOOST_RE_STR("match_not_bol"), 13, match_not_bol, 3 },
@@ -87,7 +89,9 @@ flag_info flag_data[] = {
{ BOOST_RE_STR("match_not_null"), 14, match_not_null, 3 },
{ BOOST_RE_STR("match_continuous"), 16, match_continuous, 3 },
{ BOOST_RE_STR("match_partial"), 13, match_partial, 3 },
{ BOOST_RE_STR("match_nosubs"), 12, match_nosubs, 3 },
{ BOOST_RE_STR("format_all"), 10, format_all, 3 },
{ BOOST_RE_STR("format_sed"), 10, format_sed, 3 },
{ BOOST_RE_STR("format_perl"), 11, format_perl, 3 },
{ BOOST_RE_STR("format_no_copy"), 14, format_no_copy, 3 },
@@ -116,7 +120,7 @@ typedef basic_regex<char_t> re_parse_t;
typedef match_results<string_type::const_iterator> parse_grep;
typedef string_type::const_iterator parse_iterator;
re_parse_t parse_expression(expression_text, regbase::normal);
re_parse_t parse_expression(expression_text, regex_constants::normal);
//
// now define our grep predicate function object:
+9 -9
View File
@@ -55,11 +55,11 @@ typedef bool (*pred1_type)(const match_results<ra_it>&);
typedef bool (*pred2_type)(const match_results<test_string_type::const_iterator>&);
//check that all the defined flags are available:
regbase::flag_type f = regbase::escape_in_lists | regbase::char_classes | regbase::intervals | regbase::limited_ops
| regbase::newline_alt | regbase::bk_plus_qm | regbase::bk_braces
| regbase::bk_parens | regbase::bk_refs | regbase::bk_vbar | regbase::use_except
| regbase::failbit | regbase::literal | regbase::icase | regbase::nocollate | regbase::basic
| regbase::extended | regbase::normal | regbase::emacs | regbase::awk | regbase::grep | regbase::egrep | regbase::sed;
regex::flag_type f = regex::escape_in_lists | regex::char_classes | regex::intervals | regex::limited_ops
| regex::newline_alt | regex::bk_plus_qm | regex::bk_braces
| regex::bk_parens | regex::bk_refs | regex::bk_vbar | regex::use_except
| regex::failbit | regex::literal | regex::icase | regex::nocollate | regex::basic
| regex::extended | regex::normal | regex::emacs | regex::awk | regex::grep | regex::egrep | regex::sed;
template class reg_expression<test_char_type>;
template struct sub_match<ra_it>;
@@ -92,13 +92,13 @@ template test_char_type* regex_format(test_char_type*,
const match_results<ra_it>& m,
const test_string_type& fmt,
unsigned flags);
template test_char_type* regex_merge(test_char_type*,
template test_char_type* regex_replace(test_char_type*,
ra_it,
ra_it,
const reg_expression<test_char_type>&,
const test_char_type*,
unsigned int flags);
template test_char_type* regex_merge(test_char_type*,
template test_char_type* regex_replace(test_char_type*,
ra_it,
ra_it,
const reg_expression<test_char_type>& e,
@@ -159,11 +159,11 @@ template test_string_type regex_format
(const match_results<test_string_type::const_iterator>&,
const test_string_type&,
unsigned flags);
template test_string_type regex_merge(const test_string_type&,
template test_string_type regex_replace(const test_string_type&,
const reg_expression<test_char_type>&,
const test_char_type*,
unsigned int flags);
template test_string_type regex_merge(const test_string_type&,
template test_string_type regex_replace(const test_string_type&,
const reg_expression<test_char_type>&,
const test_string_type&,
unsigned int flags);
+28 -7
View File
@@ -70,7 +70,7 @@ void cpp_eh_tests(const basic_regex<C, T, A>& )
#endif
A a;
basic_regex<C, T, A> e(a);
e.set_expression(expression.c_str(), flags[2] | regbase::use_except);
e.set_expression(expression.c_str(), flags[2] | regex::use_except);
#ifndef BOOST_NO_EXCEPTIONS
}
catch(const boost::bad_expression&)
@@ -92,7 +92,7 @@ void cpp_eh_tests(const basic_regex<C, T, A>& )
#endif
{
A a;
basic_regex<C, T, A> e(expression.c_str(), flags[2] | regbase::use_except, a);
basic_regex<C, T, A> e(expression.c_str(), flags[2] | regex::use_except, a);
}
#ifndef BOOST_NO_EXCEPTIONS
catch(const boost::bad_expression&)
@@ -360,14 +360,24 @@ void cpp_tests(const basic_regex<C, T, A>& e, bool recurse = true)
//
// now try comparison operators:
string_type s(m[0]);
if((s != m[0]) || (m[0] != s))
if((s != m[0]) || (m[0] != s)
|| !(s == m[0]) || !(m[0] == s)
|| (s < m[0]) || (m[0] < s)
|| (s > m[0]) || (m[0] > s)
|| !(s <= m[0]) || !(m[0] <= s)
|| !(s >= m[0]) || !(m[0] >= s))
{
begin_error();
cout << "string comparison failed for result" << std::endl;
}
if(s.find_first_of((string_type::value_type)0) == string_type::npos)
{
if((m[0] != s.c_str()) || (s.c_str() != m[0]))
if((m[0] != s.c_str()) || (s.c_str() != m[0])
|| !(m[0] == s.c_str()) || !(s.c_str() == m[0])
|| (m[0] > s.c_str()) || (s.c_str() > m[0])
|| (m[0] < s.c_str()) || (s.c_str() < m[0])
|| !(m[0] >= s.c_str()) || !(s.c_str() >= m[0])
|| !(m[0] <= s.c_str()) || !(s.c_str() <= m[0]))
{
begin_error();
cout << "string comparison failed for result" << std::endl;
@@ -395,6 +405,12 @@ void cpp_tests(const basic_regex<C, T, A>& e, bool recurse = true)
begin_error();
cout << "regex++ API result mismatch in regex_search(const std::string&, match_results&, const basic_regex&, int)" << endl;
}
if(!regex_search(s, e, static_cast<boost::match_flag_type>(flags[3]))
|| !regex_search(s.begin(), s.end(), e, static_cast<boost::match_flag_type>(flags[3])))
{
begin_error();
cout << "regex++ API result mismatch in regex_search(const std::string&, const basic_regex&, int)" << endl;
}
//
// partial match should give same result as full match
// provided a full match is expected:
@@ -431,6 +447,11 @@ void cpp_tests(const basic_regex<C, T, A>& e, bool recurse = true)
begin_error();
cout << "regex++ API result mismatch in regex_search(const char_t*, match_results&, const basic_regex&, int)" << endl;
}
if(!regex_search(search_text.c_str(), e, static_cast<boost::match_flag_type>(flags[3])))
{
begin_error();
cout << "regex++ API result mismatch in regex_search(const char_t*, const basic_regex&, int)" << endl;
}
}
}
if((false == recurse) && (matches[0] == 0) && (matches[1] == static_cast<int>(search_text.size())))
@@ -718,9 +739,9 @@ void run_tests()
try
{
#endif
unsigned int f = flags[2] & ~regbase::use_except;
unsigned int f = flags[2] & ~regex::use_except;
if(flags[0] & REG_ICASE)
f |= regbase::icase;
f |= regex::icase;
re_type e(expression.c_str(), f);
cpp_tests(e, true);
#ifndef BOOST_NO_EXCEPTIONS
@@ -748,7 +769,7 @@ void run_tests()
try
{
#endif
if(((flags[3] & match_partial) == 0) && (flags[2] == regbase::normal) && (has_nulls(search_text.begin(), search_text.end()) == false))
if(((flags[3] & match_partial) == 0) && (flags[2] == regex::normal) && (has_nulls(search_text.begin(), search_text.end()) == false))
{
RegEx e;
e.SetExpression(expression.c_str(), flags[0] & REG_ICASE);
+59 -3
View File
@@ -802,7 +802,6 @@ a+ "...aaa,,," \x{21} "!"
a+ "...aaa,,," \c@ \0
a+ "...aaa,,," \e \27
a+ "...aaa,,," \0101 A
a+ "...aaa,,," (\0101) A
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE format_sed format_no_copy
(a+)(b+) ...aabb,, \0 aabb
@@ -824,8 +823,9 @@ a+ "...aaa,,," (\0101) A
(a+)(b+) ...aabb,, & &
(a+)(b+) ...aabb,, \0 \0
(a+)(b+) ...aabb,, ()?: ()?:
a+ "...aaa,,," \0101 A
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE
- match_default format_all normal REG_EXTENDED REG_STARTEND REG_MERGE
; move to copying unmatched data:
a+ "...aaa,,," bbb "...bbb,,,"
a+(b+) "...aaabb,,," $1 "...bb,,,"
@@ -836,7 +836,7 @@ a+(b+) "...aaabb,,,ab*abbb?" $1 "...bb,,,b*bbb?"
(a+)|(b+) "...aaabb,,,ab*abbb?" (?1A:B)C "...ACBC,,,ACBC*ACBC?"
(a+)|(b+) "...aaabb,,,ab*abbb?" ?1:B "...B,,,B*B?"
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE format_first_only
- match_default format_all normal REG_EXTENDED REG_STARTEND REG_MERGE format_first_only
; move to copying unmatched data, but replace first occurance only:
a+ "...aaa,,," bbb "...bbb,,,"
a+(b+) "...aaabb,,," $1 "...bb,,,"
@@ -1133,6 +1133,8 @@ a()b\1 ab 0 2 1 1
"(.*\r\n){3}.* abcdefghijklmnopqrstuvwxyz.*\r\n" "00001 01 \r\n00002 02 1 2 3 4 5 6 7 8 9 0\r\n00003 03 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n00004 04 \r\n00005 05 \r\n00006 06 Seite: 0001\r\n00007 07 StartSeitEEnde: 0001\r\n00008 08 StartSeiTe Ende: 0001\r\n00009 09 Start seiteEnde: 0001\r\n00010 10 28.2.03\r\n00011 11 Page: 0001\r\n00012 12 Juhu die Erste: 0001\r\n00013 13 Es war einmal! 0001\r\n00014 14 ABCDEFGHIJKLMNOPQRSTUVWXYZ0001\r\n00015 15 abcdefghijklmnopqrstuvwxyz0001\r\n00016 16 lars.schmeiser@gft.com\r\n00017 17 \r\n00018 18 \r\n00019 19 \r\n00020 20 \r\n00021 21 1 2 3 4 5 6 7 8 9 0\r\n00022 22 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n00023 01 \r\n00024 02 1 2 3 4 5 6 7 8 9 0\r\n00025 03 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n00026 04 \r\n00027 05 \r\n00028 06 Seite: 0002\r\n00029 07 StartSeitEEnde: 0002\r\n00030 08 StartSeiTe Ende: 0002\r\n00031 09 Start seiteEnde: 0002\r\n00032 10 28.02.2003\r\n00033 11 Page: 0002\r\n00034 12 Juhu die Erste: 0002\r\n00035 13 Es war einmal! 0002\r\n00036 14 ABCDEFGHIJKLMNOPQRSTUVWXYZ0002\r\n00037 15 abcdefghijklmnopqrstuvwxyz0002\r\n00038 16 lars.schmeiser@194.1.12.111\r\n00039 17 \r\n00040 18 \r\n00041 19 \r\n00042 20 \r\n00043 21 1 2 3 4 5 6 7 8 9 0\r\n" 753 1076 934 1005
- normal REG_PERL
; new (?: construct )
(?>^abc) abc 0 3
(?>^abc) def\nabc 4 7
@@ -1172,4 +1174,58 @@ a()b\1 ab 0 2 1 1
((?>Z)+|A)* ZABCDEFG 0 2 1 2
((?>)+|A)* !
; subtleties of matching with no sub-expressions marked
- normal match_nosubs REG_NO_POSIX_TEST
a(b?c)+d accd 0 4
(wee|week)(knights|night) weeknights 0 10
.* abc 0 3
a(b|(c))d abd 0 3
a(b|(c))d acd 0 3
a(b*|c|e)d abbd 0 4
a(b*|c|e)d acd 0 3
a(b*|c|e)d ad 0 2
a(b?)c abc 0 3
a(b?)c ac 0 2
a(b+)c abc 0 3
a(b+)c abbbc 0 5
a(b*)c ac 0 2
(a|ab)(bc([de]+)f|cde) abcdef 0 6
a([bc]?)c abc 0 3
a([bc]?)c ac 0 2
a([bc]+)c abc 0 3
a([bc]+)c abcc 0 4
a([bc]+)bc abcbc 0 5
a(bb+|b)b abb 0 3
a(bbb+|bb+|b)b abb 0 3
a(bbb+|bb+|b)b abbb 0 4
a(bbb+|bb+|b)bb abbb 0 4
(.*).* abcdef 0 6
(a*)* bc 0 0
- normal nosubs REG_NO_POSIX_TEST
a(b?c)+d accd 0 4
(wee|week)(knights|night) weeknights 0 10
.* abc 0 3
a(b|(c))d abd 0 3
a(b|(c))d acd 0 3
a(b*|c|e)d abbd 0 4
a(b*|c|e)d acd 0 3
a(b*|c|e)d ad 0 2
a(b?)c abc 0 3
a(b?)c ac 0 2
a(b+)c abc 0 3
a(b+)c abbbc 0 5
a(b*)c ac 0 2
(a|ab)(bc([de]+)f|cde) abcdef 0 6
a([bc]?)c abc 0 3
a([bc]?)c ac 0 2
a([bc]+)c abc 0 3
a([bc]+)c abcc 0 4
a([bc]+)bc abcbc 0 5
a(bb+|b)b abb 0 3
a(bbb+|bb+|b)b abb 0 3
a(bbb+|bb+|b)b abbb 0 4
a(bbb+|bb+|b)bb abbb 0 4
(.*).* abcdef 0 6
(a*)* bc 0 0
+9 -9
View File
@@ -63,11 +63,11 @@ typedef bool (*pred1_type)(const match_results<ra_it>&);
typedef bool (*pred2_type)(const match_results<test_string_type::const_iterator>&);
//check that all the defined flags are available:
regbase::flag_type f = regbase::escape_in_lists | regbase::char_classes | regbase::intervals | regbase::limited_ops
| regbase::newline_alt | regbase::bk_plus_qm | regbase::bk_braces
| regbase::bk_parens | regbase::bk_refs | regbase::bk_vbar | regbase::use_except
| regbase::failbit | regbase::literal | regbase::icase | regbase::nocollate | regbase::basic
| regbase::extended | regbase::normal | regbase::emacs | regbase::awk | regbase::grep | regbase::egrep | regbase::sed;
wregex::flag_type f = wregex::escape_in_lists | wregex::char_classes | wregex::intervals | wregex::limited_ops
| wregex::newline_alt | wregex::bk_plus_qm | wregex::bk_braces
| wregex::bk_parens | wregex::bk_refs | wregex::bk_vbar | wregex::use_except
| wregex::failbit | wregex::literal | wregex::icase | wregex::nocollate | wregex::basic
| wregex::extended | wregex::normal | wregex::emacs | wregex::awk | wregex::grep | wregex::egrep | wregex::sed;
template class reg_expression<char_type>;
template struct sub_match<ra_it>;
@@ -100,13 +100,13 @@ template char_type* regex_format(char_type*,
const match_results<ra_it>& m,
const test_string_type& fmt,
unsigned flags);
template char_type* regex_merge(char_type*,
template char_type* regex_replace(char_type*,
ra_it,
ra_it,
const reg_expression<char_type>&,
const char_type*,
unsigned int flags);
template char_type* regex_merge(char_type*,
template char_type* regex_replace(char_type*,
ra_it,
ra_it,
const reg_expression<char_type>& e,
@@ -167,11 +167,11 @@ template test_string_type regex_format
(const match_results<test_string_type::const_iterator>&,
const test_string_type&,
unsigned flags);
template test_string_type regex_merge(const test_string_type&,
template test_string_type regex_replace(const test_string_type&,
const reg_expression<char_type>&,
const char_type*,
unsigned int flags);
template test_string_type regex_merge(const test_string_type&,
template test_string_type regex_replace(const test_string_type&,
const reg_expression<char_type>&,
const test_string_type&,
unsigned int flags);