aboutsummaryrefslogtreecommitdiff
path: root/xsd
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-05-09 11:50:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-05-09 11:50:57 +0200
commit6bf1e46ccc93777ca9f62746ada0e18c72fcf138 (patch)
tree89af9295e53ed2751f8343e32b55f799ce385c07 /xsd
parent3067cb353cca291d25b4b1fcf6acdb110e560536 (diff)
Port to use regex from libcutl instead of libbackend-elements
Diffstat (limited to 'xsd')
-rw-r--r--xsd/cxx/elements.cxx22
-rw-r--r--xsd/cxx/elements.hxx8
-rw-r--r--xsd/cxx/parser/elements.cxx4
-rw-r--r--xsd/cxx/parser/elements.hxx4
-rw-r--r--xsd/cxx/parser/generator.cxx43
-rw-r--r--xsd/cxx/parser/parser-header.cxx2
-rw-r--r--xsd/cxx/parser/type-processor.cxx22
-rw-r--r--xsd/cxx/tree/elements.cxx14
-rw-r--r--xsd/cxx/tree/elements.hxx8
-rw-r--r--xsd/cxx/tree/generator.cxx41
-rw-r--r--xsd/cxx/tree/name-processor.cxx46
-rw-r--r--xsd/cxx/tree/tree-forward.cxx2
-rw-r--r--xsd/makefile7
-rw-r--r--xsd/type-map/parser.cxx8
-rw-r--r--xsd/type-map/type-map.hxx29
-rw-r--r--xsd/xsd.cxx47
16 files changed, 167 insertions, 140 deletions
diff --git a/xsd/cxx/elements.cxx b/xsd/cxx/elements.cxx
index 1fe2c29..e83f661 100644
--- a/xsd/cxx/elements.cxx
+++ b/xsd/cxx/elements.cxx
@@ -5,8 +5,6 @@
#include <cxx/elements.hxx>
-#include <backend-elements/regex.hxx>
-
#include <cctype> // std::toupper
#include <memory>
#include <sstream>
@@ -218,7 +216,7 @@ namespace CXX
for (Containers::Vector<NarrowString>::ConstIterator
i (nsr.begin ()), e (nsr.end ()); i != e; ++i)
{
- nsr_mapping_.push_back (Regex (*i));
+ nsr_mapping_.push_back (Regex (String (*i)));
}
// Custom direct mapping.
@@ -251,7 +249,7 @@ namespace CXX
for (Containers::Vector<NarrowString>::ConstIterator
i (ir.begin ()), e (ir.end ()); i != e; ++i)
{
- include_mapping_.push_back (Regex (*i));
+ include_mapping_.push_back (Regex (String (*i)));
}
// Reserved names.
@@ -352,12 +350,12 @@ namespace CXX
e != nsr_mapping.rend (); ++e)
{
if (trace_namespace_regex)
- wcerr << "try: '" << e->pattern () << "' : ";
+ wcerr << "try: '" << e->regex () << "' : ";
if (e->match (pair))
{
- tmp = e->merge (pair);
- tmp = colon.merge (tmp); // replace `/' with `::'
+ tmp = e->replace (pair);
+ tmp = colon.replace (tmp); // replace `/' with `::'
// Check the result.
//
@@ -388,7 +386,7 @@ namespace CXX
}
else
{
- tmp = colon.merge (n); // replace `/' with `::'
+ tmp = colon.replace (n); // replace `/' with `::'
if (!cxx_id_expr.match (tmp))
{
@@ -397,8 +395,8 @@ namespace CXX
if (urn_mapping.match (n))
{
Regex filter (L"#[.:-]#_#");
- tmp = urn_mapping.merge (n);
- tmp = filter.merge (tmp);
+ tmp = urn_mapping.replace (n);
+ tmp = filter.replace (tmp);
if (!cxx_id_expr.match (tmp))
throw NoNamespaceMapping (
@@ -1209,11 +1207,11 @@ namespace CXX
e != include_mapping.rend (); ++e)
{
if (trace_include_regex)
- wcerr << "try: '" << e->pattern () << "' : ";
+ wcerr << "try: '" << e->regex () << "' : ";
if (e->match (path))
{
- r = e->merge (path);
+ r = e->replace (path);
found = true;
if (trace_include_regex)
diff --git a/xsd/cxx/elements.hxx b/xsd/cxx/elements.hxx
index f9fa619..15518fc 100644
--- a/xsd/cxx/elements.hxx
+++ b/xsd/cxx/elements.hxx
@@ -8,13 +8,13 @@
#include <ostream>
+#include <cutl/re.hxx>
+
#include <cult/types.hxx>
#include <cult/containers/set.hxx>
#include <cult/containers/map.hxx>
#include <cult/containers/vector.hxx>
-#include <backend-elements/regex.hxx>
-
#include <xsd-frontend/semantic-graph.hxx>
#include <xsd-frontend/traversal.hxx>
@@ -136,8 +136,8 @@ namespace CXX
class Context
{
public:
- typedef BackendElements::Regex::Pattern<WideChar> RegexPat;
- typedef BackendElements::Regex::Expression<WideChar> Regex;
+ typedef cutl::re::wregex RegexPat;
+ typedef cutl::re::wregexsub Regex;
typedef Cult::Containers::Vector<Regex> RegexMapping;
typedef Cult::Containers::Map<String, String> MapMapping;
typedef Cult::Containers::Map<String, String> MappingCache;
diff --git a/xsd/cxx/parser/elements.cxx b/xsd/cxx/parser/elements.cxx
index 585d42c..94baa28 100644
--- a/xsd/cxx/parser/elements.cxx
+++ b/xsd/cxx/parser/elements.cxx
@@ -248,12 +248,12 @@ namespace CXX
case header:
case source:
{
- inc_path = ctx_.hxx_expr->merge (path_str);
+ inc_path = ctx_.hxx_expr->replace (path_str);
break;
}
case impl_header:
{
- inc_path = ctx_.hxx_impl_expr->merge (path_str);
+ inc_path = ctx_.hxx_impl_expr->replace (path_str);
break;
}
}
diff --git a/xsd/cxx/parser/elements.hxx b/xsd/cxx/parser/elements.hxx
index edcd9f2..d8cedd8 100644
--- a/xsd/cxx/parser/elements.hxx
+++ b/xsd/cxx/parser/elements.hxx
@@ -8,7 +8,7 @@
#include <sstream>
-#include <backend-elements/regex.hxx>
+#include <cutl/re.hxx>
#include <cxx/elements.hxx>
@@ -33,7 +33,7 @@ namespace CXX
class Context: public CXX::Context
{
public:
- typedef BackendElements::Regex::Expression<Char> Regex;
+ typedef cutl::re::regexsub Regex;
public:
Context (std::wostream&,
diff --git a/xsd/cxx/parser/generator.cxx b/xsd/cxx/parser/generator.cxx
index 1a121cd..998c480 100644
--- a/xsd/cxx/parser/generator.cxx
+++ b/xsd/cxx/parser/generator.cxx
@@ -7,6 +7,8 @@
#include <boost/filesystem/fstream.hpp>
+#include <cutl/re.hxx>
+
#include <cult/containers/set.hxx>
#include <cult/containers/vector.hxx>
@@ -14,7 +16,6 @@
#include <cutl/compiler/cxx-indenter.hxx>
#include <cutl/compiler/sloc-counter.hxx>
-#include <backend-elements/regex.hxx>
#include <backend-elements/indentation/clip.hxx>
#include <xsd-frontend/semantic-graph.hxx>
@@ -626,7 +627,7 @@ namespace CXX
using std::ios_base;
namespace Indentation = BackendElements::Indentation;
- typedef BackendElements::Regex::Expression<Char> Regex;
+ typedef cutl::re::regexsub Regex;
try
{
@@ -795,7 +796,7 @@ namespace CXX
type_map.push_back (xsd);
- // Everyhting else maps to void.
+ // Everything else maps to void.
//
TypeMap::Namespace rest (".*");
rest.types_push_back (".*", "void", "void");
@@ -861,7 +862,7 @@ namespace CXX
if (!hxx_expr.match (name))
{
wcerr << "error: header expression '" <<
- hxx_expr.pattern () << "' does not match '" <<
+ hxx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -869,7 +870,7 @@ namespace CXX
if (inline_ && !ixx_expr.match (name))
{
wcerr << "error: inline expression '" <<
- ixx_expr.pattern () << "' does not match '" <<
+ ixx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -877,7 +878,7 @@ namespace CXX
if (source && !cxx_expr.match (name))
{
wcerr << "error: source expression '" <<
- cxx_expr.pattern () << "' does not match '" <<
+ cxx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -887,7 +888,7 @@ namespace CXX
if (!hxx_impl_expr.match (name))
{
wcerr << "error: implementation header expression '" <<
- hxx_impl_expr.pattern () << "' does not match '" <<
+ hxx_impl_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -895,7 +896,7 @@ namespace CXX
if (!cxx_impl_expr.match (name))
{
wcerr << "error: implementation source expression '" <<
- cxx_impl_expr.pattern () << "' does not match '" <<
+ cxx_impl_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -903,15 +904,15 @@ namespace CXX
if (!cxx_driver_expr.match (name))
{
wcerr << "error: driver source expression '" <<
- cxx_driver_expr.pattern () << "' does not match '" <<
+ cxx_driver_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
}
- NarrowString hxx_name (hxx_expr.merge (name));
- NarrowString ixx_name (inline_ ? ixx_expr.merge (name) : NarrowString ());
- NarrowString cxx_name (source ? cxx_expr.merge (name) : NarrowString ());
+ NarrowString hxx_name (hxx_expr.replace (name));
+ NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ());
+ NarrowString cxx_name (source ? cxx_expr.replace (name) : NarrowString ());
NarrowString hxx_impl_name;
NarrowString cxx_impl_name;
@@ -919,9 +920,9 @@ namespace CXX
if (impl || driver)
{
- hxx_impl_name = hxx_impl_expr.merge (name);
- cxx_impl_name = cxx_impl_expr.merge (name);
- cxx_driver_name = cxx_driver_expr.merge (name);
+ hxx_impl_name = hxx_impl_expr.replace (name);
+ cxx_impl_name = cxx_impl_expr.replace (name);
+ cxx_driver_name = cxx_driver_expr.replace (name);
}
Path hxx_path (hxx_name, boost::filesystem::native);
@@ -1198,7 +1199,7 @@ namespace CXX
sloc_filter sloc (hxx);
- String guard (guard_expr.merge (guard_prefix + hxx_name));
+ String guard (guard_expr.replace (guard_prefix + hxx_name));
guard = ctx.escape (guard); // Make it a C++ id.
std::transform (guard.begin (), guard.end(), guard.begin (), upcase);
@@ -1406,7 +1407,7 @@ namespace CXX
&ixx_expr,
&hxx_impl_expr);
- String guard (guard_expr.merge (guard_prefix + hxx_impl_name));
+ String guard (guard_expr.replace (guard_prefix + hxx_impl_name));
guard = ctx.escape (guard); // Make it a C++ id.
std::transform (guard.begin (), guard.end(), guard.begin (), upcase);
@@ -1501,18 +1502,18 @@ namespace CXX
throw Failed ();
}
- catch (BackendElements::Regex::Format<Char> const& e)
+ catch (cutl::re::format const& e)
{
wcerr << "error: invalid regex: '" <<
- e.expression ().c_str () << "': " <<
+ e.regex ().c_str () << "': " <<
e.description ().c_str () << endl;
throw Failed ();
}
- catch (BackendElements::Regex::Format<WideChar> const& e)
+ catch (cutl::re::wformat const& e)
{
wcerr << "error: invalid regex: '" <<
- e.expression () << "': " << e.description () << endl;
+ e.regex () << "': " << e.description ().c_str () << endl;
throw Failed ();
}
diff --git a/xsd/cxx/parser/parser-header.cxx b/xsd/cxx/parser/parser-header.cxx
index 1dd01b2..2490a26 100644
--- a/xsd/cxx/parser/parser-header.cxx
+++ b/xsd/cxx/parser/parser-header.cxx
@@ -1298,7 +1298,7 @@ namespace CXX
if (extern_xml_schema)
{
- String name (ctx.hxx_expr->merge (extern_xml_schema));
+ String name (ctx.hxx_expr->replace (extern_xml_schema));
ctx.os << "#include " << ctx.process_include_path (name) << endl
<< endl;
diff --git a/xsd/cxx/parser/type-processor.cxx b/xsd/cxx/parser/type-processor.cxx
index 2207a10..db3e45b 100644
--- a/xsd/cxx/parser/type-processor.cxx
+++ b/xsd/cxx/parser/type-processor.cxx
@@ -73,7 +73,7 @@ namespace CXX
String ns_name (ns.name ());
String t_name (type.name ());
- // std::wcerr << "traversing: " << ns_name << "#" << t_name << endl;
+ //std::wcerr << "traversing: " << ns_name << "#" << t_name << endl;
for (Namespaces::ConstIterator n (type_map_.begin ());
n != type_map_.end (); ++n)
@@ -89,7 +89,9 @@ namespace CXX
else
ns_match = ns_name.empty ();
- // std::wcerr << "considering ns expr: " << n->xsd_name () << endl;
+ //std::wcerr << "considering ns expr: " << n->xsd_name ()
+ // << " for " << ns_name
+ // << ": " << (ns_match ? "+" : "-") << endl;
if (ns_match)
{
@@ -111,8 +113,8 @@ namespace CXX
{
if (!n->xsd_name ().empty ())
{
- cxx_ns = n->xsd_name ().merge (
- n->cxx_name (), ns_name, true);
+ cxx_ns = n->xsd_name ().replace (
+ ns_name, n->cxx_name (), true);
}
else
cxx_ns = n->cxx_name ();
@@ -124,16 +126,16 @@ namespace CXX
//
String ret_type (cxx_ns);
- ret_type += t->xsd_name ().merge (
- t->cxx_ret_name (), t_name, true);
+ ret_type += t->xsd_name ().replace (
+ t_name, t->cxx_ret_name (), true);
String arg_type;
if (t->cxx_arg_name ())
{
arg_type = cxx_ns;
- arg_type += t->xsd_name ().merge (
- t->cxx_arg_name (), t_name, true);
+ arg_type += t->xsd_name ().replace (
+ t_name, t->cxx_arg_name (), true);
}
else
{
@@ -155,12 +157,12 @@ namespace CXX
tc.set ("ret-type", ret_type);
tc.set ("arg-type", arg_type);
+
+ //std::wcerr << t_name << " -> " << ret_type << endl;
}
tc.set ("root-schema", &schema_);
- //std::wcerr << t_name << " -> " << ret_type << endl;
-
// See of we need to add any includes to the translations
// unit.
//
diff --git a/xsd/cxx/tree/elements.cxx b/xsd/cxx/tree/elements.cxx
index 0b69fff..233063a 100644
--- a/xsd/cxx/tree/elements.cxx
+++ b/xsd/cxx/tree/elements.cxx
@@ -291,7 +291,7 @@ namespace CXX
}
regex_custom_type_map.push_back (
- RegexCustomTypeMapInfo (pat, type, base));
+ RegexCustomTypeMapInfo (WideRegexPat (pat), type, base));
}
}
}
@@ -414,7 +414,7 @@ namespace CXX
return true;
}
- r = i->pat.merge (i->type_sub, name);
+ r = i->pat.replace (name, i->type_sub);
return true;
}
}
@@ -467,7 +467,7 @@ namespace CXX
{
if (!i->base_sub.empty ())
{
- r = i->pat.merge (i->base_sub, name);
+ r = i->pat.replace (name, i->base_sub);
}
else
r.clear ();
@@ -1354,25 +1354,25 @@ namespace CXX
{
case forward:
{
- inc_path = ctx_.fwd_expr->merge (path_str);
+ inc_path = ctx_.fwd_expr->replace (path_str);
break;
}
case header:
case source:
{
- inc_path = ctx_.hxx_expr->merge (path_str);
+ inc_path = ctx_.hxx_expr->replace (path_str);
break;
}
case inline_:
{
if (weak)
{
- inc_path = ctx_.hxx_expr->merge (path_str);
+ inc_path = ctx_.hxx_expr->replace (path_str);
ctx_.os << "#include " << ctx_.process_include_path (inc_path)
<< endl;
}
- inc_path = ctx_.ixx_expr->merge (path_str);
+ inc_path = ctx_.ixx_expr->replace (path_str);
break;
}
}
diff --git a/xsd/cxx/tree/elements.hxx b/xsd/cxx/tree/elements.hxx
index 369dc3a..edcb0d2 100644
--- a/xsd/cxx/tree/elements.hxx
+++ b/xsd/cxx/tree/elements.hxx
@@ -8,12 +8,12 @@
#include <sstream>
+#include <cutl/re.hxx>
+
#include <cult/containers/map.hxx>
#include <cult/containers/deque.hxx>
#include <cult/containers/vector.hxx>
-#include <backend-elements/regex.hxx>
-
#include <cxx/elements.hxx>
#include <cxx/tree/cli.hxx>
@@ -74,8 +74,8 @@ namespace CXX
class Context: public CXX::Context
{
public:
- typedef BackendElements::Regex::Expression<Char> Regex;
- typedef BackendElements::Regex::Pattern<WideChar> WideRegexPat;
+ typedef cutl::re::regexsub Regex;
+ typedef cutl::re::wregex WideRegexPat;
struct DirectCustomTypeMapInfo
{
diff --git a/xsd/cxx/tree/generator.cxx b/xsd/cxx/tree/generator.cxx
index d7e77d0..5fe4af5 100644
--- a/xsd/cxx/tree/generator.cxx
+++ b/xsd/cxx/tree/generator.cxx
@@ -7,6 +7,8 @@
#include <boost/filesystem/fstream.hpp>
+#include <cutl/re.hxx>
+
#include <cult/containers/set.hxx>
#include <cult/containers/vector.hxx>
@@ -14,7 +16,6 @@
#include <cutl/compiler/cxx-indenter.hxx>
#include <cutl/compiler/sloc-counter.hxx>
-#include <backend-elements/regex.hxx>
#include <backend-elements/indentation/clip.hxx>
#include <xsd-frontend/semantic-graph.hxx>
@@ -853,7 +854,7 @@ namespace CXX
using std::ios_base;
namespace Indentation = BackendElements::Indentation;
- typedef BackendElements::Regex::Expression<Char> Regex;
+ typedef cutl::re::regexsub Regex;
using Cult::Containers::Vector;
@@ -990,7 +991,7 @@ namespace CXX
if (!hxx_expr.match (name))
{
wcerr << "error: header expression '" <<
- hxx_expr.pattern () << "' does not match '" <<
+ hxx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -998,7 +999,7 @@ namespace CXX
if (inline_ && !ixx_expr.match (name))
{
wcerr << "error: inline expression '" <<
- ixx_expr.pattern () << "' does not match '" <<
+ ixx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -1006,7 +1007,7 @@ namespace CXX
if (source && parts == 1 && !cxx_expr.match (name))
{
wcerr << "error: source expression '" <<
- cxx_expr.pattern () << "' does not match '" <<
+ cxx_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
@@ -1014,14 +1015,14 @@ namespace CXX
if (forward && !fwd_expr.match (name))
{
wcerr << "error: forward expression '" <<
- fwd_expr.pattern () << "' does not match '" <<
+ fwd_expr.regex ().str ().c_str () << "' does not match '" <<
name.c_str () << "'" << endl;
throw Failed ();
}
- NarrowString hxx_name (hxx_expr.merge (name));
- NarrowString ixx_name (inline_ ? ixx_expr.merge (name) : NarrowString ());
- NarrowString fwd_name (forward ? fwd_expr.merge (name) : NarrowString ());
+ NarrowString hxx_name (hxx_expr.replace (name));
+ NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ());
+ NarrowString fwd_name (forward ? fwd_expr.replace (name) : NarrowString ());
Path hxx_path (hxx_name, boost::filesystem::native);
Path ixx_path (ixx_name, boost::filesystem::native);
@@ -1040,23 +1041,23 @@ namespace CXX
Regex expr (
"#^(.+?)(\\.[^./\\\\]+)?$#$1" + parts_suffix + os.str () + "$2#");
- NarrowString part_name (expr.merge (name));
+ NarrowString part_name (expr.replace (name));
if (!cxx_expr.match (part_name))
{
wcerr << "error: source expression '" <<
- cxx_expr.pattern () << "' does not match '" <<
+ cxx_expr.regex ().str ().c_str () << "' does not match '" <<
part_name.c_str () << "'" << endl;
throw Failed ();
}
cxx_paths.push_back (
- Path (cxx_expr.merge (part_name), boost::filesystem::native));
+ Path (cxx_expr.replace (part_name), boost::filesystem::native));
}
}
else
cxx_paths.push_back (
- Path (cxx_expr.merge (name), boost::filesystem::native));
+ Path (cxx_expr.replace (name), boost::filesystem::native));
}
Path out_dir;
@@ -1272,7 +1273,7 @@ namespace CXX
// Guard
//
- String guard (guard_expr.merge (guard_prefix + fwd_name));
+ String guard (guard_expr.replace (guard_prefix + fwd_name));
guard = ctx.escape (guard); // make a c++ id
std::transform (guard.begin (), guard.end(), guard.begin (), upcase);
@@ -1381,7 +1382,7 @@ namespace CXX
// Guard
//
- String guard (guard_expr.merge (guard_prefix + hxx_name));
+ String guard (guard_expr.replace (guard_prefix + hxx_name));
guard = ctx.escape (guard); // make a c++ id
std::transform (guard.begin (), guard.end(), guard.begin (), upcase);
@@ -1529,7 +1530,7 @@ namespace CXX
// Guard
//
- String guard (guard_expr.merge (guard_prefix + ixx_name));
+ String guard (guard_expr.replace (guard_prefix + ixx_name));
guard = ctx.escape (guard); // make a c++ id
std::transform (guard.begin (), guard.end(), guard.begin (), upcase);
@@ -1765,18 +1766,18 @@ namespace CXX
throw Failed ();
}
- catch (BackendElements::Regex::Format<Char> const& e)
+ catch (cutl::re::format const& e)
{
wcerr << "error: invalid regex: '" <<
- e.expression ().c_str () << "': " <<
+ e.regex ().c_str () << "': " <<
e.description ().c_str () << endl;
throw Failed ();
}
- catch (BackendElements::Regex::Format<WideChar> const& e)
+ catch (cutl::re::wformat const& e)
{
wcerr << "error: invalid regex: '" <<
- e.expression () << "': " << e.description () << endl;
+ e.regex () << "': " << e.description ().c_str () << endl;
throw Failed ();
}
diff --git a/xsd/cxx/tree/name-processor.cxx b/xsd/cxx/tree/name-processor.cxx
index b731b82..ad1720f 100644
--- a/xsd/cxx/tree/name-processor.cxx
+++ b/xsd/cxx/tree/name-processor.cxx
@@ -6,12 +6,12 @@
#include <sstream>
#include <iostream>
+#include <cutl/re.hxx>
+
#include <cult/containers/set.hxx>
#include <cult/containers/map.hxx>
#include <cult/containers/vector.hxx>
-#include <backend-elements/regex.hxx>
-
#include <cxx/tree/default-value.hxx>
#include <cxx/tree/name-processor.hxx>
@@ -288,9 +288,17 @@ namespace CXX
}
public:
- typedef BackendElements::Regex::Expression<WideChar> Regex;
- typedef BackendElements::Regex::Format<WideChar> RegexFormat;
- typedef Cult::Containers::Vector<Regex> RegexVector;
+ typedef cutl::re::wregexsub Regex;
+ typedef cutl::re::wformat RegexFormat;
+
+ struct RegexVector: Cult::Containers::Vector<Regex>
+ {
+ void
+ push_back (String const& r)
+ {
+ Cult::Containers::Vector<Regex>::push_back (Regex (r));
+ }
+ };
String
process_regex (String const& name,
@@ -306,11 +314,11 @@ namespace CXX
i != rv.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (name))
{
- String r (i->merge (name));
+ String r (i->replace (name));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -340,11 +348,11 @@ namespace CXX
i != primary.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (name))
{
- String r (i->merge (name));
+ String r (i->replace (name));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -360,11 +368,11 @@ namespace CXX
i != backup.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (name))
{
- String r (i->merge (name));
+ String r (i->replace (name));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -395,11 +403,11 @@ namespace CXX
i != rv.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (s))
{
- String r (i->merge (s));
+ String r (i->replace (s));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -431,11 +439,11 @@ namespace CXX
i != primary.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (s))
{
- String r (i->merge (s));
+ String r (i->replace (s));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -451,11 +459,11 @@ namespace CXX
i != backup.rend (); ++i)
{
if (trace)
- os << "try: '" << i->pattern () << "' : ";
+ os << "try: '" << i->regex () << "' : ";
if (i->match (s))
{
- String r (i->merge (s));
+ String r (i->replace (s));
if (trace)
os << "'" << r << "' : +" << endl;
@@ -503,12 +511,12 @@ namespace CXX
{
try
{
- rv.push_back (Regex (*i));
+ rv.push_back (*i);
}
catch (RegexFormat const& e)
{
os << "error: invalid " << id << " name regex: '" <<
- e.expression () << "': " << e.description () << endl;
+ e.regex () << "': " << e.description ().c_str () << endl;
throw Failed ();
}
diff --git a/xsd/cxx/tree/tree-forward.cxx b/xsd/cxx/tree/tree-forward.cxx
index 2c6ad1b..7ec6155 100644
--- a/xsd/cxx/tree/tree-forward.cxx
+++ b/xsd/cxx/tree/tree-forward.cxx
@@ -145,7 +145,7 @@ namespace CXX
//
if (xml_schema)
{
- String name (ctx.hxx_expr->merge (xml_schema));
+ String name (ctx.hxx_expr->replace (xml_schema));
ctx.os << "#include " << ctx.process_include_path (name) << endl
<< endl;
diff --git a/xsd/makefile b/xsd/makefile
index 8ecf5ca..e2d00ea 100644
--- a/xsd/makefile
+++ b/xsd/makefile
@@ -84,10 +84,6 @@ $(call import,\
l: be.l,cpp-options: be.l.cpp-options)
$(call import,\
- $(scf_root)/import/libboost/regex/stub.make,\
- l: re.l,cpp-options: re.l.cpp-options)
-
-$(call import,\
$(scf_root)/import/libboost/filesystem/stub.make,\
l: fs.l,cpp-options: fs.l.cpp-options)
@@ -101,7 +97,7 @@ $(call import,\
# Build.
#
-$(xsd): $(cxx_obj) $(xsd_fe.l) $(be.l) $(cult.l) $(cutl.l) $(fs.l) $(re.l) $(xerces_c.l)
+$(xsd): $(cxx_obj) $(xsd_fe.l) $(be.l) $(cult.l) $(cutl.l) $(fs.l) $(xerces_c.l)
$(cxx_obj) $(cxx_od): cpp_options := -I$(src_base)
$(cxx_obj) $(cxx_od): \
@@ -110,7 +106,6 @@ $(cxx_obj) $(cxx_od): \
$(cult.l.cpp-options) \
$(cutl.l.cpp-options) \
$(fs.l.cpp-options) \
- $(re.l.cpp-options) \
$(xerces_c.l.cpp-options)
$(call include-dep,$(cxx_od))
diff --git a/xsd/type-map/parser.cxx b/xsd/type-map/parser.cxx
index 823f3cd..5bc2ffc 100644
--- a/xsd/type-map/parser.cxx
+++ b/xsd/type-map/parser.cxx
@@ -5,7 +5,7 @@
#include <iostream>
-#include <backend-elements/regex.hxx>
+#include <cutl/re.hxx>
#include <type-map/parser.hxx>
@@ -14,7 +14,7 @@ using std::endl;
namespace TypeMap
{
typedef Lexer::Token Token;
- typedef BackendElements::Regex::Format<WideChar> Format;
+ typedef cutl::re::wformat Format;
Parser::Parser (Lexer& lex, String const& path)
: lex_ (lex), path_ (path), e (std::wcerr)
@@ -99,7 +99,7 @@ namespace TypeMap
catch (Format const& ex)
{
e << path_ << ":" << t.line () << ": invalid namespace pattern: "
- << ex.description () << endl;
+ << ex.description ().c_str () << endl;
return false;
}
@@ -234,7 +234,7 @@ namespace TypeMap
catch (Format const& ex)
{
e << path_ << ":" << t.line () << ": invalid namespace pattern: "
- << ex.description () << endl;
+ << ex.description ().c_str () << endl;
return false;
}
diff --git a/xsd/type-map/type-map.hxx b/xsd/type-map/type-map.hxx
index ab8231c..e5715dd 100644
--- a/xsd/type-map/type-map.hxx
+++ b/xsd/type-map/type-map.hxx
@@ -6,20 +6,29 @@
#ifndef XSD_TYPE_MAP_TYPE_MAP_HXX
#define XSD_TYPE_MAP_TYPE_MAP_HXX
+#include <cutl/re.hxx>
+
#include <cult/types.hxx>
#include <cult/containers/vector.hxx>
-#include <backend-elements/regex.hxx>
-
namespace TypeMap
{
using namespace Cult::Types;
typedef WideString String;
- typedef BackendElements::Regex::Pattern<WideChar> Pattern;
+ typedef cutl::re::wregex Pattern;
class Type
{
public:
+ Type (String const& xsd_name,
+ String const& cxx_ret_name,
+ String const& cxx_arg_name)
+ : xsd_name_ (xsd_name),
+ cxx_ret_name_ (cxx_ret_name),
+ cxx_arg_name_ (cxx_arg_name)
+ {
+ }
+
Type (Pattern const& xsd_name,
String const& cxx_ret_name,
String const& cxx_arg_name)
@@ -56,6 +65,11 @@ namespace TypeMap
class Namespace
{
public:
+ Namespace (String const& xsd_name)
+ : xsd_name_ (xsd_name), has_cxx_name_ (false)
+ {
+ }
+
Namespace (Pattern const& xsd_name)
: xsd_name_ (xsd_name), has_cxx_name_ (false)
{
@@ -116,6 +130,14 @@ namespace TypeMap
}
Void
+ types_push_back (String const& xsd_type,
+ String const& cxx_ret_type,
+ String const& cxx_arg_type = L"")
+ {
+ types_.push_back (Type (xsd_type, cxx_ret_type, cxx_arg_type));
+ }
+
+ Void
types_push_back (Pattern const& xsd_type,
String const& cxx_ret_type,
String const& cxx_arg_type = L"")
@@ -157,4 +179,3 @@ namespace TypeMap
}
#endif // XSD_TYPE_MAP_TYPE_MAP_HXX
-
diff --git a/xsd/xsd.cxx b/xsd/xsd.cxx
index 3199e82..ef5c2f0 100644
--- a/xsd/xsd.cxx
+++ b/xsd/xsd.cxx
@@ -3,6 +3,8 @@
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <cutl/re.hxx>
+
#include <cult/types.hxx>
#include <cult/trace/log.hxx>
@@ -23,7 +25,6 @@
#include <xsd-frontend/transformations/schema-per-type.hxx>
#include <xsd-frontend/transformations/simplifier.hxx>
-#include <backend-elements/regex.hxx>
#include <backend-elements/indentation/clip.hxx>
#include <cxx/tree/generator.hxx>
@@ -144,8 +145,8 @@ struct LocationTranslator: XSDFrontend::LocationTranslator
private:
typedef Cult::Containers::Map<NarrowString, NarrowString> Map;
- typedef BackendElements::Regex::Expression<Char> Regex;
- typedef BackendElements::Regex::Format<Char> RegexFormat;
+ typedef cutl::re::regexsub Regex;
+ typedef cutl::re::format RegexFormat;
typedef Cult::Containers::Vector<Regex> RegexVector;
typedef Cult::Containers::Map<NarrowString, NarrowString> Cache;
@@ -171,8 +172,8 @@ struct AnonymousNameTranslator: Transformations::AnonymousNameTranslator
WideString const& xpath);
private:
- typedef BackendElements::Regex::Expression<WideChar> Regex;
- typedef BackendElements::Regex::Format<WideChar> RegexFormat;
+ typedef cutl::re::wregexsub Regex;
+ typedef cutl::re::wformat RegexFormat;
typedef Cult::Containers::Vector<Regex> RegexVector;
RegexVector regex_;
@@ -198,15 +199,15 @@ struct SchemaPerTypeTranslator: Transformations::SchemaPerTypeTranslator
translate_schema (NarrowString const& file);
private:
- typedef BackendElements::Regex::Expression<WideChar> TypeRegex;
- typedef BackendElements::Regex::Format<WideChar> TypeRegexFormat;
+ typedef cutl::re::wregexsub TypeRegex;
+ typedef cutl::re::wformat TypeRegexFormat;
typedef Cult::Containers::Vector<TypeRegex> TypeRegexVector;
TypeRegexVector type_regex_;
Boolean type_trace_;
- typedef BackendElements::Regex::Expression<Char> SchemaRegex;
- typedef BackendElements::Regex::Format<Char> SchemaRegexFormat;
+ typedef cutl::re::regexsub SchemaRegex;
+ typedef cutl::re::format SchemaRegexFormat;
typedef Cult::Containers::Vector<SchemaRegex> SchemaRegexVector;
SchemaRegexVector schema_regex_;
@@ -1151,7 +1152,7 @@ LocationTranslator (NarrowStrings const& map,
catch (RegexFormat const& e)
{
wcerr << "error: invalid location regex: '" <<
- e.expression ().c_str () << "': " <<
+ e.regex ().c_str () << "': " <<
e.description ().c_str () << endl;
throw Failed ();
@@ -1188,11 +1189,11 @@ translate (NarrowString const& l)
i != regex_.rend (); ++i)
{
if (trace_)
- wcerr << "try: '" << i->pattern () << "' : ";
+ wcerr << "try: '" << i->regex ().str ().c_str () << "' : ";
if (i->match (l))
{
- NarrowString r (i->merge (l));
+ NarrowString r (i->replace (l));
if (trace_)
wcerr << "'" << r.c_str () << "' : +" << endl;
@@ -1222,12 +1223,12 @@ AnonymousNameTranslator (NarrowStrings const& regex, Boolean trace)
{
try
{
- regex_.push_back (Regex (*i));
+ regex_.push_back (Regex (WideString (*i)));
}
catch (RegexFormat const& e)
{
wcerr << "error: invalid anonymous type regex: '" <<
- e.expression () << "': " << e.description () << endl;
+ e.regex () << "': " << e.description () << endl;
throw Failed ();
}
@@ -1249,11 +1250,11 @@ translate (WideString const& file,
i != regex_.rend (); ++i)
{
if (trace_)
- wcerr << "try: '" << i->pattern () << "' : ";
+ wcerr << "try: '" << i->regex () << "' : ";
if (i->match (s))
{
- WideString r (i->merge (s));
+ WideString r (i->replace (s));
if (trace_)
wcerr << "'" << r << "' : +" << endl;
@@ -1285,12 +1286,12 @@ SchemaPerTypeTranslator (NarrowStrings const& type_regex,
{
try
{
- type_regex_.push_back (TypeRegex (*i));
+ type_regex_.push_back (TypeRegex (WideString (*i)));
}
catch (TypeRegexFormat const& e)
{
wcerr << "error: invalid type file regex: '" <<
- e.expression () << "': " << e.description () << endl;
+ e.regex () << "': " << e.description () << endl;
throw Failed ();
}
@@ -1306,7 +1307,7 @@ SchemaPerTypeTranslator (NarrowStrings const& type_regex,
catch (SchemaRegexFormat const& e)
{
wcerr << "error: invalid type file regex: '" <<
- e.expression ().c_str () << "': " << e.description ().c_str () << endl;
+ e.regex ().c_str () << "': " << e.description ().c_str () << endl;
throw Failed ();
}
@@ -1325,11 +1326,11 @@ translate_type (WideString const& ns, WideString const& name)
i != type_regex_.rend (); ++i)
{
if (type_trace_)
- wcerr << "try: '" << i->pattern () << "' : ";
+ wcerr << "try: '" << i->regex () << "' : ";
if (i->match (s))
{
- WideString r (i->merge (s));
+ WideString r (i->replace (s));
if (type_trace_)
wcerr << "'" << r << "' : +" << endl;
@@ -1356,11 +1357,11 @@ translate_schema (NarrowString const& file)
i != schema_regex_.rend (); ++i)
{
if (schema_trace_)
- wcerr << "try: '" << i->pattern () << "' : ";
+ wcerr << "try: '" << i->regex ().str ().c_str () << "' : ";
if (i->match (file))
{
- NarrowString r (i->merge (file));
+ NarrowString r (i->replace (file));
if (schema_trace_)
wcerr << "'" << r.c_str () << "' : +" << endl;