diff --git a/src/App/Application.h b/src/App/Application.h index c9d5f1229d..189444d28c 100644 --- a/src/App/Application.h +++ b/src/App/Application.h @@ -488,7 +488,7 @@ protected: private: /// Constructor - Application(std::map &mConfig); + explicit Application(std::map &mConfig); /// Destructor virtual ~Application(); diff --git a/src/App/ColorModel.h b/src/App/ColorModel.h index a9b4b5d292..b38a79fb4b 100644 --- a/src/App/ColorModel.h +++ b/src/App/ColorModel.h @@ -74,7 +74,7 @@ class AppExport ColorModel { public: ColorModel() = default; - ColorModel (std::size_t usCt) { + explicit ColorModel (std::size_t usCt) { colors.resize(usCt); } ColorModel(const ColorModel&) = default; diff --git a/src/App/Document.cpp b/src/App/Document.cpp index d5af1f0449..817ce571dd 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -328,7 +328,7 @@ void Document::exportGraphviz(std::ostream& out) const class GraphCreator { public: - GraphCreator(struct DocumentP* _d) : d(_d), vertex_no(0), seed(std::random_device()()), distribution(0,255) { + explicit GraphCreator(struct DocumentP* _d) : d(_d), vertex_no(0), seed(std::random_device()()), distribution(0,255) { build(); } @@ -1793,7 +1793,7 @@ static DocExportStatus _ExportStatus; // Exception-safe exporting status setter class DocumentExporting { public: - DocumentExporting(const std::vector &objs) { + explicit DocumentExporting(const std::vector &objs) { _ExportStatus.status = Document::Exporting; _ExportStatus.objs.insert(objs.begin(),objs.end()); } diff --git a/src/App/Document.h b/src/App/Document.h index a576decd17..1a81d28033 100644 --- a/src/App/Document.h +++ b/src/App/Document.h @@ -510,7 +510,7 @@ public: protected: /// Construction - Document(const char *name = ""); + explicit Document(const char *name = ""); void _removeObject(DocumentObject* pcObject); void _addObject(DocumentObject* pcObject, const char* pObjectName); diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index 31c1e0920d..e863958edc 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -74,11 +74,11 @@ enum ObjectStatus { class AppExport DocumentObjectExecReturn { public: - DocumentObjectExecReturn(const std::string& sWhy, DocumentObject* WhichObject=nullptr) + explicit DocumentObjectExecReturn(const std::string& sWhy, DocumentObject* WhichObject=nullptr) : Why(sWhy), Which(WhichObject) { } - DocumentObjectExecReturn(const char* sWhy, DocumentObject* WhichObject=nullptr) + explicit DocumentObjectExecReturn(const char* sWhy, DocumentObject* WhichObject=nullptr) : Which(WhichObject) { if (sWhy) diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index bf409ba338..7410320ae9 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -476,7 +476,7 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds) Py::Object obj; Py::Object pyObj; Base::Matrix4D mat; - SubInfo(const Base::Matrix4D &mat) : sobj(nullptr), mat(mat){} + explicit SubInfo(const Base::Matrix4D &mat) : sobj(nullptr), mat(mat){} }; Base::Matrix4D mat; diff --git a/src/App/DocumentObserver.cpp b/src/App/DocumentObserver.cpp index e102333672..eead2a0769 100644 --- a/src/App/DocumentObserver.cpp +++ b/src/App/DocumentObserver.cpp @@ -544,7 +544,7 @@ std::string PropertyLinkT::getPropertyPython() const class DocumentWeakPtrT::Private { public: - Private(App::Document* doc) : _document(doc) { + explicit Private(App::Document* doc) : _document(doc) { if (doc) { connectApplicationDeletedDocument = App::GetApplication().signalDeleteDocument.connect(std::bind (&Private::deletedDocument, this, sp::_1)); @@ -596,7 +596,7 @@ App::Document* DocumentWeakPtrT::operator->() const noexcept class DocumentObjectWeakPtrT::Private { public: - Private(App::DocumentObject* obj) : object(obj), indocument(false) { + explicit Private(App::DocumentObject* obj) : object(obj), indocument(false) { set(obj); } void deletedDocument(const App::Document& doc) { diff --git a/src/App/DocumentObserver.h b/src/App/DocumentObserver.h index 5d4b580584..7b27ae61dc 100644 --- a/src/App/DocumentObserver.h +++ b/src/App/DocumentObserver.h @@ -49,9 +49,9 @@ public: /*! Constructor */ DocumentT(); /*! Constructor */ - DocumentT(Document*); + DocumentT(Document*); // explicit bombs /*! Constructor */ - DocumentT(const std::string&); + explicit DocumentT(const std::string&); /*! Constructor */ DocumentT(const DocumentT&); /*! Destructor */ @@ -99,13 +99,13 @@ public: /*! Constructor */ DocumentObjectT(DocumentObjectT &&); /*! Constructor */ - DocumentObjectT(const DocumentObject*); + explicit DocumentObjectT(const DocumentObject*); /*! Constructor */ DocumentObjectT(const Document*, const std::string& objName); /*! Constructor */ DocumentObjectT(const char *docName, const char *objName); /*! Constructor */ - DocumentObjectT(const Property*); + explicit DocumentObjectT(const Property*); /*! Destructor */ ~DocumentObjectT(); /*! Assignment operator */ @@ -177,7 +177,7 @@ public: SubObjectT(const DocumentObject*, const char *subname); /*! Constructor */ - SubObjectT(const DocumentObject*); + SubObjectT(const DocumentObject*);// explicit bombs /*! Constructor */ SubObjectT(const char *docName, const char *objName, const char *subname); @@ -257,13 +257,13 @@ public: PropertyLinkT(); /*! Constructor */ - PropertyLinkT(DocumentObject *obj); + PropertyLinkT(DocumentObject *obj);// explicit bombs /*! Constructor */ PropertyLinkT(DocumentObject *obj, const std::vector& subNames); /*! Constructor */ - PropertyLinkT(const std::vector& objs); + explicit PropertyLinkT(const std::vector& objs); /*! Constructor */ PropertyLinkT(const std::vector& objs, const std::vector& subNames); @@ -281,7 +281,7 @@ private: class AppExport DocumentWeakPtrT { public: - DocumentWeakPtrT(App::Document*) noexcept; + explicit DocumentWeakPtrT(App::Document*) noexcept; ~DocumentWeakPtrT(); /*! @@ -320,7 +320,7 @@ private: class AppExport DocumentObjectWeakPtrT { public: - DocumentObjectWeakPtrT(App::DocumentObject*); + explicit DocumentObjectWeakPtrT(App::DocumentObject*); ~DocumentObjectWeakPtrT(); /*! @@ -383,7 +383,7 @@ template class WeakPtrT { public: - WeakPtrT(T* t) : ptr(t) { + explicit WeakPtrT(T* t) : ptr(t) { } ~WeakPtrT() = default; @@ -466,7 +466,7 @@ class AppExport DocumentObserver public: /// Constructor DocumentObserver(); - DocumentObserver(Document*); + explicit DocumentObserver(Document*); virtual ~DocumentObserver(); /** Attaches to another document, the old document diff --git a/src/App/Enumeration.cpp b/src/App/Enumeration.cpp index 8a31b29ca1..1d85767232 100644 --- a/src/App/Enumeration.cpp +++ b/src/App/Enumeration.cpp @@ -34,7 +34,7 @@ using namespace App; namespace { struct StringCopy : public Enumeration::Object { - StringCopy(const char* str) : d(str) { + explicit StringCopy(const char* str) : d(str) { } const char* data() const override { return d.data(); @@ -51,7 +51,7 @@ private: }; struct StringView : public Enumeration::Object { - StringView(const char* str) : d(str) { + explicit StringView(const char* str) : d(str) { } const char* data() const override { return d.data(); diff --git a/src/App/Enumeration.h b/src/App/Enumeration.h index 1256e2719b..64320ac9b4 100644 --- a/src/App/Enumeration.h +++ b/src/App/Enumeration.h @@ -68,7 +68,7 @@ namespace App Enumeration(const Enumeration& other); /// Constructs an Enumeration with a single element - Enumeration(const char *valStr); + explicit Enumeration(const char *valStr); /// Constructs an Enumeration using val within list Enumeration(const char **list, const char *valStr); diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index 844db1c6b0..e269e8c360 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -380,7 +380,7 @@ struct PyObjectWrapper { public: typedef std::shared_ptr Pointer; - PyObjectWrapper(PyObject *obj):pyobj(obj) { + explicit PyObjectWrapper(PyObject *obj):pyobj(obj) { Py::_XINCREF(pyobj); } ~PyObjectWrapper() { @@ -940,7 +940,7 @@ std::map Expression::getDepObjects(std::vector &deps) + explicit GetIdentifiersExpressionVisitor(std::map &deps) :deps(deps) {} @@ -964,7 +964,7 @@ std::map Expression::getIdentifiers() const { class AdjustLinksExpressionVisitor : public ExpressionVisitor { public: - AdjustLinksExpressionVisitor(const std::set &inList) + explicit AdjustLinksExpressionVisitor(const std::set &inList) :inList(inList),res(false) {} @@ -985,7 +985,7 @@ bool Expression::adjustLinks(const std::set &inList) { class ImportSubNamesExpressionVisitor : public ExpressionVisitor { public: - ImportSubNamesExpressionVisitor(const ObjectIdentifier::SubNameMap &subNameMap) + explicit ImportSubNamesExpressionVisitor(const ObjectIdentifier::SubNameMap &subNameMap) :subNameMap(subNameMap) {} @@ -1698,7 +1698,7 @@ TYPESYSTEM_SOURCE(App::FunctionExpression, App::UnitExpression) static int _HiddenReference; struct HiddenReference { - HiddenReference(bool cond) + explicit HiddenReference(bool cond) :cond(cond) { if(cond) diff --git a/src/App/Expression.h b/src/App/Expression.h index 4fa5877fa8..6c77aaef59 100644 --- a/src/App/Expression.h +++ b/src/App/Expression.h @@ -80,7 +80,7 @@ protected: template class ExpressionModifier : public ExpressionVisitor { public: - ExpressionModifier(P & _prop) + explicit ExpressionModifier(P & _prop) : prop(_prop) , propLink(Base::freecad_dynamic_cast(&prop)) , signaller(_prop,false) @@ -117,7 +117,7 @@ class AppExport Expression : public Base::BaseClass { public: - Expression(const App::DocumentObject * _owner); + explicit Expression(const App::DocumentObject * _owner); ~Expression() override; @@ -164,7 +164,7 @@ public: class Exception : public Base::Exception { public: - Exception(const char *sMessage) : Base::Exception(sMessage) { } + explicit Exception(const char *sMessage) : Base::Exception(sMessage) { } }; App::DocumentObject * getOwner() const { return owner; } diff --git a/src/App/ExpressionParser.h b/src/App/ExpressionParser.h index a2425a6c10..d569c86bcc 100644 --- a/src/App/ExpressionParser.h +++ b/src/App/ExpressionParser.h @@ -43,9 +43,9 @@ struct AppExport Expression::Component { Expression* e2; Expression* e3; - Component(const std::string &n); + explicit Component(const std::string &n); Component(Expression *e1, Expression *e2, Expression *e3, bool isRange=false); - Component(const ObjectIdentifier::Component &comp); + explicit Component(const ObjectIdentifier::Component &comp); Component(const Component &other); ~Component(); Component &operator=(const Component &)=delete; @@ -71,7 +71,7 @@ struct AppExport Expression::Component { class AppExport UnitExpression : public Expression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - UnitExpression(const App::DocumentObject *_owner = nullptr, const Base::Quantity & _quantity = Base::Quantity(), const std::string & _unitStr = std::string()); + explicit UnitExpression(const App::DocumentObject *_owner = nullptr, const Base::Quantity & _quantity = Base::Quantity(), const std::string & _unitStr = std::string()); ~UnitExpression() override; @@ -111,7 +111,7 @@ private: class AppExport NumberExpression : public UnitExpression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - NumberExpression(const App::DocumentObject *_owner = nullptr, const Base::Quantity & quantity = Base::Quantity()); + explicit NumberExpression(const App::DocumentObject *_owner = nullptr, const Base::Quantity & quantity = Base::Quantity()); Expression * simplify() const override; @@ -127,7 +127,7 @@ protected: class AppExport ConstantExpression : public NumberExpression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - ConstantExpression(const App::DocumentObject *_owner = nullptr, + explicit ConstantExpression(const App::DocumentObject *_owner = nullptr, const char *_name = "", const Base::Quantity &_quantity = Base::Quantity()); @@ -170,7 +170,7 @@ public: NEG, POS }; - OperatorExpression(const App::DocumentObject *_owner = nullptr, Expression * _left = nullptr, Operator _op = NONE, Expression * _right = nullptr); + explicit OperatorExpression(const App::DocumentObject *_owner = nullptr, Expression * _left = nullptr, Operator _op = NONE, Expression * _right = nullptr); ~OperatorExpression() override; @@ -209,7 +209,7 @@ protected: class AppExport ConditionalExpression : public Expression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - ConditionalExpression(const App::DocumentObject *_owner = nullptr, Expression * _condition = nullptr,Expression * _trueExpr = nullptr, Expression * _falseExpr = nullptr); + explicit ConditionalExpression(const App::DocumentObject *_owner = nullptr, Expression * _condition = nullptr,Expression * _trueExpr = nullptr, Expression * _falseExpr = nullptr); ~ConditionalExpression() override; @@ -290,7 +290,7 @@ public: LAST, }; - FunctionExpression(const App::DocumentObject *_owner = nullptr, Function _f = NONE, + explicit FunctionExpression(const App::DocumentObject *_owner = nullptr, Function _f = NONE, std::string &&name = std::string(), std::vector _args = std::vector()); ~FunctionExpression() override; @@ -327,7 +327,7 @@ protected: class AppExport VariableExpression : public UnitExpression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - VariableExpression(const App::DocumentObject *_owner = nullptr, const ObjectIdentifier& _var = ObjectIdentifier()); + explicit VariableExpression(const App::DocumentObject *_owner = nullptr, const ObjectIdentifier& _var = ObjectIdentifier()); ~VariableExpression() override; @@ -375,7 +375,7 @@ class AppExport PyObjectExpression : public Expression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - PyObjectExpression(const App::DocumentObject *_owner=nullptr, PyObject *pyobj=nullptr, bool owned=false) + explicit PyObjectExpression(const App::DocumentObject *_owner=nullptr, PyObject *pyobj=nullptr, bool owned=false) :Expression(_owner) { setPyValue(pyobj,owned); @@ -404,7 +404,7 @@ protected: class AppExport StringExpression : public Expression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - StringExpression(const App::DocumentObject *_owner = nullptr, const std::string & _text = std::string()); + explicit StringExpression(const App::DocumentObject *_owner = nullptr, const std::string & _text = std::string()); ~StringExpression() override; Expression * simplify() const override; @@ -424,7 +424,7 @@ private: class AppExport RangeExpression : public App::Expression { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - RangeExpression(const App::DocumentObject * _owner = nullptr, const std::string & begin = std::string(), const std::string & end = std::string()); + explicit RangeExpression(const App::DocumentObject * _owner = nullptr, const std::string & begin = std::string(), const std::string & end = std::string()); ~RangeExpression() override = default; @@ -460,7 +460,7 @@ AppExport std::vector > tokenize(const std::st /// Convenient class to mark begin of importing class AppExport ExpressionImporter { public: - ExpressionImporter(Base::XMLReader &reader); + explicit ExpressionImporter(Base::XMLReader &reader); ~ExpressionImporter(); static Base::XMLReader *reader(); }; diff --git a/src/App/ExpressionVisitors.h b/src/App/ExpressionVisitors.h index 14e91c9af1..3efcf2e4df 100644 --- a/src/App/ExpressionVisitors.h +++ b/src/App/ExpressionVisitors.h @@ -34,11 +34,13 @@ namespace App { template class RenameObjectIdentifierExpressionVisitor : public ExpressionModifier

