9 #include "typehelper.h"
11 Node::Node(NodeType type,
Node *parent)
22 qDeleteAll(mChildren);
30 Node *Node::parent()
const
35 void Node::appendNode(
Node *child)
37 child->mParent =
this;
38 mChildren.push_back(child);
46 DocumentNode::DocumentNode(
int version)
52 int DocumentNode::version()
const
57 ClassNode::ClassNode(
const QString &name, ClassType type, DocumentNode *parent)
69 ClassNode::ClassType ClassNode::classType()
const
74 QString ClassNode::className()
const
80 return mName + QStringLiteral(
"Command");
82 return mName + QStringLiteral(
"Response");
84 return mName + QStringLiteral(
"Notification");
91 QString ClassNode::parentClassName()
const
97 return QStringLiteral(
"Command");
99 return QStringLiteral(
"Response");
101 return QStringLiteral(
"ChangeNotification");
109 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
110 ClassNode::ClassType ClassNode::elementNameToType(
const QStringRef &name)
112 ClassNode::ClassType ClassNode::elementNameToType(
QStringView name)
131 for (
const auto node : std::as_const(mChildren)) {
132 if (node->type() == Node::Property) {
133 rv << static_cast<PropertyNode const *>(node);
136 CppHelper::sortMembers(rv);
146 CtorNode::~CtorNode()
155 void CtorNode::setArgumentType(
const QString &name,
const QString &type)
157 for (
auto &arg : mArgs) {
158 if (arg.name == name) {
165 EnumNode::EnumNode(
const QString &name, EnumType type, ClassNode *parent)
177 EnumNode::EnumType EnumNode::enumType()
const
181 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
182 EnumNode::EnumType EnumNode::elementNameToType(
const QStringRef &name)
184 EnumNode::EnumType EnumNode::elementNameToType(
QStringView name)
196 EnumValueNode::EnumValueNode(
const QString &name, EnumNode *parent)
197 :
Node(EnumValue, parent)
203 QString EnumValueNode::name()
const
208 void EnumValueNode::setValue(
const QString &value)
213 QString EnumValueNode::value()
const
218 PropertyNode::PropertyNode(
const QString &name,
const QString &type, ClassNode *parent)
224 , mAsReference(false)
228 PropertyNode::~PropertyNode()
233 QString PropertyNode::type()
const
238 QString PropertyNode::name()
const
243 void PropertyNode::setDefaultValue(
const QString &defaultValue)
245 mDefaultValue = defaultValue;
248 QString PropertyNode::defaultValue()
const
250 return mDefaultValue;
253 bool PropertyNode::readOnly()
const
258 void PropertyNode::setReadOnly(
bool readOnly)
260 mReadOnly = readOnly;
263 bool PropertyNode::asReference()
const
268 void PropertyNode::setAsReference(
bool asReference)
270 mAsReference = asReference;
273 bool PropertyNode::isPointer()
const
275 return TypeHelper::isPointerType(mType);
283 void PropertyNode::addDependency(
const QString &enumVar,
const QString &enumValue)
285 mDepends.
insert(enumVar, enumValue);
288 void PropertyNode::setSetter(Setter *setter)
293 PropertyNode::Setter *PropertyNode::setter()
const
298 QString PropertyNode::mVariableName()
const
303 QString PropertyNode::setterName()
const