umbrello: umbrello/petalnode.h Source File

umbrello 2.31.1 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

petalnode.h
Go to the documentation of this file.
1 /***************************************************************************
2 * This program is free software; you can redistribute it and/or modify *
3 * it under the terms of the GNU General Public License as published by *
4 * the Free Software Foundation; either version 2 of the License, or *
5 * (at your option) any later version. *
6 * *
7 * copyright (C) 2006-2020 *
8 * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9 ***************************************************************************/
10
11 #ifndef PETALNODE__H
12 #define PETALNODE__H
13
14 #include <QList>
15 #include <QPair>
16 #include <QString>
17 #include <QStringList>
18
39 class PetalNode
40 {
41 public:
48 struct StringOrNode {
49 QString string;
50 PetalNode *node;
51 StringOrNode() { node = 0; }
52 virtual ~StringOrNode() { }
53 bool isEmpty() { return (string.isEmpty() && node == 0); }
54 };
55 typedef QPair<QString, StringOrNode> NameValue;
56 typedef QList<NameValue> NameValueList;
57
58 enum NodeType { nt_object, nt_list };
59
60 explicit PetalNode(NodeType nt);
61 virtual ~PetalNode();
62
63 // getters
64 NodeType type() const;
65 QStringList initialArgs() const; // name and other initial args
66 QString name() const; // convenience function: equal to initialArgs().first()
67 QString documentation() const;
68 NameValueList attributes() const;
69
70 // setters
71 //void setType(NodeType nt); see constructor
72 void setInitialArgs(const QStringList& args);
73 void setAttributes(NameValueList vl);
74
75 // utilities
76 StringOrNode findAttribute(const QString& name) const;
77
78 private:
79 NodeType m_type;
80 QStringList m_initialArgs;
81 NameValueList m_attributes;
82
83 friend QDebug operator<<(QDebug out, const PetalNode &p);
84 };
85
86 QDebug operator<<(QDebug out, const PetalNode::StringOrNode &p);
87 QDebug operator<<(QDebug out, const PetalNode::NameValue &p);
88 QDebug operator<<(QDebug out, const PetalNode::NameValueList &p);
89 QDebug operator<<(QDebug out, const PetalNode &p);
90 #endif
91
PetalNode::name
QString name() const
Definition: petalnode.cpp:93
PetalNode::setInitialArgs
void setInitialArgs(const QStringList &args)
Definition: petalnode.cpp:129
PetalNode::PetalNode
PetalNode(NodeType nt)
Definition: petalnode.cpp:74
PetalNode::findAttribute
StringOrNode findAttribute(const QString &name) const
Definition: petalnode.cpp:144
petalnode.h
PetalNode::m_initialArgs
QStringList m_initialArgs
Definition: petalnode.h:88
PetalNode::~PetalNode
virtual ~PetalNode()
Definition: petalnode.cpp:79
PetalNode::StringOrNode::isEmpty
bool isEmpty()
Definition: petalnode.h:69
PetalNode
Definition: petalnode.h:40
operator<<
QDebug operator<<(QDebug _out, const PetalNode::StringOrNode &p)
Definition: petalnode.cpp:47
PetalNode::NameValueList
QList< NameValue > NameValueList
Definition: petalnode.h:64
PetalNode::initialArgs
QStringList initialArgs() const
Definition: petalnode.cpp:88
PetalNode::m_type
NodeType m_type
Definition: petalnode.h:87
PetalNode::NodeType
NodeType
Definition: petalnode.h:66
PetalNode::NameValue
QPair< QString, StringOrNode > NameValue
Definition: petalnode.h:63
Indenter
Definition: petalnode.cpp:21
PetalNode::StringOrNode
Definition: petalnode.h:56
a
QString a
Definition: petalnode.cpp:18
PetalNode::documentation
QString documentation() const
Definition: petalnode.cpp:105
PetalNode::StringOrNode::~StringOrNode
virtual ~StringOrNode()
Definition: petalnode.h:68
PetalNode::setAttributes
void setAttributes(NameValueList vl)
Definition: petalnode.cpp:134
PetalNode::nt_object
@ nt_object
Definition: petalnode.h:66
PetalNode::m_attributes
NameValueList m_attributes
Definition: petalnode.h:89
Indenter::level
static int level
Definition: petalnode.cpp:42
PetalNode::type
NodeType type() const
Definition: petalnode.cpp:83
Indenter::~Indenter
~Indenter()
Definition: petalnode.cpp:33
PetalNode::attributes
NameValueList attributes() const
Definition: petalnode.cpp:117
Indenter::Indenter
Indenter(QDebug &out, const char *className)
Definition: petalnode.cpp:23
PetalNode::nt_list
@ nt_list
Definition: petalnode.h:66
debug_utils.h
PetalNode::StringOrNode::string
QString string
Definition: petalnode.h:65
PetalNode::StringOrNode::node
PetalNode * node
Definition: petalnode.h:66
operator<<
QDebug operator<<(QDebug out, const PetalNode::StringOrNode &p)
Definition: petalnode.cpp:47
PetalNode::operator<<
friend QDebug operator<<(QDebug out, const PetalNode &p)
Definition: petalnode.cpp:153
PetalNode::StringOrNode::StringOrNode
StringOrNode()
Definition: petalnode.h:67