{ public: - RenameObjectIdentifierExpressionVisitor(P & _prop, - const std::map &_paths, const ObjectIdentifier & _owner) - : ExpressionModifier

(_prop) - , paths(_paths) - , owner(_owner) + RenameObjectIdentifierExpressionVisitor( + P &_prop, + const std::map &_paths, + const ObjectIdentifier &_owner ) + : ExpressionModifier

( _prop ), + paths( _paths ), + owner( _owner ) { } @@ -46,7 +48,6 @@ public: this->renameObjectIdentifier(node,paths,owner); } - private: const std::map &paths; /**< Map with current and new object identifiers */ const ObjectIdentifier owner; /**< Owner of expression */ @@ -55,7 +56,7 @@ private: template class UpdateElementReferenceExpressionVisitor : public ExpressionModifier

{ public: - UpdateElementReferenceExpressionVisitor(P & _prop, App::DocumentObject *feature=nullptr, bool reverse=false) + explicit UpdateElementReferenceExpressionVisitor(P & _prop, App::DocumentObject *feature=nullptr, bool reverse=false) : ExpressionModifier

(_prop),feature(feature),reverse(reverse) { } @@ -76,7 +77,7 @@ private: class RelabelDocumentExpressionVisitor : public ExpressionVisitor { public: - RelabelDocumentExpressionVisitor(const App::Document &doc) + explicit RelabelDocumentExpressionVisitor(const App::Document &doc) : doc(doc) { } diff --git a/src/App/FeaturePython.h b/src/App/FeaturePython.h index afe63ca667..93261bc6e4 100644 --- a/src/App/FeaturePython.h +++ b/src/App/FeaturePython.h @@ -44,7 +44,7 @@ public: Rejected = 2 // handled and rejected }; - FeaturePythonImp(App::DocumentObject*); + explicit FeaturePythonImp(App::DocumentObject*); ~FeaturePythonImp(); bool execute(); diff --git a/src/App/FeaturePythonPyImp.h b/src/App/FeaturePythonPyImp.h index a31f8095fe..4e2bd58a15 100644 --- a/src/App/FeaturePythonPyImp.h +++ b/src/App/FeaturePythonPyImp.h @@ -88,7 +88,7 @@ public: static PyTypeObject Type; public: - FeaturePythonPyT(Base::BaseClass *pcObject, PyTypeObject *T = &Type); + explicit FeaturePythonPyT(Base::BaseClass *pcObject, PyTypeObject *T = &Type); virtual ~FeaturePythonPyT(); /** @name callbacks and implementers for the python object methods */ diff --git a/src/App/Material.h b/src/App/Material.h index 43fe4122de..4179015ee6 100644 --- a/src/App/Material.h +++ b/src/App/Material.h @@ -50,7 +50,7 @@ public: * Does basically the same as the constructor above unless that (R,G,B,A) is * encoded as an unsigned int. */ - Color(uint32_t rgba) + explicit Color(uint32_t rgba) { setPackedValue( rgba ); } /** Copy constructor. */ Color(const Color& c) @@ -222,9 +222,9 @@ public: /** Defines the colors and shininess for the material \a MatName. If \a MatName isn't defined then USER_DEFINED is * set and the user must define the colors itself. */ - Material(const char* MatName); + explicit Material(const char* MatName); /** Does basically the same as the constructor above unless that it accepts a MaterialType as argument. */ - Material(const MaterialType MatType); + explicit Material(const MaterialType MatType); //@} ~Material(); diff --git a/src/App/MergeDocuments.h b/src/App/MergeDocuments.h index 2f8568e98a..14e1ceca35 100644 --- a/src/App/MergeDocuments.h +++ b/src/App/MergeDocuments.h @@ -37,7 +37,7 @@ class DocumentObject; class AppExport MergeDocuments : public Base::Persistence { public: - MergeDocuments(App::Document* doc); + explicit MergeDocuments(App::Document* doc); ~MergeDocuments() override; bool isVerbose() const { return verbose; } void setVerbose(bool on) { verbose = on; } diff --git a/src/App/Metadata.h b/src/App/Metadata.h index 968d91b51d..d5159583c8 100644 --- a/src/App/Metadata.h +++ b/src/App/Metadata.h @@ -94,7 +94,7 @@ namespace App { */ struct AppExport Version { Version(); - Version(int major, int minor = 0, int patch = 0, const std::string& suffix = std::string()); + explicit Version(int major, int minor = 0, int patch = 0, const std::string& suffix = std::string()); explicit Version(const std::string& semanticString); int major; diff --git a/src/App/ObjectIdentifier.cpp b/src/App/ObjectIdentifier.cpp index 7469c8a824..48fe555853 100644 --- a/src/App/ObjectIdentifier.cpp +++ b/src/App/ObjectIdentifier.cpp @@ -856,7 +856,7 @@ App::DocumentObject * ObjectIdentifier::getDocumentObject(const App::Document * if (strcmp((*j)->Label.getValue(), static_cast(name)) == 0) { // Found object with matching label if (objectByLabel) { - FC_WARN("duplicate object label " << doc->getName() << '#' << name); + FC_WARN("duplicate object label " << doc->getName() << '#' << static_cast(name)); return nullptr; } objectByLabel = *j; @@ -935,13 +935,12 @@ void ObjectIdentifier::resolve(ResolveResults &results) const if (!results.resolvedDocumentObject) return; - if (!components.empty()) { - results.propertyName = components[0].name.getString(); - results.propertyIndex = 0; - results.getProperty(*this); - } - else + if (components.empty()) return; + + results.propertyName = components[ 0 ].name.getString(); + results.propertyIndex = 0; + results.getProperty( *this ); } else { /* Document object name not specified, resolve from path */ @@ -966,8 +965,10 @@ void ObjectIdentifier::resolve(ResolveResults &results) const /* Possible to resolve component to a document object? */ if (results.resolvedDocumentObject) { /* Yes */ - results.resolvedDocumentObjectName = String( - components[0].name, false, results.flags.test(ResolveByIdentifier)); + results.resolvedDocumentObjectName = String { + components[0].name.getString(), + false, + results.flags.test(ResolveByIdentifier)}; results.propertyName = components[1].name.getString(); results.propertyIndex = 1; results.getProperty(*this); @@ -976,7 +977,10 @@ void ObjectIdentifier::resolve(ResolveResults &results) const // interpret the first component as the property name. DocumentObject *sobj = nullptr; results.resolvedProperty = resolveProperty( - owner,components[0].name,sobj,results.propertyType); + owner, + components[0].name.toString().c_str(), + sobj, + results.propertyType); if(results.resolvedProperty) { results.propertyName = components[0].name.getString(); results.resolvedDocument = owner->getDocument(); @@ -1018,7 +1022,7 @@ Document * ObjectIdentifier::getDocument(String name, bool *ambiguous) const App::Document * docById = nullptr; if(!name.isRealString()) { - docById = App::GetApplication().getDocument(name); + docById = App::GetApplication().getDocument(name.toString().c_str()); if (name.isForceIdentifier()) return docById; } @@ -1267,7 +1271,7 @@ Property *ObjectIdentifier::resolveProperty(const App::DocumentObject *obj, const char *propertyName, App::DocumentObject *&sobj, int &ptype) const { if(obj && !subObjectName.getString().empty()) { - sobj = obj->getSubObject(subObjectName); + sobj = obj->getSubObject(subObjectName.toString().c_str()); obj = sobj; } if(!obj) diff --git a/src/App/ObjectIdentifier.h b/src/App/ObjectIdentifier.h index 947c0799d1..133728e909 100644 --- a/src/App/ObjectIdentifier.h +++ b/src/App/ObjectIdentifier.h @@ -72,7 +72,7 @@ public: class AppExport DocumentMapper { public: - DocumentMapper(const std::map &); + explicit DocumentMapper(const std::map &); ~DocumentMapper(); }; @@ -81,14 +81,21 @@ public: public: - // Constructor - String(const std::string & s = "", bool _isRealString = false, bool _forceIdentifier = false) - : str(s), isString(_isRealString), forceIdentifier(_forceIdentifier) - { } + String(const std::string &s = "", + bool _isRealString = false, + bool _forceIdentifier = false) + : str(s), + isString(_isRealString), + forceIdentifier(_forceIdentifier) + {}//explicit bombs - String(std::string &&s, bool _isRealString = false, bool _forceIdentifier = false) - : str(std::move(s)), isString(_isRealString), forceIdentifier(_forceIdentifier) - { } + explicit String(std::string &&s, + bool _isRealString = false, + bool _forceIdentifier = false) + : str(std::move(s)), + isString(_isRealString), + forceIdentifier(_forceIdentifier) + {} FC_DEFAULT_CTORS(String) { str = std::move(other.str); @@ -112,9 +119,9 @@ public: // Operators - operator std::string() const { return str; } + explicit operator std::string() const { return str; } - operator const char *() const { return str.c_str(); } + explicit operator const char *() const { return str.c_str(); } bool operator==(const String & other) const { return str == other.str; } @@ -166,9 +173,9 @@ public: } Component(const String &_name = String(), typeEnum _type=SIMPLE, - int begin=INT_MAX, int end=INT_MAX, int step=1); + int begin=INT_MAX, int end=INT_MAX, int step=1);//explicit bombs Component(String &&_name, typeEnum _type=SIMPLE, - int begin=INT_MAX, int end=INT_MAX, int step=1); + int begin=INT_MAX, int end=INT_MAX, int step=1);//explicit bombs static Component SimpleComponent(const char * _component); @@ -234,6 +241,9 @@ public: static Component SimpleComponent(String &&_component) {return Component::SimpleComponent(std::move(_component));} + static Component SimpleComponent(const std::string _component) + {return Component::SimpleComponent(_component.c_str());} + static Component ArrayComponent(int _index) {return Component::ArrayComponent(_index); } @@ -246,12 +256,12 @@ public: static Component MapComponent(String &&_key) {return Component::MapComponent(_key);} - ObjectIdentifier(const App::PropertyContainer * _owner = nullptr, + explicit ObjectIdentifier(const App::PropertyContainer * _owner = nullptr, const std::string & property = std::string(), int index=INT_MAX); ObjectIdentifier(const App::PropertyContainer * _owner, bool localProperty); - ObjectIdentifier(const App::Property & prop, int index=INT_MAX); + ObjectIdentifier(const App::Property & prop, int index=INT_MAX);//explicit bombs FC_DEFAULT_CTORS(ObjectIdentifier) { owner = other.owner; @@ -436,7 +446,7 @@ protected: struct ResolveResults { - ResolveResults(const ObjectIdentifier & oi); + explicit ResolveResults(const ObjectIdentifier & oi); int propertyIndex; App::Document * resolvedDocument; diff --git a/src/App/Origin.h b/src/App/Origin.h index 2146a3ba3b..8deabce0b7 100644 --- a/src/App/Origin.h +++ b/src/App/Origin.h @@ -137,7 +137,7 @@ private: class OriginExtension : public GeoFeatureGroupExtension { Origin* obj; public: - OriginExtension(Origin* obj); + explicit OriginExtension(Origin* obj); void initExtension(ExtensionContainer* obj) override; bool extensionGetSubObject(DocumentObject *&ret, const char *subname, PyObject **, Base::Matrix4D *, bool, int) const override; diff --git a/src/App/Path.h b/src/App/Path.h index b0007fafa4..e354575f76 100644 --- a/src/App/Path.h +++ b/src/App/Path.h @@ -40,7 +40,7 @@ protected: public: /// Constructor Path(); - Path(const std::vector & PathVector); + explicit Path(const std::vector & PathVector); virtual ~Path(); diff --git a/src/App/Property.cpp b/src/App/Property.cpp index 4ea7f844f6..edc9b1502e 100644 --- a/src/App/Property.cpp +++ b/src/App/Property.cpp @@ -162,7 +162,7 @@ namespace App { * active. */ struct PropertyCleaner { - PropertyCleaner(Property *p) + explicit PropertyCleaner(Property *p) : prop(p) { ++_PropCleanerCounter; diff --git a/src/App/Property.h b/src/App/Property.h index f0b494f61b..d10b7994e4 100644 --- a/src/App/Property.h +++ b/src/App/Property.h @@ -345,7 +345,7 @@ public: * hasn't been marked before, and calls its * aboutToSetValue(). */ - AtomicPropertyChange(P & prop, bool markChange=true) : mProp(prop) { + explicit AtomicPropertyChange(P & prop, bool markChange=true) : mProp(prop) { mProp.signalCounter++; if (markChange) aboutToChange(); diff --git a/src/App/PropertyContainer.h b/src/App/PropertyContainer.h index 40d1c36439..e2ecac07fa 100644 --- a/src/App/PropertyContainer.h +++ b/src/App/PropertyContainer.h @@ -73,8 +73,8 @@ struct AppExport PropertyData //accepting void* struct OffsetBase { - OffsetBase(const App::PropertyContainer* container) : m_container(container) {} - OffsetBase(const App::Extension* container) : m_container(container) {} + OffsetBase(const App::PropertyContainer* container) : m_container(container) {}//explicit bombs + OffsetBase(const App::Extension* container) : m_container(container) {}//explicit bombs short int getOffsetTo(const App::Property* prop) const { auto *pt = (const char*)prop; diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index 9fe2d3bfdc..cb7605af42 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -632,7 +632,7 @@ DocumentObjectExecReturn *App::PropertyExpressionEngine::execute(ExecuteOption o class resetter { public: - resetter(bool & b) : _b(b) { _b = true; } + explicit resetter(bool & b) : _b(b) { _b = true; } ~resetter() { _b = false; } private: diff --git a/src/App/PropertyExpressionEngine.h b/src/App/PropertyExpressionEngine.h index 3626bc3971..36ea7c189b 100644 --- a/src/App/PropertyExpressionEngine.h +++ b/src/App/PropertyExpressionEngine.h @@ -87,7 +87,7 @@ public: std::shared_ptr expression; /**< The actual expression tree */ bool busy; - ExpressionInfo(std::shared_ptr expression = std::shared_ptr()) { + explicit ExpressionInfo(std::shared_ptr expression = std::shared_ptr()) { this->expression = expression; this->busy = false; } diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index 699017518f..1bc29a722e 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -215,7 +215,7 @@ void PropertyLinkBase::_registerElementReference(App::DocumentObject *obj, std:: class StringGuard { public: - StringGuard(char *c) + explicit StringGuard(char *c) :c(c) { v1 = c[0]; diff --git a/src/App/PropertyLinks.h b/src/App/PropertyLinks.h index 052ba83b2a..133908f4d2 100644 --- a/src/App/PropertyLinks.h +++ b/src/App/PropertyLinks.h @@ -1054,7 +1054,7 @@ class AppExport PropertyXLink : public PropertyLinkGlobal TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - PropertyXLink(bool allowPartial=false, PropertyLinkBase *parent=nullptr); + explicit PropertyXLink(bool allowPartial=false, PropertyLinkBase *parent=nullptr); ~PropertyXLink() override; @@ -1178,7 +1178,7 @@ class AppExport PropertyXLinkSub: public PropertyXLink { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - PropertyXLinkSub(bool allowPartial=false, PropertyLinkBase *parent=nullptr); + explicit PropertyXLinkSub(bool allowPartial=false, PropertyLinkBase *parent=nullptr); ~PropertyXLinkSub() override; diff --git a/src/App/PropertyStandard.h b/src/App/PropertyStandard.h index ffcea3b306..4a6a9e7b76 100644 --- a/src/App/PropertyStandard.h +++ b/src/App/PropertyStandard.h @@ -148,7 +148,7 @@ public: PropertyEnumeration(); /// Obvious constructor - PropertyEnumeration(const Enumeration &e); + explicit PropertyEnumeration(const Enumeration &e); /// destructor ~PropertyEnumeration() override; diff --git a/src/App/Range.h b/src/App/Range.h index f40e69557c..89b53d31d9 100644 --- a/src/App/Range.h +++ b/src/App/Range.h @@ -49,15 +49,15 @@ struct AppExport CellAddress { ShowFull = Absolute | ShowRow | ShowColumn }; - CellAddress(int row = -1, int col = -1, bool absRow=false, bool absCol=false) + explicit CellAddress(int row = -1, int col = -1, bool absRow=false, bool absCol=false) : _row(row), _col(col), _absRow(absRow), _absCol(absCol) { } - CellAddress(const char * address) { + explicit CellAddress(const char * address) { *this = stringToAddress(address); } - CellAddress(const std::string & address) { + explicit CellAddress(const std::string & address) { *this = stringToAddress(address.c_str()); } @@ -117,7 +117,7 @@ protected: class AppExport Range { public: - Range(const char *range, bool normalize=false); + explicit Range(const char *range, bool normalize=false); Range(int _row_begin, int _col_begin, int _row_end, int _col_end, bool normalize=false); diff --git a/src/App/Transactions.h b/src/App/Transactions.h index 49bac8df4a..0d0165a55b 100644 --- a/src/App/Transactions.h +++ b/src/App/Transactions.h @@ -55,7 +55,7 @@ public: * transactions from different document, so that they can be undo/redo * together. */ - Transaction(int id = 0); + explicit Transaction(int id = 0); /// Construction ~Transaction() override; @@ -176,7 +176,7 @@ template class TransactionProducer : public Base::AbstractProducer { public: - TransactionProducer (const Base::Type& type) + explicit TransactionProducer (const Base::Type& type) { TransactionFactory::instance().addProducer(type, this); } diff --git a/src/Gui/PreferencePackManager.cpp b/src/Gui/PreferencePackManager.cpp index 39a73eedf9..7bc3d7a084 100644 --- a/src/Gui/PreferencePackManager.cpp +++ b/src/Gui/PreferencePackManager.cpp @@ -386,14 +386,14 @@ void PreferencePackManager::save(const std::string& name, const std::vector(); metadata->setName("User-Saved PreferencePacks"); metadata->setDescription("Generated automatically -- edits may be lost when saving new preferencePacks"); - metadata->setVersion(1); + metadata->setVersion(static_cast(1)); metadata->addMaintainer(App::Meta::Contact("No Maintainer", "email@freecadweb.org")); metadata->addLicense(App::Meta::License("(Unspecified)", "(Unspecified)")); metadata->addUrl(App::Meta::Url("https://github.com/FreeCAD/FreeCAD", App::Meta::UrlType::repository)); } App::Metadata newPreferencePackMetadata; newPreferencePackMetadata.setName(name); - newPreferencePackMetadata.setVersion(1); + newPreferencePackMetadata.setVersion(static_cast(1)); metadata->addContentItem("preferencepack", newPreferencePackMetadata); metadata->write(savedPreferencePacksDirectory / "package.xml"); diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index 6cd95b2896..0604984bda 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -1358,7 +1358,7 @@ void PropertySheet::onRelabeledDocument(const App::Document &doc) void PropertySheet::renameObjectIdentifiers(const std::map &paths) { - RenameObjectIdentifierExpressionVisitor v(*this, paths, *this); + RenameObjectIdentifierExpressionVisitor v {*this, paths, *this}; for(auto &c : data) { c.second->visit(v); if(v.changed()) { diff --git a/src/Mod/TechDraw/Gui/QGIFace.cpp b/src/Mod/TechDraw/Gui/QGIFace.cpp index 1d999fcb24..af73319adc 100644 --- a/src/Mod/TechDraw/Gui/QGIFace.cpp +++ b/src/Mod/TechDraw/Gui/QGIFace.cpp @@ -712,7 +712,7 @@ void QGIFace::getParameters() hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); - App::Color temp = hGrp->GetUnsigned("FaceColor",0xffffffff); + App::Color temp {static_cast(hGrp->GetUnsigned("FaceColor",0xffffffff))}; setFillColor(temp.asValue()); hGrp = App::GetApplication().GetUserParameter()