Project

General

Profile

Statistics
| Branch: | Revision:

root / src / nedxml / nedsaxhandler.h @ 79bb12dc

History | View | Annotate | Download (2.11 KB)

1
//==========================================================================
2
//  NEDSAXHANDLER.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
#ifndef __NEDSAXHANDLER_H
18
#define __NEDSAXHANDLER_H
19

    
20

    
21
#include "nedelement.h"
22
#include "nederror.h"
23
#include "saxparser.h"
24

    
25
NAMESPACE_BEGIN
26

    
27

    
28
/**
29
 * SAX handler (to be used with SAXParser) that builds a NED object tree.
30
 * Elements of the tree are subclassed from NEDElement;
31
 * NEDElementFactory is used to actually create the objects.
32
 *
33
 * Usage:
34
 * <pre>
35
 *    NEDSAXHandler nedsaxhandler(filename);
36
 *    SAXParser parser;
37
 *
38
 *    parser.setHandler(&nedsaxhandler);
39
 *    parser.parse(filename);
40
 *
41
 *    NEDElement *result = nedsaxhandler.getTree();
42
 * </pre>
43
 *
44
 * @ingroup XMLParser
45
 */
46
class NEDXML_API NEDSAXHandler : public SAXHandler
47
{
48
    NEDElement *root;
49
    NEDElement *current;
50
    const char *sourcefilename;
51
    NEDErrorStore *errors;
52

    
53
  public:
54
    /**
55
     * Constructor. Filename is necessary to create correct src-loc info.
56
     */
57
    NEDSAXHandler(const char *filename, NEDErrorStore *e);
58

    
59
    /**
60
     * Destructor
61
     */
62
    virtual ~NEDSAXHandler();
63

    
64
    /**
65
     * Returns the object tree that was built up during XML parsing.
66
     */
67
    virtual NEDElement *getTree();
68

    
69
    /** @name SAX event handlers */
70
    //@{
71
    virtual void startElement(const char *name, const char **atts);
72
    virtual void endElement(const char *name);
73
    virtual void characterData(const char *s, int len);
74
    virtual void processingInstruction(const char *target, const char *data);
75
    virtual void comment(const char *data);
76
    virtual void startCdataSection();
77
    virtual void endCdataSection();
78
    //@}
79
};
80

    
81
NAMESPACE_END
82

    
83

    
84
#endif
85