diff options
Diffstat (limited to 'xsde/xsde.hxx')
-rw-r--r-- | xsde/xsde.hxx | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/xsde/xsde.hxx b/xsde/xsde.hxx new file mode 100644 index 0000000..2da67d5 --- /dev/null +++ b/xsde/xsde.hxx @@ -0,0 +1,79 @@ +// file : xsde/xsde.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_HXX +#define XSDE_HXX + +#include <xsd-frontend/semantic-graph/elements.hxx> // Path + +#include <cult/types.hxx> +#include <cult/containers/set.hxx> +#include <cult/containers/vector.hxx> + +#include <cstdio> // std::remove + +using namespace Cult::Types; + +// +// +typedef Cult::Containers::Set<NarrowString> WarningSet; + +// +// +typedef Cult::Containers::Vector<NarrowString> 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_; + Boolean canceled_; +}; + +// +// +struct AutoUnlinks +{ + Void + add (XSDFrontend::SemanticGraph::Path const& file) + { + unlinks_.push_back (Evptr<AutoUnlink> (new AutoUnlink (file))); + } + + Void + cancel () + { + for (Unlinks::Iterator i (unlinks_.begin ()); i != unlinks_.end (); ++i) + { + (*i)->cancel (); + } + } + +private: + typedef Cult::Containers::Vector<Evptr<AutoUnlink> > Unlinks; + Unlinks unlinks_; +}; + +#endif // XSDE_HXX |