aboutsummaryrefslogtreecommitdiff
path: root/xsde
diff options
context:
space:
mode:
Diffstat (limited to 'xsde')
-rw-r--r--xsde/cxx/hybrid/elements.cxx8
-rw-r--r--xsde/cxx/hybrid/generator.cxx88
-rw-r--r--xsde/cxx/hybrid/generator.hxx3
-rw-r--r--xsde/cxx/parser/elements.cxx8
-rw-r--r--xsde/cxx/parser/generator.cxx45
-rw-r--r--xsde/cxx/parser/generator.hxx1
-rw-r--r--xsde/cxx/serializer/elements.cxx8
-rw-r--r--xsde/cxx/serializer/generator.cxx45
-rw-r--r--xsde/cxx/serializer/generator.hxx1
-rw-r--r--xsde/xsde.cxx226
10 files changed, 315 insertions, 118 deletions
diff --git a/xsde/cxx/hybrid/elements.cxx b/xsde/cxx/hybrid/elements.cxx
index e3bd02b..3607c37 100644
--- a/xsde/cxx/hybrid/elements.cxx
+++ b/xsde/cxx/hybrid/elements.cxx
@@ -580,6 +580,7 @@ namespace CXX
// compilation model.
//
Type t (type_);
+ SemanticGraph::Schema& s (u.schema ());
Boolean weak (u.context ().count ("weak"));
if (weak && (t == header || t == impl_header))
@@ -594,7 +595,7 @@ namespace CXX
t = forward;
else
{
- schema_.dispatch (u.schema ());
+ schema_.dispatch (s);
return;
}
}
@@ -602,7 +603,10 @@ namespace CXX
if (t == source && !weak)
return;
- SemanticGraph::Path path (u.path ());
+ SemanticGraph::Path path (
+ s.context ().count ("renamed")
+ ? s.context ().get<SemanticGraph::Path> ("renamed")
+ : u.path ());
// Try to use the portable representation of the path. If that
// fails, fall back to the native representation.
diff --git a/xsde/cxx/hybrid/generator.cxx b/xsde/cxx/hybrid/generator.cxx
index c39b062..34cfa2d 100644
--- a/xsde/cxx/hybrid/generator.cxx
+++ b/xsde/cxx/hybrid/generator.cxx
@@ -1140,6 +1140,7 @@ namespace CXX
generate_tree (Hybrid::CLI::Options const& ops,
Schema& schema,
Path const& file_path,
+ Boolean fpt,
const WarningSet& disabled_warnings,
TypeMap::Namespaces& parser_type_map,
TypeMap::Namespaces& serializer_type_map,
@@ -1267,16 +1268,13 @@ namespace CXX
Path cxx_path (cxx_name, boost::filesystem::native);
Path fwd_path (fwd_name, boost::filesystem::native);
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ Path out_dir;
+
+ if (NarrowString dir = ops.value<CLI::output_dir> ())
{
try
{
- Path path (dir, boost::filesystem::native);
-
- hxx_path = path / hxx_path;
- ixx_path = path / ixx_path;
- cxx_path = path / cxx_path;
- fwd_path = path / fwd_path;
+ out_dir = Path (dir, boost::filesystem::native);
}
catch (InvalidPath const&)
{
@@ -1285,6 +1283,26 @@ namespace CXX
}
}
+ if (fpt && !generate_xml_schema)
+ {
+ // In the file-per-type mode the schema files are always local
+ // unless the user added the directory so that we propagate this
+ // to the output files.
+ //
+ Path fpt_dir (file_path.branch_path ());
+
+ if (!fpt_dir.empty ())
+ out_dir /= fpt_dir;
+ }
+
+ if (!out_dir.empty ())
+ {
+ hxx_path = out_dir / hxx_path;
+ ixx_path = out_dir / ixx_path;
+ cxx_path = out_dir / cxx_path;
+ fwd_path = out_dir / fwd_path;
+ }
+
// Open the tree files.
//
WideOutputFileStream hxx (hxx_path, ios_base::out);
@@ -1892,6 +1910,7 @@ namespace CXX
generate_parser (Hybrid::CLI::Options const& ops,
Schema& schema,
Path const& file_path,
+ Boolean fpt,
const WarningSet&,
FileList& file_list,
AutoUnlinks& unlinks)
@@ -1998,14 +2017,13 @@ namespace CXX
Path hxx_path (hxx_name, boost::filesystem::native);
Path cxx_path (cxx_name, boost::filesystem::native);
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ Path out_dir;
+
+ if (NarrowString dir = ops.value<CLI::output_dir> ())
{
try
{
- Path path (dir, boost::filesystem::native);
-
- hxx_path = path / hxx_path;
- cxx_path = path / cxx_path;
+ out_dir = Path (dir, boost::filesystem::native);
}
catch (InvalidPath const&)
{
@@ -2014,6 +2032,24 @@ namespace CXX
}
}
+ if (fpt)
+ {
+ // In the file-per-type mode the schema files are always local
+ // unless the user added the directory so that we propagate this
+ // to the output files.
+ //
+ Path fpt_dir (file_path.branch_path ());
+
+ if (!fpt_dir.empty ())
+ out_dir /= fpt_dir;
+ }
+
+ if (!out_dir.empty ())
+ {
+ hxx_path = out_dir / hxx_path;
+ cxx_path = out_dir / cxx_path;
+ }
+
WideOutputFileStream hxx (hxx_path, ios_base::out);
WideOutputFileStream cxx (cxx_path, ios_base::out);
@@ -2296,6 +2332,7 @@ namespace CXX
generate_serializer (Hybrid::CLI::Options const& ops,
Schema& schema,
Path const& file_path,
+ Boolean fpt,
const WarningSet&,
FileList& file_list,
AutoUnlinks& unlinks)
@@ -2390,14 +2427,13 @@ namespace CXX
Path hxx_path (hxx_name, boost::filesystem::native);
Path cxx_path (cxx_name, boost::filesystem::native);
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ Path out_dir;
+
+ if (NarrowString dir = ops.value<CLI::output_dir> ())
{
try
{
- Path path (dir, boost::filesystem::native);
-
- hxx_path = path / hxx_path;
- cxx_path = path / cxx_path;
+ out_dir = Path (dir, boost::filesystem::native);
}
catch (InvalidPath const&)
{
@@ -2406,6 +2442,24 @@ namespace CXX
}
}
+ if (fpt)
+ {
+ // In the file-per-type mode the schema files are always local
+ // unless the user added the directory so that we propagate this
+ // to the output files.
+ //
+ Path fpt_dir (file_path.branch_path ());
+
+ if (!fpt_dir.empty ())
+ out_dir /= fpt_dir;
+ }
+
+ if (!out_dir.empty ())
+ {
+ hxx_path = out_dir / hxx_path;
+ cxx_path = out_dir / cxx_path;
+ }
+
WideOutputFileStream hxx (hxx_path, ios_base::out);
WideOutputFileStream cxx (cxx_path, ios_base::out);
diff --git a/xsde/cxx/hybrid/generator.hxx b/xsde/cxx/hybrid/generator.hxx
index 5d1afa0..e812801 100644
--- a/xsde/cxx/hybrid/generator.hxx
+++ b/xsde/cxx/hybrid/generator.hxx
@@ -82,6 +82,7 @@ namespace CXX
CLI::Options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const&,
+ Boolean file_per_type,
WarningSet const& disabled_warnings,
TypeMap::Namespaces& parser_type_map,
TypeMap::Namespaces& serializer_type_map,
@@ -93,6 +94,7 @@ namespace CXX
CLI::Options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const&,
+ Boolean file_per_type,
WarningSet const& disabled_warnings,
FileList&,
AutoUnlinks&);
@@ -102,6 +104,7 @@ namespace CXX
CLI::Options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const&,
+ Boolean file_per_type,
WarningSet const& disabled_warnings,
FileList&,
AutoUnlinks&);
diff --git a/xsde/cxx/parser/elements.cxx b/xsde/cxx/parser/elements.cxx
index 2261abd..fafcd52 100644
--- a/xsde/cxx/parser/elements.cxx
+++ b/xsde/cxx/parser/elements.cxx
@@ -206,6 +206,7 @@ namespace CXX
// Support for weak (forward) inclusion used in the file-per-type
// compilation model.
//
+ SemanticGraph::Schema& s (u.schema ());
Boolean weak (u.context ().count ("weak"));
if (weak && (type_ == header || type_ == impl_header))
@@ -214,7 +215,7 @@ namespace CXX
// in the impl files.
//
if (type_ == header)
- schema_.dispatch (u.schema ());
+ schema_.dispatch (s);
return;
}
@@ -222,7 +223,10 @@ namespace CXX
if (type_ == source && !weak)
return;
- SemanticGraph::Path path (u.path ());
+ SemanticGraph::Path path (
+ s.context ().count ("renamed")
+ ? s.context ().get<SemanticGraph::Path> ("renamed")
+ : u.path ());
// Try to use the portable representation of the path. If that
// fails, fall back to the native representation.
diff --git a/xsde/cxx/parser/generator.cxx b/xsde/cxx/parser/generator.cxx
index 1645525..c8a9f68 100644
--- a/xsde/cxx/parser/generator.cxx
+++ b/xsde/cxx/parser/generator.cxx
@@ -613,6 +613,7 @@ namespace CXX
generate (Parser::CLI::Options const& ops,
Schema& schema,
Path const& file_path,
+ Boolean fpt,
TypeMap::Namespaces& type_map,
Boolean gen_driver,
const WarningSet& disabled_warnings,
@@ -949,23 +950,13 @@ namespace CXX
cxx_driver_path = Path (cxx_driver_name, boost::filesystem::native);
}
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ Path out_dir;
+
+ if (NarrowString dir = ops.value<CLI::output_dir> ())
{
try
{
- Path path (dir, boost::filesystem::native);
-
- hxx_path = path / hxx_path;
- ixx_path = path / ixx_path;
- cxx_path = path / cxx_path;
-
- if (impl || driver)
- {
- hxx_impl_path = path / hxx_impl_path;
- cxx_impl_path = path / cxx_impl_path;
- cxx_driver_path = path /cxx_driver_path;
- }
-
+ out_dir = Path (dir, boost::filesystem::native);
}
catch (InvalidPath const&)
{
@@ -974,6 +965,32 @@ namespace CXX
}
}
+ if (fpt && !generate_xml_schema)
+ {
+ // In the file-per-type mode the schema files are always local
+ // unless the user added the directory so that we propagate this
+ // to the output files.
+ //
+ Path fpt_dir (file_path.branch_path ());
+
+ if (!fpt_dir.empty ())
+ out_dir /= fpt_dir;
+ }
+
+ if (!out_dir.empty ())
+ {
+ hxx_path = out_dir / hxx_path;
+ ixx_path = out_dir / ixx_path;
+ cxx_path = out_dir / cxx_path;
+
+ if (impl || driver)
+ {
+ hxx_impl_path = out_dir / hxx_impl_path;
+ cxx_impl_path = out_dir / cxx_impl_path;
+ cxx_driver_path = out_dir /cxx_driver_path;
+ }
+ }
+
// Open the impl files first so that if open fails, the skel files
// are not deleted.
//
diff --git a/xsde/cxx/parser/generator.hxx b/xsde/cxx/parser/generator.hxx
index 10b3dd3..9c8f680 100644
--- a/xsde/cxx/parser/generator.hxx
+++ b/xsde/cxx/parser/generator.hxx
@@ -50,6 +50,7 @@ namespace CXX
generate (CLI::Options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const&,
+ Boolean file_per_type,
TypeMap::Namespaces& type_map,
Boolean gen_driver,
const WarningSet& disabled_warnings,
diff --git a/xsde/cxx/serializer/elements.cxx b/xsde/cxx/serializer/elements.cxx
index 0192faf..ba59a82 100644
--- a/xsde/cxx/serializer/elements.cxx
+++ b/xsde/cxx/serializer/elements.cxx
@@ -226,6 +226,7 @@ namespace CXX
// Support for weak (forward) inclusion used in the file-per-type
// compilation model.
//
+ SemanticGraph::Schema& s (u.schema ());
Boolean weak (u.context ().count ("weak"));
if (weak && (type_ == header || type_ == impl_header))
@@ -234,7 +235,7 @@ namespace CXX
// in the impl files.
//
if (type_ == header)
- schema_.dispatch (u.schema ());
+ schema_.dispatch (s);
return;
}
@@ -242,7 +243,10 @@ namespace CXX
if (type_ == source && !weak)
return;
- SemanticGraph::Path path (u.path ());
+ SemanticGraph::Path path (
+ s.context ().count ("renamed")
+ ? s.context ().get<SemanticGraph::Path> ("renamed")
+ : u.path ());
// Try to use the portable representation of the path. If that
// fails, fall back to the native representation.
diff --git a/xsde/cxx/serializer/generator.cxx b/xsde/cxx/serializer/generator.cxx
index 9d519b9..92e5197 100644
--- a/xsde/cxx/serializer/generator.cxx
+++ b/xsde/cxx/serializer/generator.cxx
@@ -606,6 +606,7 @@ namespace CXX
generate (Serializer::CLI::Options const& ops,
Schema& schema,
Path const& file_path,
+ Boolean fpt,
TypeMap::Namespaces& type_map,
Boolean gen_driver,
const WarningSet& disabled_warnings,
@@ -935,23 +936,13 @@ namespace CXX
cxx_driver_path = Path (cxx_driver_name, boost::filesystem::native);
}
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ Path out_dir;
+
+ if (NarrowString dir = ops.value<CLI::output_dir> ())
{
try
{
- Path path (dir, boost::filesystem::native);
-
- hxx_path = path / hxx_path;
- ixx_path = path / ixx_path;
- cxx_path = path / cxx_path;
-
- if (impl || driver)
- {
- hxx_impl_path = path / hxx_impl_path;
- cxx_impl_path = path / cxx_impl_path;
- cxx_driver_path = path /cxx_driver_path;
- }
-
+ out_dir = Path (dir, boost::filesystem::native);
}
catch (InvalidPath const&)
{
@@ -960,6 +951,32 @@ namespace CXX
}
}
+ if (fpt && !generate_xml_schema)
+ {
+ // In the file-per-type mode the schema files are always local
+ // unless the user added the directory so that we propagate this
+ // to the output files.
+ //
+ Path fpt_dir (file_path.branch_path ());
+
+ if (!fpt_dir.empty ())
+ out_dir /= fpt_dir;
+ }
+
+ if (!out_dir.empty ())
+ {
+ hxx_path = out_dir / hxx_path;
+ ixx_path = out_dir / ixx_path;
+ cxx_path = out_dir / cxx_path;
+
+ if (impl || driver)
+ {
+ hxx_impl_path = out_dir / hxx_impl_path;
+ cxx_impl_path = out_dir / cxx_impl_path;
+ cxx_driver_path = out_dir /cxx_driver_path;
+ }
+ }
+
// Open the impl files first so that if open fails, the skel files
// are not deleted.
//
diff --git a/xsde/cxx/serializer/generator.hxx b/xsde/cxx/serializer/generator.hxx
index dd3c0c5..8c2465c 100644
--- a/xsde/cxx/serializer/generator.hxx
+++ b/xsde/cxx/serializer/generator.hxx
@@ -50,6 +50,7 @@ namespace CXX
generate (CLI::Options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const&,
+ Boolean file_per_type,
TypeMap::Namespaces& type_map,
Boolean gen_driver,
const WarningSet& disabled_warnings,
diff --git a/xsde/xsde.cxx b/xsde/xsde.cxx
index fc56a45..e413719 100644
--- a/xsde/xsde.cxx
+++ b/xsde/xsde.cxx
@@ -71,43 +71,47 @@ namespace CLI
struct HelpOptionsSpec: Cult::CLI::OptionsSpec<HelpOptions> {};
- extern Key disable_warning = "disable-warning";
- extern Key sloc_limit = "sloc-limit";
- extern Key preserve_anonymous = "preserve-anonymous";
- extern Key anonymous_regex = "anonymous-regex";
- extern Key anonymous_regex_trace = "anonymous-regex-trace";
- extern Key location_map = "location-map";
- extern Key location_regex = "location-regex";
- extern Key location_regex_trace = "location-regex-trace";
- extern Key file_per_type = "file-per-type";
- extern Key type_file_regex = "type-file-regex";
- extern Key type_file_regex_trace = "type-file-regex-trace";
- extern Key file_list = "file-list";
- extern Key file_list_prologue = "file-list-prologue";
- extern Key file_list_epilogue = "file-list-epilogue";
- extern Key file_list_delim = "file-list-delim";
- extern Key disable_multi_import = "disable-multi-import"; // Undocumented.
- extern Key disable_full_check = "disable-full-check"; // Undocumented.
+ extern Key disable_warning = "disable-warning";
+ extern Key sloc_limit = "sloc-limit";
+ extern Key preserve_anonymous = "preserve-anonymous";
+ extern Key anonymous_regex = "anonymous-regex";
+ extern Key anonymous_regex_trace = "anonymous-regex-trace";
+ extern Key location_map = "location-map";
+ extern Key location_regex = "location-regex";
+ extern Key location_regex_trace = "location-regex-trace";
+ extern Key file_per_type = "file-per-type";
+ extern Key type_file_regex = "type-file-regex";
+ extern Key type_file_regex_trace = "type-file-regex-trace";
+ extern Key schema_file_regex = "schema-file-regex";
+ extern Key schema_file_regex_trace = "schema-file-regex-trace";
+ extern Key file_list = "file-list";
+ extern Key file_list_prologue = "file-list-prologue";
+ extern Key file_list_epilogue = "file-list-epilogue";
+ extern Key file_list_delim = "file-list-delim";
+ extern Key disable_multi_import = "disable-multi-import"; // Undocumented.
+ extern Key disable_full_check = "disable-full-check"; // Undocumented.
typedef Cult::CLI::Options
<
- disable_warning, Cult::Containers::Vector<NarrowString>,
- sloc_limit, UnsignedLong,
- preserve_anonymous, Boolean,
- anonymous_regex, NarrowStrings,
- anonymous_regex_trace, Boolean,
- location_map, NarrowStrings,
- location_regex, NarrowStrings,
- location_regex_trace, Boolean,
- file_per_type, Boolean,
- type_file_regex, NarrowStrings,
- type_file_regex_trace, Boolean,
- file_list, NarrowString,
- file_list_prologue, NarrowString,
- file_list_epilogue, NarrowString,
- file_list_delim, NarrowString,
- disable_multi_import, Boolean,
- disable_full_check, Boolean
+ disable_warning, Cult::Containers::Vector<NarrowString>,
+ sloc_limit, UnsignedLong,
+ preserve_anonymous, Boolean,
+ anonymous_regex, NarrowStrings,
+ anonymous_regex_trace, Boolean,
+ location_map, NarrowStrings,
+ location_regex, NarrowStrings,
+ location_regex_trace, Boolean,
+ file_per_type, Boolean,
+ type_file_regex, NarrowStrings,
+ type_file_regex_trace, Boolean,
+ schema_file_regex, NarrowStrings,
+ schema_file_regex_trace, Boolean,
+ file_list, NarrowString,
+ file_list_prologue, NarrowString,
+ file_list_epilogue, NarrowString,
+ file_list_delim, NarrowString,
+ disable_multi_import, Boolean,
+ disable_full_check, Boolean
>
CommonOptions;
@@ -168,22 +172,35 @@ private:
//
//
-struct TypeSchemaTranslator: Transformations::TypeSchemaTranslator
+struct SchemaPerTypeTranslator: Transformations::SchemaPerTypeTranslator
{
struct Failed {};
- TypeSchemaTranslator (NarrowStrings const& regex, Boolean trace);
+ SchemaPerTypeTranslator (NarrowStrings const& type_regex,
+ Boolean type_trace,
+ NarrowStrings const& schema_regex,
+ Boolean schema_trace);
virtual WideString
- translate (WideString const& ns, WideString const& name);
+ translate_type (WideString const& ns, WideString const& name);
+
+ virtual NarrowString
+ translate_schema (NarrowString const& file);
private:
- typedef BackendElements::Regex::Expression<WideChar> Regex;
- typedef BackendElements::Regex::Format<WideChar> RegexFormat;
- typedef Cult::Containers::Vector<Regex> RegexVector;
+ typedef BackendElements::Regex::Expression<WideChar> TypeRegex;
+ typedef BackendElements::Regex::Format<WideChar> TypeRegexFormat;
+ typedef Cult::Containers::Vector<TypeRegex> TypeRegexVector;
- RegexVector regex_;
- Boolean trace_;
+ TypeRegexVector type_regex_;
+ Boolean type_trace_;
+
+ typedef BackendElements::Regex::Expression<Char> SchemaRegex;
+ typedef BackendElements::Regex::Format<Char> SchemaRegexFormat;
+ typedef Cult::Containers::Vector<SchemaRegex> SchemaRegexVector;
+
+ SchemaRegexVector schema_regex_;
+ Boolean schema_trace_;
};
// Expand the \n escape sequence.
@@ -344,7 +361,7 @@ main (Int argc, Char* argv[])
e << "--type-file-regex <regex>" << endl
<< " Add the provided regular expression to the list of\n"
<< " regular expressions used to translate type names\n"
- << " to file names when the --type-per-file option is\n"
+ << " to file names when the --file-per-type option is\n"
<< " specified."
<< endl;
@@ -353,6 +370,18 @@ main (Int argc, Char* argv[])
<< " specified with the --type-file-regex option."
<< endl;
+ e << "--schema-file-regex <regex>" << endl
+ << " Add the provided regular expression to the list\n"
+ << " of regular expressions used to translate schema\n"
+ << " file names when the --file-per-type option is\n"
+ << " specified."
+ << endl;
+
+ e << "--schema-file-regex-trace" << endl
+ << " Trace the process of applying regular expressions\n"
+ << " specified with the --schema-file-regex option."
+ << endl;
+
// File list options.
//
e << "--file-list <file>" << endl
@@ -885,6 +914,7 @@ main (Int argc, Char* argv[])
*h_ops,
*root,
tu,
+ false,
disabled_w,
parser_type_map,
serializer_type_map,
@@ -907,6 +937,7 @@ main (Int argc, Char* argv[])
*p_ops,
*root,
tu,
+ false,
parser_type_map,
true,
disabled_w,
@@ -929,6 +960,7 @@ main (Int argc, Char* argv[])
*s_ops,
*root,
tu,
+ false,
serializer_type_map,
true,
disabled_w,
@@ -953,6 +985,7 @@ main (Int argc, Char* argv[])
*h_ops,
*root,
tu,
+ false,
disabled_w,
file_list,
unlinks);
@@ -973,6 +1006,7 @@ main (Int argc, Char* argv[])
*h_ops,
*root,
tu,
+ false,
disabled_w,
file_list,
unlinks);
@@ -1085,9 +1119,11 @@ main (Int argc, Char* argv[])
//
typedef Cult::Containers::Vector<SemanticGraph::Schema*> Schemas;
- TypeSchemaTranslator type_translator (
+ SchemaPerTypeTranslator type_translator (
common_ops.value<CLI::type_file_regex> (),
- common_ops.value<CLI::type_file_regex_trace> ());
+ common_ops.value<CLI::type_file_regex_trace> (),
+ common_ops.value<CLI::schema_file_regex> (),
+ common_ops.value<CLI::schema_file_regex_trace> ());
Transformations::SchemaPerType trans (
type_translator, gen_hybrid ? "fixed" : 0);
@@ -1099,7 +1135,10 @@ main (Int argc, Char* argv[])
i != e; ++i)
{
SemanticGraph::Schema& s (**i);
- SemanticGraph::Path path (s.used_begin ()->path ());
+ SemanticGraph::Path path (
+ s.context ().count ("renamed")
+ ? s.context ().get<SemanticGraph::Path> ("renamed")
+ : s.used_begin ()->path ());
TypeMap::Namespaces parser_type_map, serializer_type_map;
@@ -1111,6 +1150,7 @@ main (Int argc, Char* argv[])
*h_ops,
s,
path,
+ true,
disabled_w,
parser_type_map,
serializer_type_map,
@@ -1135,6 +1175,7 @@ main (Int argc, Char* argv[])
*p_ops,
s,
path,
+ true,
parser_type_map,
i == b,
disabled_w,
@@ -1159,6 +1200,7 @@ main (Int argc, Char* argv[])
*s_ops,
s,
path,
+ true,
serializer_type_map,
i == b,
disabled_w,
@@ -1183,6 +1225,7 @@ main (Int argc, Char* argv[])
*h_ops,
s,
path,
+ true,
disabled_w,
file_list,
unlinks);
@@ -1203,6 +1246,7 @@ main (Int argc, Char* argv[])
*h_ops,
s,
path,
+ true,
disabled_w,
file_list,
unlinks);
@@ -1295,7 +1339,7 @@ main (Int argc, Char* argv[])
{
// Diagnostic has already been issued.
}
- catch (TypeSchemaTranslator::Failed const&)
+ catch (SchemaPerTypeTranslator::Failed const&)
{
// Diagnostic has already been issued.
}
@@ -1493,20 +1537,24 @@ translate (WideString const& file,
return name;
}
-// TypeSchemaTranslator
+// SchemaPerTypeTranslator
//
-TypeSchemaTranslator::
-TypeSchemaTranslator (NarrowStrings const& regex, Boolean trace)
- : trace_ (trace)
+SchemaPerTypeTranslator::
+SchemaPerTypeTranslator (NarrowStrings const& type_regex,
+ Boolean type_trace,
+ NarrowStrings const& schema_regex,
+ Boolean schema_trace)
+ : type_trace_ (type_trace), schema_trace_ (schema_trace)
{
- for (NarrowStrings::ConstIterator i (regex.begin ()); i != regex.end (); ++i)
+ for (NarrowStrings::ConstIterator i (type_regex.begin ());
+ i != type_regex.end (); ++i)
{
try
{
- regex_.push_back (Regex (*i));
+ type_regex_.push_back (TypeRegex (*i));
}
- catch (RegexFormat const& e)
+ catch (TypeRegexFormat const& e)
{
wcerr << "error: invalid type file regex: '" <<
e.expression () << "': " << e.description () << endl;
@@ -1514,42 +1562,86 @@ TypeSchemaTranslator (NarrowStrings const& regex, Boolean trace)
throw Failed ();
}
}
+
+ for (NarrowStrings::ConstIterator i (schema_regex.begin ());
+ i != schema_regex.end (); ++i)
+ {
+ try
+ {
+ schema_regex_.push_back (SchemaRegex (*i));
+ }
+ catch (SchemaRegexFormat const& e)
+ {
+ wcerr << "error: invalid type file regex: '" <<
+ e.expression ().c_str () << "': " << e.description ().c_str () << endl;
+
+ throw Failed ();
+ }
+ }
}
-WideString TypeSchemaTranslator::
-translate (WideString const& ns, WideString const& name)
+WideString SchemaPerTypeTranslator::
+translate_type (WideString const& ns, WideString const& name)
{
- if (regex_.empty ())
- return name;
-
WideString s (ns + L' ' + name);
- if (trace_)
+ if (type_trace_)
wcerr << "type: '" << s << "'" << endl;
- for (RegexVector::ReverseIterator i (regex_.rbegin ());
- i != regex_.rend (); ++i)
+ for (TypeRegexVector::ReverseIterator i (type_regex_.rbegin ());
+ i != type_regex_.rend (); ++i)
{
- if (trace_)
+ if (type_trace_)
wcerr << "try: '" << i->pattern () << "' : ";
if (i->match (s))
{
WideString r (i->merge (s));
- if (trace_)
+ if (type_trace_)
wcerr << "'" << r << "' : +" << endl;
return r;
}
- if (trace_)
+ if (type_trace_)
wcerr << '-' << endl;
}
- // No match - return the type name.
+ // No match - return empty string.
//
- return name;
+ return L"";
+}
+
+NarrowString SchemaPerTypeTranslator::
+translate_schema (NarrowString const& file)
+{
+ if (schema_trace_)
+ wcerr << "schema: '" << file.c_str () << "'" << endl;
+
+ for (SchemaRegexVector::ReverseIterator i (schema_regex_.rbegin ());
+ i != schema_regex_.rend (); ++i)
+ {
+ if (schema_trace_)
+ wcerr << "try: '" << i->pattern () << "' : ";
+
+ if (i->match (file))
+ {
+ NarrowString r (i->merge (file));
+
+ if (schema_trace_)
+ wcerr << "'" << r.c_str () << "' : +" << endl;
+
+ return r;
+ }
+
+ if (schema_trace_)
+ wcerr << '-' << endl;
+ }
+
+ // No match - return empty string.
+ //
+ return "";
}
//