umbrello 2.32.3 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 SPDX-License-Identifier: GPL-2.0-or-later
3 SPDX-FileCopyrightText: 2006-2020 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
4*/
5
6#ifndef PETALNODE__H
7#define PETALNODE__H
8
9#include <QList>
10#include <QPair>
11#include <QString>
12#include <QStringList>
13
34 class PetalNode
35{
36 public:
43 struct StringOrNode {
44 QString string;
45 PetalNode *node;
46 StringOrNode() { node = 0; }
47 virtual ~StringOrNode() { }
48 bool isEmpty() { return (string.isEmpty() && node == 0); }
49 };
50 typedef QPair<QString, StringOrNode> NameValue;
51 typedef QList<NameValue> NameValueList;
52
53 enum NodeType { nt_object, nt_list };
54
55 explicit PetalNode(NodeType nt);
56 virtual ~PetalNode();
57
58 // getters
59 NodeType type() const;
60 QStringList initialArgs() const; // name and other initial args
61 QString name() const; // convenience function: equal to initialArgs().first()
62 QString documentation() const;
63 NameValueList attributes() const;
64
65 // setters
66 //void setType(NodeType nt); see constructor
67 void setInitialArgs(const QStringList& args);
68 void setAttributes(NameValueList vl);
69
70 // utilities
71 StringOrNode findAttribute(const QString& name) const;
72
73 private:
74 NodeType m_type;
75 QStringList m_initialArgs;
76 NameValueList m_attributes;
77
78 friend QDebug operator<<(QDebug out, const PetalNode &p);
79};
80
81QDebug operator<<(QDebug out, const PetalNode::StringOrNode &p);
82QDebug operator<<(QDebug out, const PetalNode::NameValue &p);
83QDebug operator<<(QDebug out, const PetalNode::NameValueList &p);
84QDebug operator<<(QDebug out, const PetalNode &p);
85#endif
86
PetalNode
Definition: petalnode.h:35
PetalNode::operator<<
friend QDebug operator<<(QDebug out, const PetalNode &p)
Definition: petalnode.cpp:148
PetalNode::NameValueList
QList< NameValue > NameValueList
Definition: petalnode.h:51
PetalNode::setInitialArgs
void setInitialArgs(const QStringList &args)
Definition: petalnode.cpp:124
PetalNode::initialArgs
QStringList initialArgs() const
Definition: petalnode.cpp:83
PetalNode::PetalNode
PetalNode(NodeType nt)
Definition: petalnode.cpp:69
PetalNode::m_attributes
NameValueList m_attributes
Definition: petalnode.h:76
PetalNode::documentation
QString documentation() const
Definition: petalnode.cpp:100
PetalNode::name
QString name() const
Definition: petalnode.cpp:88
PetalNode::m_initialArgs
QStringList m_initialArgs
Definition: petalnode.h:75
PetalNode::NameValue
QPair< QString, StringOrNode > NameValue
Definition: petalnode.h:50
PetalNode::~PetalNode
virtual ~PetalNode()
Definition: petalnode.cpp:74
PetalNode::m_type
NodeType m_type
Definition: petalnode.h:74
PetalNode::attributes
NameValueList attributes() const
Definition: petalnode.cpp:112
PetalNode::type
NodeType type() const
Definition: petalnode.cpp:78
PetalNode::NodeType
NodeType
Definition: petalnode.h:53
PetalNode::nt_object
@ nt_object
Definition: petalnode.h:53
PetalNode::nt_list
@ nt_list
Definition: petalnode.h:53
PetalNode::setAttributes
void setAttributes(NameValueList vl)
Definition: petalnode.cpp:129
PetalNode::findAttribute
StringOrNode findAttribute(const QString &name) const
Definition: petalnode.cpp:139
operator<<
QDebug operator<<(QDebug out, const PetalNode::StringOrNode &p)
Definition: petalnode.cpp:42
PetalNode::StringOrNode
Definition: petalnode.h:43
PetalNode::StringOrNode::~StringOrNode
virtual ~StringOrNode()
Definition: petalnode.h:47
PetalNode::StringOrNode::string
QString string
Definition: petalnode.h:44
PetalNode::StringOrNode::node
PetalNode * node
Definition: petalnode.h:45
PetalNode::StringOrNode::StringOrNode
StringOrNode()
Definition: petalnode.h:46
PetalNode::StringOrNode::isEmpty
bool isEmpty()
Definition: petalnode.h:48