SUMO - Simulation of Urban MObility
PlainXMLFormatter.h
Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Output formatter for plain XML output
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This file is part of SUMO.
00014 //   SUMO is free software: you can redistribute it and/or modify
00015 //   it under the terms of the GNU General Public License as published by
00016 //   the Free Software Foundation, either version 3 of the License, or
00017 //   (at your option) any later version.
00018 //
00019 /****************************************************************************/
00020 #ifndef PlainXMLFormatter_h
00021 #define PlainXMLFormatter_h
00022 
00023 
00024 // ===========================================================================
00025 // included modules
00026 // ===========================================================================
00027 #ifdef _MSC_VER
00028 #include <windows_config.h>
00029 #else
00030 #include <config.h>
00031 #endif
00032 
00033 #include "OutputFormatter.h"
00034 
00035 
00036 // ===========================================================================
00037 // class definitions
00038 // ===========================================================================
00045 class PlainXMLFormatter : public OutputFormatter {
00046 public:
00048     PlainXMLFormatter(const unsigned int defaultIndentation=0);
00049 
00050 
00052     virtual ~PlainXMLFormatter() { }
00053 
00054 
00068     bool writeXMLHeader(std::ostream& into, const std::string& rootElement,
00069                         const std::string xmlParams = "",
00070                         const std::string& attrs = "",
00071                         const std::string& comment = "");
00072 
00073 
00084     void openTag(std::ostream& into, const std::string& xmlElement);
00085 
00086 
00094     void openTag(std::ostream& into, const SumoXMLTag& xmlElement);
00095 
00096 
00103     void closeOpener(std::ostream& into);
00104 
00105 
00113     bool closeTag(std::ostream& into, bool abbreviated=false);
00114 
00115 
00122     void writeAttr(std::ostream& into, const std::string& attr, const std::string& val);
00123 
00124 
00131     template <class T>
00132     static void writeAttr(std::ostream& into, const SumoXMLAttr attr, const T& val) {
00133         into << " " << toString(attr) << "=\"" << toString(val, into.precision()) << "\"";
00134     }
00135 
00136 
00137 private:
00139     std::vector<std::string> myXMLStack;
00140 
00142     unsigned int myDefaultIndentation;
00143 
00144 
00145 };
00146 
00147 
00148 #endif
00149 
00150 /****************************************************************************/
00151 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines