Skip to content

Commit

Permalink
Require C++17, port from deprecated qAsConst to std::as_const
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaure-kdab committed Jul 18, 2024
1 parent 425ff91 commit 5f20596
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Default=false (Qt5 will be used even if Qt6 is available)

cmake_minimum_required(VERSION 3.11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(libkode)
Expand Down
2 changes: 1 addition & 1 deletion code_generation/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ Enum::List Class::enums() const

bool Class::hasEnum(const QString &name) const
{
for (const Enum &e : qAsConst(d->mEnums)) {
for (const Enum &e : std::as_const(d->mEnums)) {
if (e.name() == name)
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion code_generation/printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void Printer::printHeader(const File &file)
if (cl.useSharedData())
includes.append(Include("QtCore/QSharedData"));
// qDebug() << "includes=" << includes;
for (auto include : qAsConst(includes)) {
for (auto include : std::as_const(includes)) {
if (!processedIncludes.contains(include)) {
if (include.type == Include::Relative)
out += "#include \"" + include.includeFileName + '"';
Expand Down
2 changes: 1 addition & 1 deletion schema/complextype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ bool ComplexType::operator==(const ComplexType &other) const
ComplexType ComplexTypeList::complexType(const QName &qualifiedName) const
{
// qDebug() << "looking for" << typeName << "ns=" << typeName.nameSpace();
for (const ComplexType &type : qAsConst(*this)) {
for (const ComplexType &type : std::as_const(*this)) {
// qDebug() << type.nameSpace() << "qualifiedName=" << type.qualifiedName();
if (qualifiedName == type.qualifiedName()) {
return type;
Expand Down
16 changes: 8 additions & 8 deletions schema/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ ComplexType Parser::parseComplexType(ParserContext *context, const QDomElement &
|| name.localName() == QLatin1String("choice")) {
Element::List elems;
parseCompositor(context, childElement, newType.nameSpace(), &elems, &groups);
for (const Element &elem : qAsConst(elems)) {
for (const Element &elem : std::as_const(elems)) {
newType.addElement(elem);
}
} else if (name.localName() == QLatin1String("attribute")) {
Expand Down Expand Up @@ -909,10 +909,10 @@ void Parser::parseComplexContent(ParserContext *context, const QDomElement &elem
Group::List groups;
parseCompositor(context, ctElement, complexType.nameSpace(), &elems,
&groups);
for (const Element &elem : qAsConst(elems)) {
for (const Element &elem : std::as_const(elems)) {
complexType.addElement(elem);
}
for (const Group &group : qAsConst(groups)) {
for (const Group &group : std::as_const(groups)) {
complexType.addGroup(group);
}
} else if (name.localName() == QLatin1String("attribute")) {
Expand Down Expand Up @@ -1222,7 +1222,7 @@ QString Parser::schemaUri()

Element Parser::findElement(const QName &name) const
{
for (const Element &e : qAsConst(d->mElements)) {
for (const Element &e : std::as_const(d->mElements)) {
if (e.nameSpace() == name.nameSpace() && e.name() == name.localName()) {
return e;
}
Expand All @@ -1233,7 +1233,7 @@ Element Parser::findElement(const QName &name) const

Group Parser::findGroup(const QName &name) const
{
for (const Group &g : qAsConst(d->mGroups)) {
for (const Group &g : std::as_const(d->mGroups)) {
if (g.nameSpace() == name.nameSpace() && g.name() == name.localName()) {
return g;
}
Expand All @@ -1244,7 +1244,7 @@ Group Parser::findGroup(const QName &name) const

Attribute Parser::findAttribute(const QName &name) const
{
for (const Attribute &attr : qAsConst(d->mAttributes)) {
for (const Attribute &attr : std::as_const(d->mAttributes)) {
if (attr.nameSpace() == name.nameSpace() && attr.name() == name.localName()) {
return attr;
}
Expand All @@ -1255,7 +1255,7 @@ Attribute Parser::findAttribute(const QName &name) const

AttributeGroup Parser::findAttributeGroup(const QName &name) const
{
for (const AttributeGroup &g : qAsConst(d->mAttributeGroups)) {
for (const AttributeGroup &g : std::as_const(d->mAttributeGroups)) {
if (g.nameSpace() == name.nameSpace() && g.name() == name.localName()) {
return g;
}
Expand Down Expand Up @@ -1363,7 +1363,7 @@ bool Parser::resolveForwardDeclarations()
Q_ASSERT(!group.reference().isEmpty());
AttributeGroup refAttributeGroup = findAttributeGroup(group.reference());
Attribute::List groupAttributes = refAttributeGroup.attributes();
for (const Attribute &ga : qAsConst(groupAttributes)) {
for (const Attribute &ga : std::as_const(groupAttributes)) {
attributes.append(ga);
}
}
Expand Down
2 changes: 1 addition & 1 deletion schema/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ SimpleType Types::simpleType(const QName &simpleTypeName, const QString &element
if (elementFilter.isEmpty())
return d->mSimpleTypes.simpleType(simpleTypeName);

for (auto type : qAsConst(d->mSimpleTypes)) {
for (auto type : std::as_const(d->mSimpleTypes)) {
if (type.qualifiedName() == simpleTypeName && elementFilter == type.elementName())
return type;
}
Expand Down

0 comments on commit 5f20596

Please sign in to comment.