From 6f5e742482eadf055c18bdbe4082450d3161edef Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 30 May 2013 19:54:24 -0400 Subject: Get rid of dependency on Boost filesystem --- INSTALL | 3 +- build/import/libboost/filesystem/rules.make | 53 -------------------- build/import/libboost/filesystem/stub.make | 36 ------------- build/import/libxsd-frontend/stub.make | 2 +- xsd/cxx/elements.cxx | 6 ++- xsd/cxx/parser/elements.cxx | 5 +- xsd/cxx/parser/generator.cxx | 78 ++++++++++++++--------------- xsd/cxx/tree/elements.cxx | 5 +- xsd/cxx/tree/fundamental-header.hxx | 1 + xsd/cxx/tree/generator.cxx | 77 +++++++++++++--------------- xsd/makefile | 7 +-- xsd/xsd.cxx | 28 +++++------ xsd/xsd.hxx | 52 ++----------------- 13 files changed, 103 insertions(+), 250 deletions(-) delete mode 100644 build/import/libboost/filesystem/rules.make delete mode 100644 build/import/libboost/filesystem/stub.make diff --git a/INSTALL b/INSTALL index 366cda1..aa2edc5 100644 --- a/INSTALL +++ b/INSTALL @@ -11,8 +11,7 @@ Compiler Prerequisites - libbackend-elements >= 1.7.2 http://kolpackov.net/projects/libbackend-elements/ - libcult >= 1.4.6 http://kolpackov.net/projects/libcult/ - libxerces-c >= 2.6.0 http://xerces.apache.org/xerces-c/ - - libboost_filesystem >= 1.33.1 http://boost.org - - libboost_regex >= 1.33.1 http://boost.org + Generated Code Prerequisites diff --git a/build/import/libboost/filesystem/rules.make b/build/import/libboost/filesystem/rules.make deleted file mode 100644 index fa70735..0000000 --- a/build/import/libboost/filesystem/rules.make +++ /dev/null @@ -1,53 +0,0 @@ -# file : build/import/libboost/filesystem/rules.make -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2011 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -#@@ Should use message everywhere. -# - -$(dcf_root)/import/libboost/%: root := $(libboost_root) - -$(dcf_root)/import/libboost/filesystem/filesystem.l: \ - | $(dcf_root)/import/libboost/filesystem/. - -ifeq ($(libboost_type),archive) - -ifeq ($(libboost_system),y) -$(dcf_root)/import/libboost/filesystem/filesystem.l: \ - $(libboost_root)/stage/lib/libboost_filesystem$(libboost_suffix).a \ - $(libboost_root)/stage/lib/libboost_system$(libboost_suffix).a -else -$(dcf_root)/import/libboost/filesystem/filesystem.l: \ - $(libboost_root)/stage/lib/libboost_filesystem$(libboost_suffix).a -endif - @echo $^ >$@ - -else - -ifeq ($(libboost_system),y) -$(dcf_root)/import/libboost/filesystem/filesystem.l: \ - $(libboost_root)/stage/lib/libboost_filesystem$(libboost_suffix).so \ - $(libboost_root)/stage/lib/libboost_system$(libboost_suffix).so -else -$(dcf_root)/import/libboost/filesystem/filesystem.l: \ - $(libboost_root)/stage/lib/libboost_filesystem$(libboost_suffix).so -endif - @echo $^ >$@ - @echo rpath:$(root)/stage/lib >>$@ - -endif - - -$(dcf_root)/import/libboost/filesystem/filesystem.l.cpp-options: \ - | $(dcf_root)/import/libboost/filesystem/. - @echo include: -I$(root) >$@ - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libboost/filesystem/filesystem.l,\ -rm -f $(dcf_root)/import/libboost/filesystem/filesystem.l) - $(call message,,rm -f $(dcf_root)/import/libboost/filesystem/filesystem.l.cpp-options) - -endif diff --git a/build/import/libboost/filesystem/stub.make b/build/import/libboost/filesystem/stub.make deleted file mode 100644 index 76ad55e..0000000 --- a/build/import/libboost/filesystem/stub.make +++ /dev/null @@ -1,36 +0,0 @@ -# file : build/import/libboost/filesystem/stub.make -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2011 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libboost/configuration-rules.make,$(dcf_root)) - -libboost_installed := - -$(call -include,$(dcf_root)/import/libboost/configuration-dynamic.make) - -ifdef libboost_installed - -ifeq ($(libboost_installed),y) - -ifeq ($(libboost_system),y) -$(call export,l: -lboost_filesystem$(libboost_suffix) -lboost_system$(libboost_suffix),cpp_options: ) -else -$(call export,l: -lboost_filesystem$(libboost_suffix),cpp_options: ) -endif - -else - -$(call include-once,$(scf_root)/import/libboost/filesystem/rules.make,$(dcf_root)) - -$(call export,\ - l: $(dcf_root)/import/libboost/filesystem/filesystem.l,\ - cpp-options: $(dcf_root)/import/libboost/filesystem/filesystem.l.cpp-options) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libxsd-frontend/stub.make b/build/import/libxsd-frontend/stub.make index f861eb6..8c72f1b 100644 --- a/build/import/libxsd-frontend/stub.make +++ b/build/import/libxsd-frontend/stub.make @@ -13,7 +13,7 @@ ifdef libxsd_frontend_installed ifeq ($(libxsd_frontend_installed),y) -$(call export,l: -lxsd-frontend -lfrontend-elements -lcult -lboost_filesystem -lxerces-c,cpp_options: ) +$(call export,l: -lxsd-frontend -lfrontend-elements -lcult -lxerces-c,cpp_options: ) else diff --git a/xsd/cxx/elements.cxx b/xsd/cxx/elements.cxx index 7d2d277..4a76444 100644 --- a/xsd/cxx/elements.cxx +++ b/xsd/cxx/elements.cxx @@ -305,16 +305,18 @@ namespace CXX if (!path.empty ()) { + path.normalize (); + // Try to use the portable representation of the path. If that // fails, fall back to the native representation. // try { - pair = path.string (); + pair = path.posix_string (); } catch (SemanticGraph::InvalidPath const&) { - pair = path.native_file_string (); + pair = path.string (); } } diff --git a/xsd/cxx/parser/elements.cxx b/xsd/cxx/parser/elements.cxx index a721ea8..bd610a3 100644 --- a/xsd/cxx/parser/elements.cxx +++ b/xsd/cxx/parser/elements.cxx @@ -212,6 +212,7 @@ namespace CXX s.context ().count ("renamed") ? s.context ().get ("renamed") : u.path ()); + path.normalize (); // Try to use the portable representation of the path. If that // fails, fall back to the native representation. @@ -219,11 +220,11 @@ namespace CXX NarrowString path_str; try { - path_str = path.string (); + path_str = path.posix_string (); } catch (SemanticGraph::InvalidPath const&) { - path_str = path.native_file_string (); + path_str = path.string (); } String inc_path; diff --git a/xsd/cxx/parser/generator.cxx b/xsd/cxx/parser/generator.cxx index 7ef7183..a262004 100644 --- a/xsd/cxx/parser/generator.cxx +++ b/xsd/cxx/parser/generator.cxx @@ -3,9 +3,9 @@ // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include #include - -#include +#include #include @@ -52,17 +52,9 @@ using namespace XSDFrontend::SemanticGraph; // // -typedef -boost::filesystem::wifstream -WideInputFileStream; - -typedef -boost::filesystem::wofstream -WideOutputFileStream; - -typedef -boost::filesystem::ifstream -NarrowInputFileStream; +typedef std::wifstream WideInputFileStream; +typedef std::wofstream WideOutputFileStream; +typedef std::ifstream NarrowInputFileStream; namespace CXX { @@ -136,8 +128,9 @@ namespace CXX { try { - Path fs_path (path, boost::filesystem::native); - ifs.open (fs_path, std::ios_base::in | std::ios_base::binary); + Path fs_path (path); + ifs.open (fs_path.string ().c_str (), + std::ios_base::in | std::ios_base::binary); if (!ifs.is_open ()) { @@ -220,7 +213,7 @@ namespace CXX { if (NarrowString name = ops.extern_xml_schema ()) { - if (file_path.native_file_string () != name) + if (file_path.string () != name) generate_xml_schema = false; } } @@ -395,7 +388,7 @@ namespace CXX // Generate code. // - NarrowString name (file_path.leaf ()); + NarrowString name (file_path.leaf ().string ()); NarrowString skel_suffix (ops.skel_file_suffix ()); NarrowString impl_suffix (ops.impl_file_suffix ()); @@ -501,9 +494,9 @@ namespace CXX cxx_driver_name = cxx_driver_expr.replace (name); } - Path hxx_path (hxx_name, boost::filesystem::native); - Path ixx_path (ixx_name, boost::filesystem::native); - Path cxx_path (cxx_name, boost::filesystem::native); + Path hxx_path (hxx_name); + Path ixx_path (ixx_name); + Path cxx_path (cxx_name); Path hxx_impl_path; Path cxx_impl_path; @@ -511,9 +504,9 @@ namespace CXX if (impl || driver) { - hxx_impl_path = Path (hxx_impl_name, boost::filesystem::native); - cxx_impl_path = Path (cxx_impl_name, boost::filesystem::native); - cxx_driver_path = Path (cxx_driver_name, boost::filesystem::native); + hxx_impl_path = Path (hxx_impl_name); + cxx_impl_path = Path (cxx_impl_name); + cxx_driver_path = Path (cxx_driver_name); } Path out_dir; @@ -522,7 +515,7 @@ namespace CXX { try { - out_dir = Path (dir, boost::filesystem::native); + out_dir = Path (dir); } catch (InvalidPath const&) { @@ -537,7 +530,7 @@ namespace CXX // unless the user added the directory so that we propagate this // to the output files. // - Path fpt_dir (file_path.branch_path ()); + Path fpt_dir (file_path.directory ()); if (!fpt_dir.empty ()) out_dir /= fpt_dir; @@ -568,7 +561,8 @@ namespace CXX { if (!ops.force_overwrite ()) { - WideInputFileStream tmp (hxx_impl_path, ios_base::in); + WideInputFileStream tmp ( + hxx_impl_path.string ().c_str (), ios_base::in); if (tmp.is_open ()) { @@ -580,7 +574,7 @@ namespace CXX tmp.close (); } - hxx_impl.open (hxx_impl_path, ios_base::out); + hxx_impl.open (hxx_impl_path.string ().c_str (), ios_base::out); if (!hxx_impl.is_open ()) { @@ -590,11 +584,12 @@ namespace CXX } unlinks.add (hxx_impl_path); - file_list.push_back (hxx_impl_path.native_file_string ()); + file_list.push_back (hxx_impl_path.string ()); if (!ops.force_overwrite ()) { - WideInputFileStream tmp (cxx_impl_path, ios_base::in); + WideInputFileStream tmp ( + cxx_impl_path.string ().c_str (), ios_base::in); if (tmp.is_open ()) { @@ -606,7 +601,7 @@ namespace CXX tmp.close (); } - cxx_impl.open (cxx_impl_path, ios_base::out); + cxx_impl.open (cxx_impl_path.string ().c_str (), ios_base::out); if (!cxx_impl.is_open ()) { @@ -616,14 +611,15 @@ namespace CXX } unlinks.add (cxx_impl_path); - file_list.push_back (cxx_impl_path.native_file_string ()); + file_list.push_back (cxx_impl_path.string ()); } if (driver) { if (!ops.force_overwrite ()) { - WideInputFileStream tmp (cxx_driver_path, ios_base::in); + WideInputFileStream tmp ( + cxx_driver_path.string ().c_str (), ios_base::in); if (tmp.is_open ()) { @@ -635,7 +631,7 @@ namespace CXX tmp.close (); } - cxx_driver.open (cxx_driver_path, ios_base::out); + cxx_driver.open (cxx_driver_path.string ().c_str (), ios_base::out); if (!cxx_driver.is_open ()) { @@ -645,12 +641,12 @@ namespace CXX } unlinks.add (cxx_driver_path); - file_list.push_back (cxx_driver_path.native_file_string ()); + file_list.push_back (cxx_driver_path.string ()); } // Open the skel files. // - WideOutputFileStream hxx (hxx_path, ios_base::out); + WideOutputFileStream hxx (hxx_path.string ().c_str (), ios_base::out); WideOutputFileStream ixx; WideOutputFileStream cxx; @@ -661,11 +657,11 @@ namespace CXX } unlinks.add (hxx_path); - file_list.push_back (hxx_path.native_file_string ()); + file_list.push_back (hxx_path.string ()); if (inline_) { - ixx.open (ixx_path, ios_base::out); + ixx.open (ixx_path.string ().c_str (), ios_base::out); if (!ixx.is_open ()) { @@ -674,13 +670,13 @@ namespace CXX } unlinks.add (ixx_path); - file_list.push_back (ixx_path.native_file_string ()); + file_list.push_back (ixx_path.string ()); } if (source) { - cxx.open (cxx_path, ios_base::out); + cxx.open (cxx_path.string ().c_str (), ios_base::out); if (!cxx.is_open ()) { @@ -689,7 +685,7 @@ namespace CXX } unlinks.add (cxx_path); - file_list.push_back (cxx_path.native_file_string ()); + file_list.push_back (cxx_path.string ()); } // Print copyright and license. @@ -754,7 +750,7 @@ namespace CXX NarrowString guard_prefix (ops.guard_prefix ()); if (!guard_prefix) - guard_prefix = file_path.branch_path ().native_directory_string (); + guard_prefix = file_path.directory ().string (); if (guard_prefix) guard_prefix += '_'; diff --git a/xsd/cxx/tree/elements.cxx b/xsd/cxx/tree/elements.cxx index 87d58ca..5fdee30 100644 --- a/xsd/cxx/tree/elements.cxx +++ b/xsd/cxx/tree/elements.cxx @@ -1326,6 +1326,7 @@ namespace CXX s.context ().count ("renamed") ? s.context ().get ("renamed") : u.path ()); + path.normalize (); // Try to use the portable representation of the path. If that // fails, fall back to the native representation. @@ -1333,11 +1334,11 @@ namespace CXX NarrowString path_str; try { - path_str = path.string (); + path_str = path.posix_string (); } catch (SemanticGraph::InvalidPath const&) { - path_str = path.native_file_string (); + path_str = path.string (); } String inc_path; diff --git a/xsd/cxx/tree/fundamental-header.hxx b/xsd/cxx/tree/fundamental-header.hxx index dd67f89..2171de4 100644 --- a/xsd/cxx/tree/fundamental-header.hxx +++ b/xsd/cxx/tree/fundamental-header.hxx @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/xsd/cxx/tree/generator.cxx b/xsd/cxx/tree/generator.cxx index a68db3e..b373d31 100644 --- a/xsd/cxx/tree/generator.cxx +++ b/xsd/cxx/tree/generator.cxx @@ -4,9 +4,9 @@ // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include +#include #include - -#include +#include #include #include @@ -55,13 +55,8 @@ using namespace XSDFrontend::SemanticGraph; // // -typedef -boost::filesystem::wifstream -WideInputFileStream; - -typedef -boost::filesystem::wofstream -WideOutputFileStream; +typedef std::wifstream WideInputFileStream; +typedef std::wofstream WideOutputFileStream; namespace CXX { @@ -126,8 +121,9 @@ namespace CXX { try { - Path fs_path (path, boost::filesystem::native); - ifs.open (fs_path, std::ios_base::in | std::ios_base::binary); + Path fs_path (path); + ifs.open (fs_path.string ().c_str (), + std::ios_base::in | std::ios_base::binary); if (!ifs.is_open ()) { @@ -288,7 +284,7 @@ namespace CXX { if (NarrowString name = ops.extern_xml_schema ()) { - if (file_path.native_file_string () != name) + if (file_path.string () != name) generate_xml_schema = false; } } @@ -316,7 +312,7 @@ namespace CXX // Generate code. // - NarrowString name (file_path.leaf ()); + NarrowString name (file_path.leaf ().string ()); NarrowString hxx_suffix (ops.hxx_suffix ()); NarrowString ixx_suffix (ops.ixx_suffix ()); @@ -389,10 +385,10 @@ namespace CXX NarrowString fwd_name (forward ? fwd_expr.replace (name) : NarrowString ()); NarrowString dep_name (gen_dep ? dep_expr.replace (name) : NarrowString ()); - Path hxx_path (hxx_name, boost::filesystem::native); - Path ixx_path (ixx_name, boost::filesystem::native); - Path fwd_path (fwd_name, boost::filesystem::native); - Path dep_path (dep_name, boost::filesystem::native); + Path hxx_path (hxx_name); + Path ixx_path (ixx_name); + Path fwd_path (fwd_name); + Path dep_path (dep_name); Paths cxx_paths; if (source) @@ -417,13 +413,11 @@ namespace CXX throw Failed (); } - cxx_paths.push_back ( - Path (cxx_expr.replace (part_name), boost::filesystem::native)); + cxx_paths.push_back (Path (cxx_expr.replace (part_name))); } } else - cxx_paths.push_back ( - Path (cxx_expr.replace (name), boost::filesystem::native)); + cxx_paths.push_back (Path (cxx_expr.replace (name))); } Path out_dir; @@ -432,7 +426,7 @@ namespace CXX { try { - out_dir = Path (dir, boost::filesystem::native); + out_dir = Path (dir); } catch (InvalidPath const&) { @@ -447,7 +441,7 @@ namespace CXX // unless the user added the directory so that we propagate this // to the output files. // - Path fpt_dir (file_path.branch_path ()); + Path fpt_dir (file_path.directory ()); if (!fpt_dir.empty ()) out_dir /= fpt_dir; @@ -477,7 +471,7 @@ namespace CXX // if (gen_dep) { - dep.open (dep_path, ios_base::out); + dep.open (dep_path.string ().c_str (), ios_base::out); if (!dep.is_open ()) { @@ -486,14 +480,14 @@ namespace CXX } unlinks.add (dep_path); - file_list.push_back (dep_path.native_file_string ()); + file_list.push_back (dep_path.string ()); } // FWD // if (gen_cxx && forward) { - fwd.open (fwd_path, ios_base::out); + fwd.open (fwd_path.string ().c_str (), ios_base::out); if (!fwd.is_open ()) { @@ -502,14 +496,14 @@ namespace CXX } unlinks.add (fwd_path); - file_list.push_back (fwd_path.native_file_string ()); + file_list.push_back (fwd_path.string ()); } // HXX // if (gen_cxx && header) { - hxx.open (hxx_path, ios_base::out); + hxx.open (hxx_path.string ().c_str (), ios_base::out); if (!hxx.is_open ()) { @@ -518,14 +512,14 @@ namespace CXX } unlinks.add (hxx_path); - file_list.push_back (hxx_path.native_file_string ()); + file_list.push_back (hxx_path.string ()); } // IXX // if (gen_cxx && inline_) { - ixx.open (ixx_path, ios_base::out); + ixx.open (ixx_path.string ().c_str (), ios_base::out); if (!ixx.is_open ()) { @@ -534,7 +528,7 @@ namespace CXX } unlinks.add (ixx_path); - file_list.push_back (ixx_path.native_file_string ()); + file_list.push_back (ixx_path.string ()); } // CXX @@ -545,7 +539,8 @@ namespace CXX i != cxx_paths.end (); ++i) { shared_ptr s ( - new (shared) WideOutputFileStream (*i, ios_base::out)); + new (shared) WideOutputFileStream ( + i->string ().c_str (), ios_base::out)); if (!s->is_open ()) { @@ -554,7 +549,7 @@ namespace CXX } unlinks.add (*i); - file_list.push_back (i->native_file_string ()); + file_list.push_back (i->string ()); cxx.push_back (s); } } @@ -632,7 +627,7 @@ namespace CXX NarrowString guard_prefix (ops.guard_prefix ()); if (!guard_prefix) - guard_prefix = file_path.branch_path ().native_directory_string (); + guard_prefix = file_path.directory ().string (); if (guard_prefix) guard_prefix += '_'; @@ -652,19 +647,19 @@ namespace CXX } else { - target = hxx_path.native_file_string (); + target = hxx_path.string (); if (forward) - target += " \\\n" + fwd_path.native_file_string (); + target += " \\\n" + fwd_path.string (); if (inline_) - target += " \\\n" + ixx_path.native_file_string (); + target += " \\\n" + ixx_path.string (); for (Paths::iterator i (cxx_paths.begin ()); i != cxx_paths.end (); ++i) - target += " \\\n" + i->native_file_string (); + target += " \\\n" + i->string (); - target += " \\\n" + dep_path.native_file_string (); + target += " \\\n" + dep_path.string (); } dep << target.c_str () << ':'; @@ -674,7 +669,7 @@ namespace CXX for (Paths::iterator i (prq.begin ()); i != prq.end (); ++i) dep << " \\" << endl - << " " << i->string (); + << " " << *i; dep << endl; @@ -685,7 +680,7 @@ namespace CXX { for (Paths::iterator i (prq.begin () + 1); i != prq.end (); ++i) dep << endl - << i->string () << ':' << endl; + << *i << ':' << endl; } } diff --git a/xsd/makefile b/xsd/makefile index 00bab30..e80df26 100644 --- a/xsd/makefile +++ b/xsd/makefile @@ -86,10 +86,6 @@ $(call import,\ l: cutl.l,cpp-options: cutl.l.cpp-options) $(call import,\ - $(scf_root)/import/libboost/filesystem/stub.make,\ - l: fs.l,cpp-options: fs.l.cpp-options) - -$(call import,\ $(scf_root)/import/libxsd-frontend/stub.make,\ l: xsd_fe.l,cpp-options: xsd_fe.l.cpp-options) @@ -99,13 +95,12 @@ $(call import,\ # Build. # -$(xsd): $(cxx_obj) $(xsd_fe.l) $(cutl.l) $(fs.l) $(xerces_c.l) +$(xsd): $(cxx_obj) $(xsd_fe.l) $(cutl.l) $(xerces_c.l) $(cxx_obj) $(cxx_od): cpp_options := -I$(src_base) $(cxx_obj) $(cxx_od): \ $(xsd_fe.l.cpp-options) \ $(cutl.l.cpp-options) \ - $(fs.l.cpp-options) \ $(xerces_c.l.cpp-options) genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx) diff --git a/xsd/xsd.cxx b/xsd/xsd.cxx index de6f2fd..794745f 100644 --- a/xsd/xsd.cxx +++ b/xsd/xsd.cxx @@ -8,8 +8,7 @@ #include // std::auto_ptr #include // std::size_t #include - -#include +#include #include @@ -420,7 +419,7 @@ main (int argc, char* argv[]) try { - tu = SemanticGraph::Path (files[i], boost::filesystem::native); + tu = SemanticGraph::Path (files[i]); } catch (SemanticGraph::InvalidPath const&) { @@ -453,7 +452,7 @@ main (int argc, char* argv[]) { if (NarrowString name = common_ops.extern_xml_schema ()) { - if (tu.native_file_string () != name) + if (tu.string () != name) gen_xml_schema = false; } } @@ -589,8 +588,7 @@ main (int argc, char* argv[]) { try { - paths.push_back ( - SemanticGraph::Path (files[i], boost::filesystem::native)); + paths.push_back (SemanticGraph::Path (files[i])); } catch (SemanticGraph::InvalidPath const&) { @@ -625,7 +623,7 @@ main (int argc, char* argv[]) try { Transformations::Anonymous trans (anon_translator); - trans.transform (*schema, "", false); + trans.transform (*schema, SemanticGraph::Path (), false); } catch (Transformations::Anonymous::Failed const&) { @@ -638,7 +636,7 @@ main (int argc, char* argv[]) if (cmd == "cxx-tree") { Transformations::EnumSynthesis trans; - trans.transform (*schema, ""); + trans.transform (*schema, SemanticGraph::Path ()); } // Simplify the schema graph. @@ -646,7 +644,7 @@ main (int argc, char* argv[]) if (cmd == "cxx-parser") { Transformations::Simplifier trans; - trans.transform (*schema, ""); + trans.transform (*schema, SemanticGraph::Path ()); } // Normalize and annotate complex content restrictions. @@ -656,7 +654,7 @@ main (int argc, char* argv[]) try { Transformations::Restriction trans; - trans.transform (*schema, ""); + trans.transform (*schema, SemanticGraph::Path ()); } catch (Transformations::Restriction::Failed const&) { @@ -668,7 +666,7 @@ main (int argc, char* argv[]) // { Processing::Cardinality::Processor proc; - proc.process (*schema, ""); + proc.process (*schema, SemanticGraph::Path ()); } // Rearrange the graph so that each type is in a seperate @@ -751,14 +749,14 @@ main (int argc, char* argv[]) // if (NarrowString fl = common_ops.file_list ()) { - typedef boost::filesystem::ofstream OutputFileStream; + typedef std::ofstream OutputFileStream; try { OutputFileStream ofs; SemanticGraph::Path path (fl); - ofs.open (fl, ios_base::out); + ofs.open (path.string ().c_str (), ios_base::out); if (!ofs.is_open ()) { @@ -960,7 +958,7 @@ AnonymousNameTranslator (NarrowStrings const& regex, bool trace) catch (RegexFormat const& e) { wcerr << "error: invalid anonymous type regex: '" << - e.regex () << "': " << e.description () << endl; + e.regex () << "': " << e.description ().c_str () << endl; throw Failed (); } @@ -1023,7 +1021,7 @@ SchemaPerTypeTranslator (NarrowStrings const& type_regex, catch (TypeRegexFormat const& e) { wcerr << "error: invalid type file regex: '" << - e.regex () << "': " << e.description () << endl; + e.regex () << "': " << e.description ().c_str () << endl; throw Failed (); } diff --git a/xsd/xsd.hxx b/xsd/xsd.hxx index 43f38ea..83bfdfd 100644 --- a/xsd/xsd.hxx +++ b/xsd/xsd.hxx @@ -11,6 +11,7 @@ #include // std::remove #include +#include #include // Path @@ -19,54 +20,7 @@ typedef std::set WarningSet; typedef std::vector FileList; -// -// -struct AutoUnlink -{ - AutoUnlink (XSDFrontend::SemanticGraph::Path const& file) - : file_ (file), canceled_ (false) - { - } - - ~AutoUnlink () - { - if (!canceled_) - std::remove (file_.native_file_string ().c_str ()); - } - - void - cancel () - { - canceled_ = true; - } - -private: - XSDFrontend::SemanticGraph::Path file_; - bool canceled_; -}; - -// -// -struct AutoUnlinks -{ - void - add (XSDFrontend::SemanticGraph::Path const& file) - { - unlinks_.push_back( - cutl::shared_ptr ( - new (shared) AutoUnlink (file))); - } - - void - cancel () - { - for (Unlinks::iterator i (unlinks_.begin ()); i != unlinks_.end (); ++i) - (*i)->cancel (); - } - -private: - typedef std::vector > Unlinks; - Unlinks unlinks_; -}; +typedef cutl::fs::auto_remove AutoUnlink; +typedef cutl::fs::auto_removes AutoUnlinks; #endif // XSD_HXX -- cgit v1.1