16 if (node->
type() == Node::Class) {
17 return static_cast<const ClassNode *
>(node)->className();
19 if (node->
type() == Node::Enum) {
20 auto enumNode =
static_cast<const EnumNode *
>(node);
21 if (enumNode->enumType() == EnumNode::TypeFlag) {
22 return QStringLiteral(
"%1::%2").arg(qualifiedName(node->parent()), enumNode->flagsName());
24 return QStringLiteral(
"%1::%2").arg(qualifiedName(node->parent()), enumNode->name());
27 Q_ASSERT_X(
false,
"qualifiedName",
"Invalid node type");
33Node::Node(NodeType type,
Node *parent)
38 parent->appendNode(
this);
44 qDeleteAll(mChildren);
52Node *Node::parent()
const
57void Node::appendNode(
Node *child)
59 child->mParent =
this;
68DocumentNode::DocumentNode(
int version)
74int DocumentNode::version()
const
79ClassNode::ClassNode(
const QString &name, ClassType type, DocumentNode *parent)
91ClassNode::ClassType ClassNode::classType()
const
96QString ClassNode::className()
const
102 return mName + QStringLiteral(
"Command");
104 return mName + QStringLiteral(
"Response");
106 return mName + QStringLiteral(
"Notification");
113QString ClassNode::parentClassName()
const
115 switch (mClassType) {
119 return QStringLiteral(
"Command");
121 return QStringLiteral(
"Response");
123 return QStringLiteral(
"ChangeNotification");
131ClassNode::ClassType ClassNode::elementNameToType(
QStringView name)
149 for (
const auto node : std::as_const(mChildren)) {
150 if (node->
type() == Node::Property) {
151 rv << static_cast<PropertyNode const *>(node);
154 CppHelper::sortMembers(rv);
173void CtorNode::setArgumentType(
const QString &name,
const QString &type)
175 for (
auto &arg : mArgs) {
176 if (arg.name ==
name) {
183EnumNode::EnumNode(
const QString &name, EnumType type, ClassNode *parent)
195EnumNode::EnumType EnumNode::enumType()
const
200QString EnumNode::flagsName()
const
202 if (mEnumType == TypeFlag) {
203 return mName + QStringLiteral(
"s");
209EnumNode::EnumType EnumNode::elementNameToType(
QStringView name)
220EnumValueNode::EnumValueNode(
const QString &name, EnumNode *parent)
221 :
Node(EnumValue, parent)
227QString EnumValueNode::name()
const
232void EnumValueNode::setValue(
const QString &value)
237QString EnumValueNode::value()
const
242PropertyNode::PropertyNode(
const QString &name,
const QString &type, ClassNode *parent)
248 , mAsReference(false)
252PropertyNode::~PropertyNode()
257QString PropertyNode::type()
const
262QString PropertyNode::name()
const
267void PropertyNode::setDefaultValue(
const QString &defaultValue)
269 mDefaultValue = defaultValue;
272QString PropertyNode::defaultValue()
const
274 return mDefaultValue;
277bool PropertyNode::readOnly()
const
282void PropertyNode::setReadOnly(
bool readOnly)
284 mReadOnly = readOnly;
287bool PropertyNode::asReference()
const
292void PropertyNode::setAsReference(
bool asReference)
294 mAsReference = asReference;
297bool PropertyNode::isPointer()
const
299 return TypeHelper::isPointerType(mType);
302bool PropertyNode::isEnum()
const
304 auto parentClass =
static_cast<ClassNode *
>(parent());
305 for (
const auto node : parentClass->children()) {
306 if (node->
type() == Node::Enum) {
307 const auto enumNode =
static_cast<const EnumNode *
>(node);
308 if (qualifiedName(enumNode) == mType) {
322void PropertyNode::addDependency(
const QString &enumVar,
const QString &enumValue)
324 mDepends.
insert(enumVar, enumValue);
327void PropertyNode::setSetter(Setter *setter)
332PropertyNode::Setter *PropertyNode::setter()
const
337QString PropertyNode::mVariableName()
const
342QString PropertyNode::setterName()
const
virtual QString type() const
KDB_EXPORT KDbVersionInfo version()
QString name(GameStandardAction id)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
void push_back(parameter_type value)
iterator insert(const Key &key, const T &value)
QString toUpper() const const
QStringView mid(qsizetype start, qsizetype length) const const