herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
Utilities
XML
ElementIO.h
1
// -*- C++ -*-
2
//
3
// ElementIO.hpp is a part of myXML
4
// Copyright (C) 2012-2019 Simon Platzer, The Herwig Collaboration
5
//
6
// myXML is licenced under version 3 of the GPL, see COPYING for details.
7
//
8
9
#ifndef MYXML_ElementIO_hpp_included
10
#define MYXML_ElementIO_hpp_included
11
12
#include <iostream>
13
14
#include "Element.h"
15
16
namespace
XML {
17
22
class
ElementIO
{
23
24
public
:
25
29
template
<
class
OStream>
30
static
void
put
(
Element
, OStream&);
31
35
static
Element
get
(std::istream&);
36
40
static
Element
getAll
(std::istream&);
41
42
private
:
43
47
static
void
strip
(std::string&,
const
std::string&
skip
=
"\n\t "
);
48
52
static
std::istream&
getline
(std::istream&, std::string&,
const
std::string&);
53
57
static
void
skip
(std::istream&,
const
std::string& skip_chars =
"\n\t "
);
58
62
struct
Tag
{
63
67
enum
EnumerateTagTypes
{
68
69
Unknown = -1,
71
EmptyElement
= 1,
73
ElementBegin
= 2,
75
ProcessingInstruction
= 3,
77
CharacterData
= 4,
79
ParsedCharacterData
= 5,
81
Comment
= 6,
83
ElementEnd
= 20
85
};
86
90
int
type
;
91
95
std::string
content
;
96
100
std::map<std::string,std::string>
attributes
;
101
105
Element
produce
()
const
;
106
107
};
108
112
static
void
getTag
(
Tag
&, std::istream&);
113
117
static
Element
produce
(std::list<Tag>&);
118
122
static
void
produce
(std::list<Tag>&,
Element
&);
123
127
static
void
unexpectedEOF
(
const
std::string& what =
""
);
128
132
static
void
parseError
(
const
std::string& what =
""
);
133
134
};
135
136
}
137
138
#include "ElementIO.tcc"
139
140
#endif
// MYXML_ElementIO_hpp_included
XML::ElementIO
ElementIO handles in/output of XML elements.
Definition:
ElementIO.h:22
XML::ElementIO::produce
static void produce(std::list< Tag > &, Element &)
Produce element tree from parsed stack of tags.
XML::ElementIO::getTag
static void getTag(Tag &, std::istream &)
Get a single tag or parsed content from an istream.
XML::ElementIO::getAll
static Element getAll(std::istream &)
Parse the entire stream.
XML::ElementIO::unexpectedEOF
static void unexpectedEOF(const std::string &what="")
Throw an unexpected end of file exception.
XML::ElementIO::put
static void put(Element, OStream &)
Write a tree to an ostream.
XML::ElementIO::strip
static void strip(std::string &, const std::string &skip="\n\t ")
Strip whitespaces from a string.
XML::ElementIO::getline
static std::istream & getline(std::istream &, std::string &, const std::string &)
Read from istream until occurence of the given pattern.
XML::ElementIO::parseError
static void parseError(const std::string &what="")
Throw a parse error exception.
XML::ElementIO::skip
static void skip(std::istream &, const std::string &skip_chars="\n\t ")
Skip charecters encountered on the given istream.
XML::ElementIO::get
static Element get(std::istream &)
Get the next element from a stream.
XML::ElementIO::produce
static Element produce(std::list< Tag > &)
Produce element tree from parsed stack of tags.
XML::Element
Element represents a (tree of) XML elements.
Definition:
Element.h:56
XML::ElementIO::Tag
Helper struct representing a single tag or parsed content.
Definition:
ElementIO.h:62
XML::ElementIO::Tag::content
std::string content
The content or name of the tag.
Definition:
ElementIO.h:95
XML::ElementIO::Tag::EnumerateTagTypes
EnumerateTagTypes
The tag type enumeration.
Definition:
ElementIO.h:67
XML::ElementIO::Tag::CharacterData
@ CharacterData
A processing instruction tag.
Definition:
ElementIO.h:77
XML::ElementIO::Tag::ElementEnd
@ ElementEnd
A comment tag.
Definition:
ElementIO.h:83
XML::ElementIO::Tag::ParsedCharacterData
@ ParsedCharacterData
Character data tag.
Definition:
ElementIO.h:79
XML::ElementIO::Tag::ElementBegin
@ ElementBegin
An empty element tag.
Definition:
ElementIO.h:73
XML::ElementIO::Tag::Comment
@ Comment
Parsed character data.
Definition:
ElementIO.h:81
XML::ElementIO::Tag::EmptyElement
@ EmptyElement
Tag type unknown.
Definition:
ElementIO.h:71
XML::ElementIO::Tag::ProcessingInstruction
@ ProcessingInstruction
An element begin tag.
Definition:
ElementIO.h:75
XML::ElementIO::Tag::produce
Element produce() const
Produce an element.
XML::ElementIO::Tag::type
int type
The type of the tag.
Definition:
ElementIO.h:90
XML::ElementIO::Tag::attributes
std::map< std::string, std::string > attributes
A lis of attributes, if present.
Definition:
ElementIO.h:100
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6