Statistics
| Branch: | Revision:

root / src / nedxml / xmlgenerator.h @ 68da4f12

History | View | Annotate | Download (2.46 KB)

1
//==========================================================================
2
//  XMLGENERATOR.H - part of
3
//
4
//                     OMNeT++/OMNEST
5
//            Discrete System Simulation in C++
6
//
7
//==========================================================================
8

    
9
/*--------------------------------------------------------------*
10
  Copyright (C) 2002-2008 Andras Varga
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

13
  This file is distributed WITHOUT ANY WARRANTY. See the file
14
  `license' for details on this and other legal matters.
15
*--------------------------------------------------------------*/
16

    
17

    
18
#ifndef __XMLGENERATOR_H
19
#define __XMLGENERATOR_H
20

    
21

    
22
#include <iostream>
23
#include "nedelements.h"
24

    
25
NAMESPACE_BEGIN
26

    
27
/**
28
 * Simple front-end to NEDXMLGenerator.
29
 *
30
 * @ingroup XMLGenerator
31
 */
32
NEDXML_API void generateXML(std::ostream& out, NEDElement *tree, bool srcloc, int indentsize = 4);
33

    
34
/**
35
 * Simple front-end to NEDXMLGenerator.
36
 *
37
 * @ingroup XMLGenerator
38
 */
39
NEDXML_API std::string generateXML(NEDElement *tree, bool srcloc, int indentsize = 4);
40

    
41
/**
42
 * Serializes a NED object tree in XML format.
43
 *
44
 * @ingroup XMLGenerator
45
 */
46
class NEDXML_API NEDXMLGenerator
47
{
48
  protected:
49
    bool printsrcloc;
50
    int indentsize;
51
    virtual void printAttrValue(std::ostream& out, const char *s);
52
    virtual void doGenerate(std::ostream& out, NEDElement *node, int level);
53

    
54
  public:
55
    /**
56
     * Constructor
57
     */
58
    NEDXMLGenerator();
59

    
60
    /**
61
     * Destructor
62
     */
63
    virtual ~NEDXMLGenerator();
64

    
65
    /**
66
     * Enable or disable generation of src-loc attributes in the output XML.
67
     * src-loc attributes contain filename-line-column information that refers
68
     * to the original document. For example, if the NEDElement tree was
69
     * produced by parsing a NED file, src-loc attributes refer to locations
70
     * in the NED file.
71
     */
72
    virtual void setSourceLocationAttributes(bool srcloc);
73

    
74
    /**
75
     * Set indent size in the output XML.
76
     */
77
    virtual void setIndentSize(int indentsize);
78

    
79
    /**
80
     * Serialize the object tree as XML to the given output stream.
81
     * The XML declaration will be:
82
     * <pre>
83
     * <?xml version="1.0"?>
84
     * </pre>
85
     * I.e. unspecified encoding, and no document type will be included.
86
     */
87
    virtual void generate(std::ostream& out, NEDElement *tree);
88

    
89
    /**
90
     * Serialize the object tree into XML, and return the result as string.
91
     */
92
    virtual std::string generate(NEDElement *tree);
93

    
94
};
95

    
96
NAMESPACE_END
97

    
98

    
99
#endif