summaryrefslogtreecommitdiff
path: root/xsd/xsd
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-09-11 09:40:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-09-11 09:40:05 +0200
commit5a16bda0fa232eaaf3a497f569939a4f1bcf727f (patch)
tree56d3f38d68d934a299374d1c0baed36f3442c5f7 /xsd/xsd
parent0d9c416f2e8452a1f4d1c38727f81c420a4f5cd0 (diff)
Recognize --file-list value `-` as request to write to stdout
Diffstat (limited to 'xsd/xsd')
-rw-r--r--xsd/xsd/options.cli8
-rw-r--r--xsd/xsd/pregenerated/xsd/options.cxx3
-rw-r--r--xsd/xsd/xsd.cxx25
3 files changed, 21 insertions, 15 deletions
diff --git a/xsd/xsd/options.cli b/xsd/xsd/options.cli
index 6c327a4..e81052a 100644
--- a/xsd/xsd/options.cli
+++ b/xsd/xsd/options.cli
@@ -277,10 +277,10 @@ class options = 0
NarrowString --file-list
{
"<file>",
- "Write a list of generated C++ files to <file>. This option is primarily
- useful in the file-per-type compilation mode (\cb{--file-per-type}) to
- create a list of generated C++ files, for example, as a makefile
- fragment."
+ "Write a list of generated C++ files to <file> or to \cb{stdout} if
+ <file> is \cb{-}. This option is primarily useful in the file-per-type
+ compilation mode (\cb{--file-per-type}) to create a list of generated
+ C++ files, for example, as a makefile fragment."
};
NarrowString --file-list-prologue
diff --git a/xsd/xsd/pregenerated/xsd/options.cxx b/xsd/xsd/pregenerated/xsd/options.cxx
index 83cf67e..d8e59f6 100644
--- a/xsd/xsd/pregenerated/xsd/options.cxx
+++ b/xsd/xsd/pregenerated/xsd/options.cxx
@@ -1175,7 +1175,8 @@ print_usage (::std::wostream& os, ::cli::usage_para p)
<< " into type files instead of schema files when the" << ::std::endl
<< " --type-file-regex option is specified." << ::std::endl;
- os << "--file-list <file> Write a list of generated C++ files to <file>." << ::std::endl;
+ os << "--file-list <file> Write a list of generated C++ files to <file> or" << ::std::endl
+ << " to stdout if <file> is -." << ::std::endl;
os << "--file-list-prologue <text> Insert <text> at the beginning of the file list." << ::std::endl;
diff --git a/xsd/xsd/xsd.cxx b/xsd/xsd/xsd.cxx
index 0df4ea0..5a239d5 100644
--- a/xsd/xsd/xsd.cxx
+++ b/xsd/xsd/xsd.cxx
@@ -770,38 +770,43 @@ main (int argc, char* argv[])
try
{
OutputFileStream ofs;
- SemanticGraph::Path path (fl);
+ if (fl != "-")
+ {
+ SemanticGraph::Path path (fl);
- ofs.open (path.string ().c_str (), ios_base::out);
+ ofs.open (path.string ().c_str (), ios_base::out);
- if (!ofs.is_open ())
- {
- wcerr << path << ": error: unable to open in write mode" << endl;
- return 1;
+ if (!ofs.is_open ())
+ {
+ wcerr << path << ": error: unable to open in write mode" << endl;
+ return 1;
+ }
}
+ std::ostream& os (ofs.is_open () ? ofs : cout);
+
NarrowString d (common_ops.file_list_delim ());
expand_nl (d);
if (NarrowString p = common_ops.file_list_prologue ())
{
expand_nl (p);
- ofs << p;
+ os << p;
}
for (FileList::iterator i (file_list.begin ()), e (file_list.end ());
i != e;)
{
- ofs << *i;
+ os << *i;
if (++i != e)
- ofs << d;
+ os << d;
}
if (NarrowString e = common_ops.file_list_epilogue ())
{
expand_nl (e);
- ofs << e;
+ os << e;
}
}
catch (SemanticGraph::InvalidPath const&)