From f0510d2f90467de8e8f260b47d79a9baaf9bef17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Sep 2009 07:15:29 +0200 Subject: Start tracking XSD with git --- xsd/xsd.hxx | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 xsd/xsd.hxx (limited to 'xsd/xsd.hxx') diff --git a/xsd/xsd.hxx b/xsd/xsd.hxx new file mode 100644 index 0000000..f09b18d --- /dev/null +++ b/xsd/xsd.hxx @@ -0,0 +1,80 @@ +// file : xsd/xsd.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_HXX +#define XSD_HXX + +#include // Path + +#include +#include +#include + + +#include // std::remove + +using namespace Cult::Types; + +// +// +typedef Cult::Containers::Set WarningSet; + +// +// +typedef Cult::Containers::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_; + Boolean canceled_; +}; + +// +// +struct AutoUnlinks +{ + Void + add (XSDFrontend::SemanticGraph::Path const& file) + { + unlinks_.push_back (Evptr (new AutoUnlink (file))); + } + + Void + cancel () + { + for (Unlinks::Iterator i (unlinks_.begin ()); i != unlinks_.end (); ++i) + { + (*i)->cancel (); + } + } + +private: + typedef Cult::Containers::Vector > Unlinks; + Unlinks unlinks_; +}; + +#endif // XSD_HXX -- cgit v1.1