Project

General

Profile

Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (4.93 KB)

1 01873262 Georg Kunz
//==========================================================================
2
// nedsyntaxvalidator.h -
3
//
4
//                     OMNeT++/OMNEST
5
//            Discrete System Simulation in C++
6
//
7
// Contents:
8
//   class NEDSyntaxValidator
9
//
10
//==========================================================================
11
12
/*--------------------------------------------------------------*
13
  Copyright (C) 2002-2008 Andras Varga
14
  Copyright (C) 2006-2008 OpenSim Ltd.
15

16
  This file is distributed WITHOUT ANY WARRANTY. See the file
17
  `license' for details on this and other legal matters.
18
*--------------------------------------------------------------*/
19
20
21
#ifndef __NEDSYNTAXVALIDATOR_H
22
#define __NEDSYNTAXVALIDATOR_H
23
24
#include "nedvalidator.h"
25
26
NAMESPACE_BEGIN
27
28
29
/**
30
 * Performs structural validation of components. Assumes the tree already
31
 * passed DTD validation. Every compound module and other component is
32
 * viewed in isolation: syntax validation does NOT process imports or
33
 * examines validity of references to other module types, channel types, etc.
34
 *
35
 * @ingroup Validation
36
 */
37
class NEDXML_API NEDSyntaxValidator : public NEDValidatorBase
38
{
39
  protected:
40
    bool parsedExpressions;
41
42
    // internal helpers: verify attributes
43
    void checkExpressionAttributes(NEDElement *node, const char *attrs[], bool optional[], int n);
44
    void checkDottedNameAttribute(NEDElement *node, const char *attr, bool wildcardsAllowed);
45
46
    // helper: whether the given node is inside the BODY of a submodule decl or a connection's channelspec
47
    bool isWithinSubcomponent(NEDElement *node);
48
49
    // whether the given node is inside an inner type
50
    bool isWithinInnerType(NEDElement *node);
51
52
  public:
53
    /**
54
     * Constructor. Bool argument specifies if the validator should expect
55
     * parsed or unparsed expressions in the tree (This affects the validation
56
     * process.)
57
     */
58
    NEDSyntaxValidator(bool parsedExpr, NEDErrorStore *e)
59
        : NEDValidatorBase(e) {parsedExpressions=parsedExpr;}
60
61
    /**
62
     * Destructor.
63
     */
64
    virtual ~NEDSyntaxValidator() {}
65
66
  protected:
67
    /** @name Validator methods */
68
    //@{
69
    virtual void validateElement(FilesElement *node);
70
    virtual void validateElement(NedFileElement *node);
71
    virtual void validateElement(CommentElement *node);
72
    virtual void validateElement(PackageElement *node);
73
    virtual void validateElement(ImportElement *node);
74
    virtual void validateElement(PropertyDeclElement *node);
75
    virtual void validateElement(ExtendsElement *node);
76
    virtual void validateElement(InterfaceNameElement *node);
77
    virtual void validateElement(SimpleModuleElement *node);
78
    virtual void validateElement(ModuleInterfaceElement *node);
79
    virtual void validateElement(CompoundModuleElement *node);
80
    virtual void validateElement(ChannelInterfaceElement *node);
81
    virtual void validateElement(ChannelElement *node);
82
    virtual void validateElement(ParametersElement *node);
83
    virtual void validateElement(ParamElement *node);
84
    virtual void validateElement(PropertyElement *node);
85
    virtual void validateElement(PropertyKeyElement *node);
86
    virtual void validateElement(GatesElement *node);
87
    virtual void validateElement(GateElement *node);
88
    virtual void validateElement(TypesElement *node);
89
    virtual void validateElement(SubmodulesElement *node);
90
    virtual void validateElement(SubmoduleElement *node);
91
    virtual void validateElement(ConnectionsElement *node);
92
    virtual void validateElement(ConnectionElement *node);
93
    virtual void validateElement(ChannelSpecElement *node);
94
    virtual void validateElement(ConnectionGroupElement *node);
95
    virtual void validateElement(LoopElement *node);
96
    virtual void validateElement(ConditionElement *node);
97
    virtual void validateElement(ExpressionElement *node);
98
    virtual void validateElement(OperatorElement *node);
99
    virtual void validateElement(FunctionElement *node);
100
    virtual void validateElement(IdentElement *node);
101
    virtual void validateElement(LiteralElement *node);
102
    virtual void validateElement(MsgFileElement *node);
103
    virtual void validateElement(NamespaceElement *node);
104
    virtual void validateElement(CplusplusElement *node);
105
    virtual void validateElement(StructDeclElement *node);
106
    virtual void validateElement(ClassDeclElement *node);
107
    virtual void validateElement(MessageDeclElement *node);
108
    virtual void validateElement(PacketDeclElement *node);
109
    virtual void validateElement(EnumDeclElement *node);
110
    virtual void validateElement(EnumElement *node);
111
    virtual void validateElement(EnumFieldsElement *node);
112
    virtual void validateElement(EnumFieldElement *node);
113
    virtual void validateElement(MessageElement *node);
114
    virtual void validateElement(PacketElement *node);
115
    virtual void validateElement(ClassElement *node);
116
    virtual void validateElement(StructElement *node);
117
    virtual void validateElement(FieldElement *node);
118
    virtual void validateElement(UnknownElement *node);
119
    //@}
120
};
121
122
NAMESPACE_END
123
124
125
#endif