diff options
Diffstat (limited to 'xsd/xsd/cxx')
-rw-r--r-- | xsd/xsd/cxx/parser/generator.cxx | 173 | ||||
-rw-r--r-- | xsd/xsd/cxx/tree/generator.cxx | 80 |
2 files changed, 152 insertions, 101 deletions
diff --git a/xsd/xsd/cxx/parser/generator.cxx b/xsd/xsd/cxx/parser/generator.cxx index 832dbcb..b1acdbb 100644 --- a/xsd/xsd/cxx/parser/generator.cxx +++ b/xsd/xsd/cxx/parser/generator.cxx @@ -231,8 +231,11 @@ namespace CXX throw Failed (); } + bool gen_cxx (!ops.file_list_only ()); + // Process names. // + if (gen_cxx) { NameProcessor proc; proc.process (ops, schema, file_path, string_literal_map); @@ -244,7 +247,7 @@ namespace CXX // Compute state machine info. // - if (validation) + if (gen_cxx && validation) { StateProcessor proc; proc.process (schema, file_path); @@ -253,6 +256,7 @@ namespace CXX // Read-in type maps. // TypeMap::Namespaces type_map; + if (gen_cxx) { using namespace TypeMap; @@ -375,6 +379,7 @@ namespace CXX // Process types. // + if (gen_cxx) { TypeProcessor proc; proc.process (ops, schema, gen_driver, type_map); @@ -558,135 +563,165 @@ namespace CXX if (impl) { - if (!ops.force_overwrite ()) + if (gen_cxx) { - WideInputFileStream tmp ( - hxx_impl_path.string ().c_str (), ios_base::in); + if (!ops.force_overwrite ()) + { + WideInputFileStream tmp ( + hxx_impl_path.string ().c_str (), ios_base::in); - if (tmp.is_open ()) + if (tmp.is_open ()) + { + wcerr << hxx_impl_path << ": error: cowardly refusing to " << + "overwrite an existing file" << endl; + throw Failed (); + } + + tmp.close (); + } + + hxx_impl.open (hxx_impl_path.string ().c_str (), ios_base::out); + + if (!hxx_impl.is_open ()) { - wcerr << hxx_impl_path << ": error: cowardly refusing to " << - "overwrite an existing file" << endl; + wcerr << hxx_impl_path << ": error: unable to open in write mode" + << endl; throw Failed (); } - tmp.close (); + unlinks.add (hxx_impl_path); } - hxx_impl.open (hxx_impl_path.string ().c_str (), ios_base::out); + file_list.push_back (hxx_impl_path.string ()); - if (!hxx_impl.is_open ()) + if (gen_cxx) { - wcerr << hxx_impl_path << ": error: unable to open in write mode" - << endl; - throw Failed (); - } + if (!ops.force_overwrite ()) + { + WideInputFileStream tmp ( + cxx_impl_path.string ().c_str (), ios_base::in); - unlinks.add (hxx_impl_path); - file_list.push_back (hxx_impl_path.string ()); + if (tmp.is_open ()) + { + wcerr << cxx_impl_path << ": error: cowardly refusing to " << + "overwrite an existing file" << endl; + throw Failed (); + } - if (!ops.force_overwrite ()) - { - WideInputFileStream tmp ( - cxx_impl_path.string ().c_str (), ios_base::in); + tmp.close (); + } - if (tmp.is_open ()) + cxx_impl.open (cxx_impl_path.string ().c_str (), ios_base::out); + + if (!cxx_impl.is_open ()) { - wcerr << cxx_impl_path << ": error: cowardly refusing to " << - "overwrite an existing file" << endl; + wcerr << cxx_impl_path << ": error: unable to open in write mode" + << endl; throw Failed (); } - tmp.close (); - } - - cxx_impl.open (cxx_impl_path.string ().c_str (), ios_base::out); - - if (!cxx_impl.is_open ()) - { - wcerr << cxx_impl_path << ": error: unable to open in write mode" - << endl; - throw Failed (); + unlinks.add (cxx_impl_path); } - unlinks.add (cxx_impl_path); file_list.push_back (cxx_impl_path.string ()); } if (driver) { - if (!ops.force_overwrite ()) + if (gen_cxx) { - WideInputFileStream tmp ( - cxx_driver_path.string ().c_str (), ios_base::in); - - if (tmp.is_open ()) + if (!ops.force_overwrite ()) { - wcerr << cxx_driver_path << ": error: cowardly refusing to " << - "overwrite an existing file" << endl; - throw Failed (); + WideInputFileStream tmp ( + cxx_driver_path.string ().c_str (), ios_base::in); + + if (tmp.is_open ()) + { + wcerr << cxx_driver_path << ": error: cowardly refusing to " << + "overwrite an existing file" << endl; + throw Failed (); + } + + tmp.close (); } - tmp.close (); - } + cxx_driver.open (cxx_driver_path.string ().c_str (), ios_base::out); - cxx_driver.open (cxx_driver_path.string ().c_str (), ios_base::out); + if (!cxx_driver.is_open ()) + { + wcerr << cxx_driver_path << ": error: unable to open in write " << + "mode" << endl; + throw Failed (); + } - if (!cxx_driver.is_open ()) - { - wcerr << cxx_driver_path << ": error: unable to open in write " << - "mode" << endl; - throw Failed (); + unlinks.add (cxx_driver_path); } - unlinks.add (cxx_driver_path); file_list.push_back (cxx_driver_path.string ()); } // Open the skel files. // - WideOutputFileStream hxx (hxx_path.string ().c_str (), ios_base::out); + WideOutputFileStream hxx; WideOutputFileStream ixx; WideOutputFileStream cxx; - if (!hxx.is_open ()) + if (gen_cxx) { - wcerr << hxx_path << ": error: unable to open in write mode" << endl; - throw Failed (); + hxx.open (hxx_path.string ().c_str (), ios_base::out); + + if (!hxx.is_open ()) + { + wcerr << hxx_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (hxx_path); } - unlinks.add (hxx_path); file_list.push_back (hxx_path.string ()); if (inline_) { - ixx.open (ixx_path.string ().c_str (), ios_base::out); - - if (!ixx.is_open ()) + if (gen_cxx) { - wcerr << ixx_path << ": error: unable to open in write mode" << endl; - throw Failed (); + ixx.open (ixx_path.string ().c_str (), ios_base::out); + + if (!ixx.is_open ()) + { + wcerr << ixx_path << ": error: unable to open in write mode" + << endl; + throw Failed (); + } + + unlinks.add (ixx_path); } - unlinks.add (ixx_path); file_list.push_back (ixx_path.string ()); } - if (source) { - cxx.open (cxx_path.string ().c_str (), ios_base::out); - - if (!cxx.is_open ()) + if (gen_cxx) { - wcerr << cxx_path << ": error: unable to open in write mode" << endl; - throw Failed (); + cxx.open (cxx_path.string ().c_str (), ios_base::out); + + if (!cxx.is_open ()) + { + wcerr << cxx_path << ": error: unable to open in write mode" + << endl; + throw Failed (); + } + + unlinks.add (cxx_path); } - unlinks.add (cxx_path); file_list.push_back (cxx_path.string ()); } + if (!gen_cxx) + return 0; + // Print copyright and license. // char const* copyright ( diff --git a/xsd/xsd/cxx/tree/generator.cxx b/xsd/xsd/cxx/tree/generator.cxx index 8becfec..d3e4db2 100644 --- a/xsd/xsd/cxx/tree/generator.cxx +++ b/xsd/xsd/cxx/tree/generator.cxx @@ -231,7 +231,7 @@ namespace CXX throw Failed (); } - bool gen_cxx (!ops.generate_dep_only ()); + bool gen_cxx (!ops.generate_dep_only () && !ops.file_list_only ()); // Process ordered types. // @@ -493,72 +493,88 @@ namespace CXX // FWD // - if (gen_cxx && forward) + if (forward) { - fwd.open (fwd_path.string ().c_str (), ios_base::out); - - if (!fwd.is_open ()) + if (gen_cxx) { - wcerr << fwd_path << ": error: unable to open in write mode" << endl; - throw Failed (); + fwd.open (fwd_path.string ().c_str (), ios_base::out); + + if (!fwd.is_open ()) + { + wcerr << fwd_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (fwd_path); } - unlinks.add (fwd_path); file_list.push_back (fwd_path.string ()); } // HXX // - if (gen_cxx && header) + if (header) { - hxx.open (hxx_path.string ().c_str (), ios_base::out); - - if (!hxx.is_open ()) + if (gen_cxx) { - wcerr << hxx_path << ": error: unable to open in write mode" << endl; - throw Failed (); + hxx.open (hxx_path.string ().c_str (), ios_base::out); + + if (!hxx.is_open ()) + { + wcerr << hxx_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (hxx_path); } - unlinks.add (hxx_path); file_list.push_back (hxx_path.string ()); } // IXX // - if (gen_cxx && inline_) + if (inline_) { - ixx.open (ixx_path.string ().c_str (), ios_base::out); - - if (!ixx.is_open ()) + if (gen_cxx) { - wcerr << ixx_path << ": error: unable to open in write mode" << endl; - throw Failed (); + ixx.open (ixx_path.string ().c_str (), ios_base::out); + + if (!ixx.is_open ()) + { + wcerr << ixx_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (ixx_path); } - unlinks.add (ixx_path); file_list.push_back (ixx_path.string ()); } // CXX // - if (gen_cxx && source) + if (source) { for (Paths::iterator i (cxx_paths.begin ()); i != cxx_paths.end (); ++i) { - shared_ptr<WideOutputFileStream> s ( - new (shared) WideOutputFileStream ( - i->string ().c_str (), ios_base::out)); - - if (!s->is_open ()) + if (gen_cxx) { - wcerr << *i << ": error: unable to open in write mode" << endl; - throw Failed (); + shared_ptr<WideOutputFileStream> s ( + new (shared) WideOutputFileStream ( + i->string ().c_str (), ios_base::out)); + + if (!s->is_open ()) + { + wcerr << *i << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + cxx.push_back (s); + unlinks.add (*i); } - unlinks.add (*i); file_list.push_back (i->string ()); - cxx.push_back (s); } } |