Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Herwig/Utilities/XML/ElementIO.tcc is written in an unsupported language. File is not indexed.

0001 // -*- C++ -*-
0002 //
0003 // ElementIO.tpp is a part of myXML
0004 // Copyright (C) 2012-2019 Simon Platzer, The Herwig Collaboration
0005 //
0006 // myXML is licenced under version 3 of the GPL, see COPYING for details.
0007 //
0008 
0009 namespace XML {
0010 
0011   template<class OStream>
0012   void ElementIO::put(Element e, OStream& os) {
0013 
0014     if ( e.type() == ElementTypes::Unknown )
0015       return;
0016 
0017     if ( e.type() != ElementTypes::Root ) {
0018 
0019       if ( e.type() == ElementTypes::Element ||
0020            e.type() == ElementTypes::EmptyElement ) {
0021         os << "<" << e.name();
0022         for ( std::map<std::string,std::string>::const_iterator a =
0023                 e.attributes().begin(); a != e.attributes().end(); ++a ) {
0024           os << " " << a->first << "=";
0025           std::string delim = "\"";
0026           if (a->second.find_first_of(delim) != std::string::npos)
0027             delim = "'";
0028           os << delim << a->second << delim;
0029         }
0030         if ( e.type() == ElementTypes::Element ) {
0031           os << ">\n";
0032         }
0033         if ( e.type() == ElementTypes::EmptyElement ) {
0034           os << "/>\n";
0035         }
0036       }
0037 
0038       if ( e.type() == ElementTypes::ProcessingInstruction ) {
0039         os << "<?" << e.content() << "?>\n";
0040       }
0041 
0042       if ( e.type() == ElementTypes::CharacterData ) {
0043         os << "<![CDATA[" << e.content() << "]]>\n";
0044       }
0045 
0046       if ( e.type() == ElementTypes::ParsedCharacterData ) {
0047         os << e.content() << "\n";
0048       }
0049 
0050       if ( e.type() == ElementTypes::Comment ) {
0051         os << "<!--" << e.content() << "-->\n";
0052       }
0053 
0054     }
0055 
0056     if ( e.hasChildren() ) {
0057       for ( std::list<Element>::const_iterator c = e.children().begin();
0058             c != e.children().end(); ++c )
0059         put(*c,os);
0060     }
0061 
0062     if ( e.type() == ElementTypes::Element ) {
0063       os << "</" << e.name() << ">\n";
0064     }
0065 
0066   }
0067 
0068 }