Project

General

Profile

Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.35 KB)

1 01873262 Georg Kunz
//==========================================================================
2
// nedutil.h - part of
3
//
4
//                     OMNeT++/OMNEST
5
//            Discrete System Simulation in C++
6
//
7
// Contents:
8
//   misc util functions
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 __NEDUTIL_H
22
#define __NEDUTIL_H
23
24
#include <string>
25
#include "nedelement.h"
26
27
NAMESPACE_BEGIN
28
29
//FIXME split to several files
30
31
class DisplayString;
32
class PropertyElement;
33
class LiteralElement;
34
35
/**
36
 * Display string conversions.
37
 */
38
class NEDXML_API DisplayStringUtil
39
{
40
  private:
41
    static void parseDisplayString(const char *s, DisplayString& ds);
42
  public:
43
    static std::string upgradeBackgroundDisplayString(const char *s);
44
    static std::string upgradeSubmoduleDisplayString(const char *s);
45
    static std::string upgradeConnectionDisplayString(const char *s);
46
    static std::string toOldBackgroundDisplayString(const char *s);
47
    static std::string toOldSubmoduleDisplayString(const char *s);
48
    static std::string toOldConnectionDisplayString(const char *s);
49
};
50
51
class NEDXML_API NEDElementUtil
52
{
53
  public:
54
    /** @name Utilities for accessing properties */
55
    //@{
56
    static const char *getLocalStringProperty(NEDElement *parent, const char *name);
57
    static bool getLocalBoolProperty(NEDElement *parent, const char *name);
58
    static PropertyElement *getLocalProperty(NEDElement *parent, const char *name);
59
    static LiteralElement *getTheOnlyValueFrom(PropertyElement *property);
60
    static bool propertyAsBool(PropertyElement *property);
61
    static const char *propertyAsString(PropertyElement *property);
62
    //@}
63
64
    /** @name Comparison */
65
    //@{
66
    /** Compares tagname and declared attrs (ignores id, srcloc, srcregion, etc) */
67
    static int compare(NEDElement *node1, NEDElement *node2);
68
    /** Recursive version of compare() */
69
    static int compareTree(NEDElement *node1, NEDElement *node2);
70
    //@}
71
72
    /** @name Misc */
73
    //@{
74
    static bool isNEDType(NEDElement *node);
75
    //@}
76
};
77
78
NAMESPACE_END
79
80
81
#endif