From 89bdd489b04d07446e56b8dd06aedb02fe725954 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 17 Aug 2023 13:15:08 +0200 Subject: [PATCH] App: modernize C++: return braced init list --- src/App/Application.cpp | 4 ++-- src/App/ComplexGeoDataPyImp.cpp | 2 +- src/App/Document.cpp | 2 +- src/App/DocumentObject.cpp | 2 +- src/App/DocumentObjectExtensionPyImp.cpp | 2 +- src/App/DocumentObjectGroupPyImp.cpp | 2 +- src/App/DocumentObjectPyImp.cpp | 12 ++++++------ src/App/DocumentObserver.cpp | 4 ++-- src/App/DocumentPyImp.cpp | 22 +++++++++++----------- src/App/DynamicProperty.cpp | 2 +- src/App/ElementMap.cpp | 4 ++-- src/App/ElementNamingUtils.cpp | 6 +++--- src/App/Expression.cpp | 10 +++++----- src/App/ExpressionTokenizer.cpp | 4 ++-- src/App/Extension.cpp | 5 +---- src/App/ExtensionContainerPyImp.cpp | 2 +- src/App/ExtensionPyImp.cpp | 2 +- src/App/FeaturePython.cpp | 2 +- src/App/GeoFeatureGroupExtension.cpp | 6 +++--- src/App/GeoFeatureGroupExtensionPyImp.cpp | 3 +-- src/App/GeoFeaturePyImp.cpp | 2 +- src/App/Graphviz.cpp | 2 +- src/App/GroupExtensionPyImp.cpp | 2 +- src/App/MaterialPyImp.cpp | 2 +- src/App/ObjectIdentifier.cpp | 6 +++--- src/App/OriginGroupExtensionPyImp.cpp | 2 +- src/App/PartPyImp.cpp | 2 +- src/App/PropertyContainer.h | 2 +- src/App/PropertyContainerPyImp.cpp | 2 +- src/App/PropertyExpressionEngine.cpp | 2 +- src/App/PropertyGeo.h | 2 +- src/App/PropertyLinks.cpp | 12 ++++++------ src/App/StringHasherPyImp.cpp | 2 +- src/App/StringIDPyImp.cpp | 6 +++--- 34 files changed, 70 insertions(+), 74 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 1aeed367dd..fcb1c7e948 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -593,7 +593,7 @@ std::vector Application::getDocuments() const std::string Application::getUniqueDocumentName(const char *Name, bool tempDoc) const { if (!Name || *Name == '\0') - return std::string(); + return {}; std::string CleanName = Base::Tools::getIdentifier(Name); // name in use? @@ -3160,7 +3160,7 @@ std::tuple getCustomPaths() userTemp = fi.absoluteFilePath(); } - return std::tuple(userHome, userData, userTemp); + return {userHome, userData, userTemp}; } /*! diff --git a/src/App/ComplexGeoDataPyImp.cpp b/src/App/ComplexGeoDataPyImp.cpp index 4b80e0f1e6..e6c9fe69a5 100644 --- a/src/App/ComplexGeoDataPyImp.cpp +++ b/src/App/ComplexGeoDataPyImp.cpp @@ -43,7 +43,7 @@ using namespace Base; // returns a string which represent the object e.g. when printed in python std::string ComplexGeoDataPy::representation() const { - return std::string(""); + return {""}; } PyObject* ComplexGeoDataPy::getElementTypes(PyObject *args) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index a35191c045..54b6d79f06 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -3799,7 +3799,7 @@ const char * Document::getObjectName(DocumentObject *pFeat) const std::string Document::getUniqueObjectName(const char *Name) const { if (!Name || *Name == '\0') - return std::string(); + return {}; std::string CleanName = Base::Tools::getIdentifier(Name); // name in use? diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 7229f6bcd6..2d56834e55 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -312,7 +312,7 @@ int DocumentObject::isExporting() const { std::string DocumentObject::getExportName(bool forced) const { if(!pcNameInDocument) - return std::string(); + return {}; if(!forced && !isExporting()) return *pcNameInDocument; diff --git a/src/App/DocumentObjectExtensionPyImp.cpp b/src/App/DocumentObjectExtensionPyImp.cpp index 47bd7e1e2c..a80f1a1603 100644 --- a/src/App/DocumentObjectExtensionPyImp.cpp +++ b/src/App/DocumentObjectExtensionPyImp.cpp @@ -32,7 +32,7 @@ using namespace App; // returns a string which represent the object e.g. when printed in python std::string DocumentObjectExtensionPy::representation() const { - return std::string(""); + return {""}; } PyObject *DocumentObjectExtensionPy::getCustomAttributes(const char* /*attr*/) const diff --git a/src/App/DocumentObjectGroupPyImp.cpp b/src/App/DocumentObjectGroupPyImp.cpp index 15e23c1084..4b4c36565f 100644 --- a/src/App/DocumentObjectGroupPyImp.cpp +++ b/src/App/DocumentObjectGroupPyImp.cpp @@ -34,7 +34,7 @@ using namespace App; // returns a string which represent the object e.g. when printed in python std::string DocumentObjectGroupPy::representation() const { - return std::string(""); + return {""}; } PyObject *DocumentObjectGroupPy::getCustomAttributes(const char* /*attr*/) const diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index 98d24c7131..dee1e06b3b 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -55,12 +55,12 @@ Py::String DocumentObjectPy::getName() const if (!internal) { throw Py::RuntimeError(std::string("This object is currently not part of a document")); } - return Py::String(std::string(internal)); + return {std::string(internal)}; } Py::String DocumentObjectPy::getFullName() const { - return Py::String(getDocumentObjectPtr()->getFullName()); + return {getDocumentObjectPtr()->getFullName()}; } Py::Object DocumentObjectPy::getDocument() const @@ -694,7 +694,7 @@ PyObject* DocumentObjectPy::getParent(PyObject *args) Py::Boolean DocumentObjectPy::getMustExecute() const { try { - return Py::Boolean(getDocumentObjectPtr()->mustExecute()?true:false); + return {getDocumentObjectPtr()->mustExecute() ? true : false}; } catch (const Base::Exception& e) { throw Py::RuntimeError(e.what()); @@ -741,7 +741,7 @@ Py::Int DocumentObjectPy::getID() const { } Py::Boolean DocumentObjectPy::getRemoving() const { - return Py::Boolean(getDocumentObjectPtr()->testStatus(ObjectStatus::Remove)); + return {getDocumentObjectPtr()->testStatus(ObjectStatus::Remove)}; } PyObject *DocumentObjectPy::resolve(PyObject *args) @@ -813,11 +813,11 @@ PyObject *DocumentObjectPy::adjustRelativeLinks(PyObject *args) { } Py::String DocumentObjectPy::getOldLabel() const { - return Py::String(getDocumentObjectPtr()->getOldLabel()); + return {getDocumentObjectPtr()->getOldLabel()}; } Py::Boolean DocumentObjectPy::getNoTouch() const { - return Py::Boolean(getDocumentObjectPtr()->testStatus(ObjectStatus::NoTouch)); + return {getDocumentObjectPtr()->testStatus(ObjectStatus::NoTouch)}; } void DocumentObjectPy::setNoTouch(Py::Boolean value) { diff --git a/src/App/DocumentObserver.cpp b/src/App/DocumentObserver.cpp index 87d449e973..e9a7edc3a0 100644 --- a/src/App/DocumentObserver.cpp +++ b/src/App/DocumentObserver.cpp @@ -364,7 +364,7 @@ std::string SubObjectT::getNewElementName() const { std::pair element; auto obj = getObject(); if(!obj) - return std::string(); + return {}; GeoFeature::resolveElement(obj,subname.c_str(),element); return std::move(element.first); } @@ -373,7 +373,7 @@ std::string SubObjectT::getOldElementName(int *index) const { std::pair element; auto obj = getObject(); if(!obj) - return std::string(); + return {}; GeoFeature::resolveElement(obj,subname.c_str(),element); if(!index) return std::move(element.second); diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index a7f0e4f39d..c5da0e6a3f 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -472,7 +472,7 @@ PyObject* DocumentPy::commitTransaction(PyObject * args) } Py::Boolean DocumentPy::getHasPendingTransaction() const { - return Py::Boolean(getDocumentPtr()->hasPendingTransaction()); + return {getDocumentPtr()->hasPendingTransaction()}; } PyObject* DocumentPy::undo(PyObject * args) @@ -780,17 +780,17 @@ Py::String DocumentPy::getDependencyGraph() const { std::stringstream out; getDocumentPtr()->exportGraphviz(out); - return Py::String(out.str()); + return {out.str()}; } Py::String DocumentPy::getName() const { - return Py::String(getDocumentPtr()->getName()); + return {getDocumentPtr()->getName()}; } Py::Boolean DocumentPy::getRecomputesFrozen() const { - return Py::Boolean(getDocumentPtr()->testStatus(Document::Status::SkipRecompute)); + return {getDocumentPtr()->testStatus(Document::Status::SkipRecompute)}; } void DocumentPy::setRecomputesFrozen(Py::Boolean arg) @@ -942,35 +942,35 @@ PyObject *DocumentPy::getDependentDocuments(PyObject *args) { Py::Boolean DocumentPy::getRestoring() const { - return Py::Boolean(getDocumentPtr()->testStatus(Document::Status::Restoring)); + return {getDocumentPtr()->testStatus(Document::Status::Restoring)}; } Py::Boolean DocumentPy::getPartial() const { - return Py::Boolean(getDocumentPtr()->testStatus(Document::Status::PartialDoc)); + return {getDocumentPtr()->testStatus(Document::Status::PartialDoc)}; } Py::Boolean DocumentPy::getImporting() const { - return Py::Boolean(getDocumentPtr()->testStatus(Document::Status::Importing)); + return {getDocumentPtr()->testStatus(Document::Status::Importing)}; } Py::Boolean DocumentPy::getRecomputing() const { - return Py::Boolean(getDocumentPtr()->testStatus(Document::Status::Recomputing)); + return {getDocumentPtr()->testStatus(Document::Status::Recomputing)}; } Py::Boolean DocumentPy::getTransacting() const { - return Py::Boolean(getDocumentPtr()->isPerformingTransaction()); + return {getDocumentPtr()->isPerformingTransaction()}; } Py::String DocumentPy::getOldLabel() const { - return Py::String(getDocumentPtr()->getOldLabel()); + return {getDocumentPtr()->getOldLabel()}; } Py::Boolean DocumentPy::getTemporary() const { - return Py::Boolean(getDocumentPtr()->testStatus(Document::TempDoc)); + return {getDocumentPtr()->testStatus(Document::TempDoc)}; } diff --git a/src/App/DynamicProperty.cpp b/src/App/DynamicProperty.cpp index 7ad6419b33..cc21764ada 100644 --- a/src/App/DynamicProperty.cpp +++ b/src/App/DynamicProperty.cpp @@ -328,7 +328,7 @@ DynamicProperty::PropData DynamicProperty::getDynamicPropertyData(const Property auto it = index.find(const_cast(prop)); if(it != index.end()) return *it; - return PropData(); + return {}; } bool DynamicProperty::changeDynamicProperty(const Property *prop, const char *group, const char *doc) { diff --git a/src/App/ElementMap.cpp b/src/App/ElementMap.cpp index 3be76b9973..d6263dd80e 100644 --- a/src/App/ElementMap.cpp +++ b/src/App/ElementMap.cpp @@ -848,12 +848,12 @@ IndexedName ElementMap::find(const MappedName& name, ElementIDRefs* sids) const MappedName ElementMap::find(const IndexedName& idx, ElementIDRefs* sids) const { if (!idx) { - return MappedName(); + return {}; } auto iter = this->indexedNames.find(idx.getType()); if (iter == this->indexedNames.end()) { - return MappedName(); + return {}; } auto& indices = iter->second; diff --git a/src/App/ElementNamingUtils.cpp b/src/App/ElementNamingUtils.cpp index b972dde726..7a27ba4213 100644 --- a/src/App/ElementNamingUtils.cpp +++ b/src/App/ElementNamingUtils.cpp @@ -12,7 +12,7 @@ const char *Data::isMappedElement(const char *name) { std::string Data::newElementName(const char *name) { if(!name) - return std::string(); + return {}; const char *dot = strrchr(name,'.'); if(!dot || dot==name) return name; @@ -30,7 +30,7 @@ std::string Data::newElementName(const char *name) { std::string Data::oldElementName(const char *name) { if(!name) - return std::string(); + return {}; const char *dot = strrchr(name,'.'); if(!dot || dot==name) return name; @@ -48,7 +48,7 @@ std::string Data::oldElementName(const char *name) { std::string Data::noElementName(const char *name) { if(!name) - return std::string(); + return {}; auto element = findElementName(name); if(element) return std::string(name,element-name); diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index ba136afe46..dccf2c07d0 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -449,12 +449,12 @@ Py::Object pyObjectFromAny(const App::any &value) { App::any pyObjectToAny(Py::Object value, bool check) { if(value.isNone()) - return App::any(); + return {}; PyObject *pyvalue = value.ptr(); if(!check) - return App::any(pyObjectWrap(pyvalue)); + return {pyObjectWrap(pyvalue)}; if (PyObject_TypeCheck(pyvalue, &Base::QuantityPy::Type)) { Base::QuantityPy * qp = static_cast(pyvalue); @@ -1048,7 +1048,7 @@ ExpressionPtr Expression::updateLabelReference( App::DocumentObject *obj, const std::string &ref, const char *newLabel) const { if(ref.size()<=2) - return ExpressionPtr(); + return {}; std::vector labels; for(auto &v : getIdentifiers()) v.first.getDepLabels(labels); @@ -1061,7 +1061,7 @@ ExpressionPtr Expression::updateLabelReference( return ExpressionPtr(expr); } } - return ExpressionPtr(); + return {}; } class ReplaceObjectExpressionVisitor : public ExpressionVisitor { @@ -1097,7 +1097,7 @@ ExpressionPtr Expression::replaceObject(const DocumentObject *parent, const_cast(this)->visit(v); if(v.paths.empty()) - return ExpressionPtr(); + return {}; // Now make a copy and do the actual replacement auto expr = copy(); diff --git a/src/App/ExpressionTokenizer.cpp b/src/App/ExpressionTokenizer.cpp index db311214cf..fde06ce208 100644 --- a/src/App/ExpressionTokenizer.cpp +++ b/src/App/ExpressionTokenizer.cpp @@ -67,7 +67,7 @@ QString ExpressionTokenizer::perform(const QString& prefix, int pos) // No tokens if (tokens.empty()) { - return QString(); + return {}; } prefixEnd = prefix.size(); @@ -114,7 +114,7 @@ QString ExpressionTokenizer::perform(const QString& prefix, int pos) if (!stringing && !prefix.isEmpty() && prefixEnd > 0 && prefixEnd <= prefix.size() && prefix[prefixEnd-1] == QChar(32)) { - return QString(); + return {}; } if (!stringing) { diff --git a/src/App/Extension.cpp b/src/App/Extension.cpp index c3dea0f5e7..4b5cbc61ad 100644 --- a/src/App/Extension.cpp +++ b/src/App/Extension.cpp @@ -115,12 +115,9 @@ std::string Extension::name() const { if (pos != std::string::npos) return temp.substr(pos+1); - else - return std::string(); + return {}; } - - Property* Extension::extensionGetPropertyByName(const char* name) const { return extensionGetPropertyData().getPropertyByName(this, name); diff --git a/src/App/ExtensionContainerPyImp.cpp b/src/App/ExtensionContainerPyImp.cpp index 2ddb0b4cca..3a22b9c906 100644 --- a/src/App/ExtensionContainerPyImp.cpp +++ b/src/App/ExtensionContainerPyImp.cpp @@ -38,7 +38,7 @@ using namespace App; // returns a string which represent the object e.g. when printed in python std::string ExtensionContainerPy::representation() const { - return std::string(""); + return {""}; } int ExtensionContainerPy::initialization() { diff --git a/src/App/ExtensionPyImp.cpp b/src/App/ExtensionPyImp.cpp index 113d8cf427..b57bcb73a2 100644 --- a/src/App/ExtensionPyImp.cpp +++ b/src/App/ExtensionPyImp.cpp @@ -34,7 +34,7 @@ using namespace App; // returns a string which represent the object e.g. when printed in python std::string ExtensionPy::representation() const { - return std::string(""); + return {""}; } PyObject *ExtensionPy::getCustomAttributes(const char* /*attr*/) const diff --git a/src/App/FeaturePython.cpp b/src/App/FeaturePython.cpp index 25c34f1111..2aeddc2651 100644 --- a/src/App/FeaturePython.cpp +++ b/src/App/FeaturePython.cpp @@ -480,7 +480,7 @@ std::string FeaturePythonImp::getViewProviderName() e.ReportException(); } - return std::string(); + return {}; } FeaturePythonImp::ValueT diff --git a/src/App/GeoFeatureGroupExtension.cpp b/src/App/GeoFeatureGroupExtension.cpp index 4ed7683ebd..e884254350 100644 --- a/src/App/GeoFeatureGroupExtension.cpp +++ b/src/App/GeoFeatureGroupExtension.cpp @@ -235,7 +235,7 @@ void GeoFeatureGroupExtension::extensionOnChanged(const Property* p) { std::vector< DocumentObject* > GeoFeatureGroupExtension::getScopedObjectsFromLinks(const DocumentObject* obj, LinkScope scope) { if(!obj) - return std::vector< DocumentObject* >(); + return {}; //we get all linked objects. We can't use outList() as this includes the links from expressions std::vector< App::DocumentObject* > result; @@ -256,7 +256,7 @@ std::vector< DocumentObject* > GeoFeatureGroupExtension::getScopedObjectsFromLin std::vector< DocumentObject* > GeoFeatureGroupExtension::getScopedObjectsFromLink(App::Property* prop, LinkScope scope) { if(!prop) - return std::vector< DocumentObject* >(); + return {}; std::vector< App::DocumentObject* > result; auto link = Base::freecad_dynamic_cast(prop); @@ -321,7 +321,7 @@ void GeoFeatureGroupExtension::getCSInList(const DocumentObject* obj, std::vector< DocumentObject* > GeoFeatureGroupExtension::getCSRelevantLinks(const DocumentObject* obj) { if(!obj) - return std::vector< DocumentObject* >(); + return {}; //get all out links std::vector vec; diff --git a/src/App/GeoFeatureGroupExtensionPyImp.cpp b/src/App/GeoFeatureGroupExtensionPyImp.cpp index 884886af51..6a27200f32 100644 --- a/src/App/GeoFeatureGroupExtensionPyImp.cpp +++ b/src/App/GeoFeatureGroupExtensionPyImp.cpp @@ -33,10 +33,9 @@ using namespace App; // returns a string which represents the object e.g. when printed in python std::string GeoFeatureGroupExtensionPy::representation() const { - return std::string(""); + return {""}; } - PyObject *GeoFeatureGroupExtensionPy::getCustomAttributes(const char* /*attr*/) const { return nullptr; diff --git a/src/App/GeoFeaturePyImp.cpp b/src/App/GeoFeaturePyImp.cpp index 0041db6f1d..ec2af688df 100644 --- a/src/App/GeoFeaturePyImp.cpp +++ b/src/App/GeoFeaturePyImp.cpp @@ -34,7 +34,7 @@ using namespace App; // returns a string which represents the object e.g. when printed in python std::string GeoFeaturePy::representation() const { - return std::string(""); + return {""}; } PyObject* GeoFeaturePy::getPaths(PyObject * /*args*/) diff --git a/src/App/Graphviz.cpp b/src/App/Graphviz.cpp index d98ae95c28..351e41b91f 100644 --- a/src/App/Graphviz.cpp +++ b/src/App/Graphviz.cpp @@ -132,7 +132,7 @@ void Document::exportGraphviz(std::ostream& out) const std::string getId(const ObjectIdentifier & path) { DocumentObject * docObj = path.getDocumentObject(); if (!docObj) - return std::string(); + return {}; return std::string((docObj)->getDocument()->getName()) + "#" + docObj->getNameInDocument() + "." + path.getPropertyName() + path.getSubPathStr(); } diff --git a/src/App/GroupExtensionPyImp.cpp b/src/App/GroupExtensionPyImp.cpp index 62d4aea805..4b89fb7ae3 100644 --- a/src/App/GroupExtensionPyImp.cpp +++ b/src/App/GroupExtensionPyImp.cpp @@ -36,7 +36,7 @@ using namespace App; // returns a string which represent the object e.g. when printed in python std::string GroupExtensionPy::representation() const { - return std::string(""); + return {""}; } PyObject* GroupExtensionPy::newObject(PyObject *args) diff --git a/src/App/MaterialPyImp.cpp b/src/App/MaterialPyImp.cpp index 41a3600505..e758cdac83 100644 --- a/src/App/MaterialPyImp.cpp +++ b/src/App/MaterialPyImp.cpp @@ -80,7 +80,7 @@ int MaterialPy::PyInit(PyObject* args, PyObject* kwds) // returns a string which represents the object e.g. when printed in python std::string MaterialPy::representation() const { - return std::string(""); + return {""}; } PyObject* MaterialPy::set(PyObject * args) diff --git a/src/App/ObjectIdentifier.cpp b/src/App/ObjectIdentifier.cpp index baf52d40b8..962a972bb8 100644 --- a/src/App/ObjectIdentifier.cpp +++ b/src/App/ObjectIdentifier.cpp @@ -374,13 +374,13 @@ const std::string &ObjectIdentifier::toString() const std::string ObjectIdentifier::toPersistentString() const { if(!owner) - return std::string(); + return {}; std::ostringstream s; ResolveResults result(*this); if(result.propertyIndex >= (int)components.size()) - return std::string(); + return {}; if(localProperty || (result.resolvedProperty && @@ -1776,7 +1776,7 @@ App::any ObjectIdentifier::getValue(bool pathValue, bool *isPseudoProperty) cons }catch(Py::Exception &) { Base::PyException::ThrowException(); } - return App::any(); + return {}; } Py::Object ObjectIdentifier::getPyValue(bool pathValue, bool *isPseudoProperty) const diff --git a/src/App/OriginGroupExtensionPyImp.cpp b/src/App/OriginGroupExtensionPyImp.cpp index 4eedc185a8..a7fc7c3870 100644 --- a/src/App/OriginGroupExtensionPyImp.cpp +++ b/src/App/OriginGroupExtensionPyImp.cpp @@ -32,7 +32,7 @@ using namespace App; // returns a string which represents the object e.g. when printed in python std::string OriginGroupExtensionPy::representation() const { - return std::string(""); + return {""}; } PyObject *OriginGroupExtensionPy::getCustomAttributes(const char* /*attr*/) const diff --git a/src/App/PartPyImp.cpp b/src/App/PartPyImp.cpp index 6fd5228b51..e595a18c82 100644 --- a/src/App/PartPyImp.cpp +++ b/src/App/PartPyImp.cpp @@ -32,7 +32,7 @@ using namespace App; // returns a string which represents the object e.g. when printed in python std::string PartPy::representation() const { - return std::string(""); + return {""}; } PyObject *PartPy::getCustomAttributes(const char* /*attr*/) const diff --git a/src/App/PropertyContainer.h b/src/App/PropertyContainer.h index deea54b260..d45cda7733 100644 --- a/src/App/PropertyContainer.h +++ b/src/App/PropertyContainer.h @@ -158,7 +158,7 @@ public: unsigned int getMemSize () const override; - virtual std::string getFullName() const {return std::string();} + virtual std::string getFullName() const {return {};} /// find a property by its name virtual Property *getPropertyByName(const char* name) const; diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp index 8b00033874..41ce05a2e3 100644 --- a/src/App/PropertyContainerPyImp.cpp +++ b/src/App/PropertyContainerPyImp.cpp @@ -45,7 +45,7 @@ using namespace App; // returns a string which represent the object e.g. when printed in python std::string PropertyContainerPy::representation() const { - return std::string(""); + return {""}; } PyObject* PropertyContainerPy::getPropertyByName(PyObject *args) diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index 94fe9137d4..41b12a1705 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -811,7 +811,7 @@ std::string PropertyExpressionEngine::validateExpression(const ObjectIdentifier return e.what(); } - return std::string(); + return {}; } /** diff --git a/src/App/PropertyGeo.h b/src/App/PropertyGeo.h index 62d1f1299c..d32cd3507c 100644 --- a/src/App/PropertyGeo.h +++ b/src/App/PropertyGeo.h @@ -102,7 +102,7 @@ public: bool getPyPathValue(const ObjectIdentifier &path, Py::Object &res) const override; virtual Base::Unit getUnit() const { - return Base::Unit(); + return {}; } bool isSame(const Property &other) const override { diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index 1620d29e6f..6c9238e182 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -147,7 +147,7 @@ std::string PropertyLinkBase::updateLabelReference(const App::DocumentObject *pa const char *subname, App::DocumentObject *obj, const std::string &ref, const char *newLabel) { if(!obj || !obj->getNameInDocument() || !parent || !parent->getNameInDocument()) - return std::string(); + return {}; // Because the label is allowed to be the same across different // hierarchies, we have to search for all occurrences, and make sure the @@ -162,7 +162,7 @@ std::string PropertyLinkBase::updateLabelReference(const App::DocumentObject *pa return sub; } } - return std::string(); + return {}; } std::vector > > @@ -192,7 +192,7 @@ PropertyLinkBase::updateLabelReferences(App::DocumentObject *obj, const char *ne static std::string propertyName(const Property *prop) { if(!prop) - return std::string(); + return {}; if(!prop->getContainer() || !prop->hasName()) { auto xlink = Base::freecad_dynamic_cast(prop); if(xlink) @@ -1238,7 +1238,7 @@ std::string PropertyLinkBase::tryImportSubName(const App::DocumentObject *obj, c const App::Document *doc, const std::map &nameMap) { if(!doc || !obj || !obj->getNameInDocument()) - return std::string(); + return {}; std::ostringstream ss; std::string subname(_subname); @@ -1249,7 +1249,7 @@ std::string PropertyLinkBase::tryImportSubName(const App::DocumentObject *obj, c auto sobj = obj->getSubObject(subname.c_str()); if(!sobj) { FC_ERR("Failed to restore label reference " << obj->getFullName() << '.' << subname); - return std::string(); + return {}; } dot[0] = 0; if(next[0] == '$') { @@ -1273,7 +1273,7 @@ std::string PropertyLinkBase::tryImportSubName(const App::DocumentObject *obj, c } if(sub!=subname.c_str()) return ss.str(); - return std::string(); + return {}; } #define ATTR_SHADOWED "shadowed" diff --git a/src/App/StringHasherPyImp.cpp b/src/App/StringHasherPyImp.cpp index 582effc79f..1a2b21a6de 100644 --- a/src/App/StringHasherPyImp.cpp +++ b/src/App/StringHasherPyImp.cpp @@ -127,7 +127,7 @@ Py::Long StringHasherPy::getSize() const Py::Boolean StringHasherPy::getSaveAll() const { - return Py::Boolean(getStringHasherPtr()->getSaveAll()); + return {getStringHasherPtr()->getSaveAll()}; } void StringHasherPy::setSaveAll(Py::Boolean value) diff --git a/src/App/StringIDPyImp.cpp b/src/App/StringIDPyImp.cpp index 10b6563185..549b71f1c8 100644 --- a/src/App/StringIDPyImp.cpp +++ b/src/App/StringIDPyImp.cpp @@ -66,17 +66,17 @@ Py::List StringIDPy::getRelated() const Py::String StringIDPy::getData() const { - return Py::String(getStringIDPtr()->dataToText(this->_index)); + return {getStringIDPtr()->dataToText(this->_index)}; } Py::Boolean StringIDPy::getIsBinary() const { - return Py::Boolean(getStringIDPtr()->isBinary()); + return {getStringIDPtr()->isBinary()}; } Py::Boolean StringIDPy::getIsHashed() const { - return Py::Boolean(getStringIDPtr()->isHashed()); + return {getStringIDPtr()->isHashed()}; } Py::Long StringIDPy::getIndex() const