Browse Source

Mark single-parameter constructors explicit

Suggested by cppcheck
Turo Lamminen 9 years ago
parent
commit
46121a1559

+ 2 - 2
code/ASEParser.h

@@ -138,7 +138,7 @@ struct Bone
     }
 
     //! Construction from an existing name
-    Bone( const std::string& name)
+    explicit Bone( const std::string& name)
         :   mName   (name)
     {}
 
@@ -216,7 +216,7 @@ struct BaseNode
     enum Type {Light, Camera, Mesh, Dummy} mType;
 
     //! Constructor. Creates a default name for the node
-    BaseNode(Type _mType)
+    explicit BaseNode(Type _mType)
         : mType         (_mType)
         , mProcessed    (false)
     {

+ 1 - 1
code/Assimp.cpp

@@ -110,7 +110,7 @@ static boost::mutex gLogStreamMutex;
 class LogToCallbackRedirector : public LogStream
 {
 public:
-    LogToCallbackRedirector(const aiLogStream& s)
+    explicit LogToCallbackRedirector(const aiLogStream& s)
         : stream (s)    {
             ai_assert(NULL != s.callback);
     }

+ 1 - 1
code/BVHLoader.h

@@ -83,7 +83,7 @@ class BVHLoader : public BaseImporter
         std::vector<float> mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames
 
         Node() { }
-        Node( const aiNode* pNode) : mNode( pNode) { }
+        explicit Node( const aiNode* pNode) : mNode( pNode) { }
     };
 
 public:

+ 1 - 1
code/BaseImporter.h

@@ -70,7 +70,7 @@ class IOStream;
 template <typename T>
 struct ScopeGuard
 {
-    ScopeGuard(T* obj) : obj(obj), mdismiss() {}
+    explicit ScopeGuard(T* obj) : obj(obj), mdismiss() {}
     ~ScopeGuard () throw() {
         if (!mdismiss) {
             delete obj;

+ 2 - 2
code/BaseProcess.h

@@ -74,7 +74,7 @@ public:
     template <typename T>
     struct THeapData : public Base
     {
-        THeapData(T* in)
+        explicit THeapData(T* in)
             : data (in)
         {}
 
@@ -89,7 +89,7 @@ public:
     template <typename T>
     struct TStaticData : public Base
     {
-        TStaticData(T in)
+        explicit TStaticData(T in)
             : data (in)
         {}
 

+ 2 - 2
code/CInterfaceIOWrapper.h

@@ -57,7 +57,7 @@ class CIOStreamWrapper : public IOStream
     friend class CIOSystemWrapper;
 public:
 
-    CIOStreamWrapper(aiFile* pFile)
+    explicit CIOStreamWrapper(aiFile* pFile)
         : mFile(pFile)
     {}
 
@@ -110,7 +110,7 @@ private:
 class CIOSystemWrapper : public IOSystem
 {
 public:
-    CIOSystemWrapper(aiFileIO* pFile)
+    explicit CIOSystemWrapper(aiFileIO* pFile)
         : mFileSystem(pFile)
     {}
 

+ 1 - 1
code/ComputeUVMappingProcess.h

@@ -125,7 +125,7 @@ private:
     // temporary structure to describe a mapping
     struct MappingInfo
     {
-        MappingInfo(aiTextureMapping _type)
+        explicit MappingInfo(aiTextureMapping _type)
             : type  (_type)
             , axis  (0.f,1.f,0.f)
             , uv    (0u)

+ 1 - 1
code/FBXProperties.h

@@ -87,7 +87,7 @@ class TypedProperty : public Property
 {
 public:
 
-    TypedProperty(const T& value)
+    explicit TypedProperty(const T& value)
         : value(value)
     {
     }

+ 2 - 2
code/IRRLoader.h

@@ -113,7 +113,7 @@ private:
 
         } type;
 
-        Animator(AT t = UNKNOWN)
+        explicit Animator(AT t = UNKNOWN)
             : type              (t)
             , speed             (0.001f)
             , direction         (0.f,1.f,0.f)
@@ -163,7 +163,7 @@ private:
             ANIMMESH
         } type;
 
-        Node(ET t)
+        explicit Node(ET t)
             :   type                (t)
             ,   scaling             (1.f,1.f,1.f) // assume uniform scaling by default
             ,   parent()

+ 1 - 1
code/Importer.h

@@ -167,7 +167,7 @@ public:
     // -------------------------------------------------------------------
     /** Construct a batch loader from a given IO system to be used
      *  to acess external files */
-    BatchLoader(IOSystem* pIO);
+    explicit BatchLoader(IOSystem* pIO);
     ~BatchLoader();
 
 

+ 2 - 2
code/LWOFileData.h

@@ -269,7 +269,7 @@ struct Face : public aiFace
     {}
 
     //! Construction from given type
-    Face(uint32_t _type)
+    explicit Face(uint32_t _type)
         : surfaceIndex  (0)
         , smoothGroup   (0)
         , type          (_type)
@@ -305,7 +305,7 @@ struct Face : public aiFace
  */
 struct VMapEntry
 {
-    VMapEntry(unsigned int _dims)
+    explicit VMapEntry(unsigned int _dims)
         :  dims(_dims)
     {}
 

+ 3 - 3
code/MD5Parser.h

@@ -280,7 +280,7 @@ public:
      *
      *  @param mSections List of file sections (output of MD5Parser)
      */
-    MD5MeshParser(SectionList& mSections);
+    explicit MD5MeshParser(SectionList& mSections);
 
     //! List of all meshes
     MeshList mMeshes;
@@ -305,7 +305,7 @@ public:
      *
      *  @param mSections List of file sections (output of MD5Parser)
      */
-    MD5AnimParser(SectionList& mSections);
+    explicit MD5AnimParser(SectionList& mSections);
 
 
     //! Output frame rate
@@ -337,7 +337,7 @@ public:
      *
      *  @param mSections List of file sections (output of MD5Parser)
      */
-    MD5CameraParser(SectionList& mSections);
+    explicit MD5CameraParser(SectionList& mSections);
 
 
     //! Output frame rate

+ 1 - 1
code/ObjFileData.h

@@ -242,7 +242,7 @@ struct Mesh {
     bool m_hasNormals;
 
     /// Constructor
-    Mesh( const std::string &name ) 
+    explicit Mesh( const std::string &name ) 
     : m_name( name )
     , m_pMaterial(NULL)
     , m_uiNumIndices(0)

+ 2 - 2
code/OgreStructs.h

@@ -381,8 +381,8 @@ typedef std::vector<VertexAnimationTrack> VertexAnimationTrackList;
 class Animation
 {
 public:
-    Animation(Skeleton *parent);
-    Animation(Mesh *parent);
+    explicit Animation(Skeleton *parent);
+    explicit Animation(Mesh *parent);
 
     /// Returns the associated vertex data for a track in this animation.
     /** @note Only valid to call when parent Mesh is set. */

+ 1 - 1
code/OgreXmlSerializer.h

@@ -69,7 +69,7 @@ public:
     static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh);
 
 private:
-    OgreXmlSerializer(XmlReader *reader) :
+    explicit OgreXmlSerializer(XmlReader *reader) :
         m_reader(reader)
     {
     }

+ 1 - 1
code/Q3BSPZipArchive.h

@@ -90,7 +90,7 @@ class ZipFile : public IOStream {
 
     public:
 
-        ZipFile(size_t size);
+        explicit ZipFile(size_t size);
 
         ~ZipFile();
 

+ 1 - 1
code/Q3DLoader.h

@@ -103,7 +103,7 @@ private:
 
     struct Face
     {
-        Face(unsigned int s)
+        explicit Face(unsigned int s)
             :   indices   (s)
             ,   uvindices (s)
             ,   mat       (0)

+ 2 - 2
code/RawLoader.h

@@ -88,7 +88,7 @@ private:
 
     struct MeshInformation
     {
-        MeshInformation(const std::string& _name)
+        explicit MeshInformation(const std::string& _name)
             : name(_name)
         {
             vertices.reserve(100);
@@ -103,7 +103,7 @@ private:
 
     struct GroupInformation
     {
-        GroupInformation(const std::string& _name)
+        explicit GroupInformation(const std::string& _name)
             : name(_name)
         {
             meshes.reserve(10);

+ 1 - 1
code/SGSpatialSort.h

@@ -66,7 +66,7 @@ public:
     /** Construction from a given face array, handling smoothing groups
      *  properly
      */
-    SGSpatialSort(const std::vector<aiVector3D>& vPositions);
+    explicit SGSpatialSort(const std::vector<aiVector3D>& vPositions);
 
     // -------------------------------------------------------------------
     /** Add a vertex to the spatial sort

+ 1 - 1
code/SceneCombiner.h

@@ -166,7 +166,7 @@ struct SceneHelper
         id[0] = 0;
     }
 
-    SceneHelper (aiScene* _scene)
+    explicit SceneHelper (aiScene* _scene)
         : scene     (_scene)
         , idlen     (0)
     {

+ 1 - 1
code/StdOStreamLogStream.h

@@ -16,7 +16,7 @@ public:
     /** @brief  Construction from an existing std::ostream
      *  @param _ostream Output stream to be used
     */
-    StdOStreamLogStream(std::ostream& _ostream);
+    explicit StdOStreamLogStream(std::ostream& _ostream);
 
     /** @brief  Destructor  */
     ~StdOStreamLogStream();

+ 1 - 1
code/TinyFormatter.h

@@ -97,7 +97,7 @@ public:
     // being bound to const ref& function parameters. Copying streams is not permitted, though.
     // This workaround avoids this by manually specifying a copy ctor.
 #if !defined(__GNUC__) || !defined(__APPLE__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
-    basic_formatter(const basic_formatter& other) {
+    explicit basic_formatter(const basic_formatter& other) {
         underlying << (string)other;
     }
 #endif

+ 1 - 1
code/UnrealLoader.h

@@ -87,7 +87,7 @@ struct TempMat  {
         ,   numFaces    (0)
     {}
 
-    TempMat(const Triangle& in)
+    explicit TempMat(const Triangle& in)
         :   type        ((Unreal::MeshFlags)in.mType)
         ,   tex         (in.mTextureNum)
         ,   numFaces    (0)

+ 2 - 2
code/XFileHelper.h

@@ -129,7 +129,7 @@ struct Mesh
 
     std::vector<Bone> mBones;
 
-    Mesh(const std::string &pName = "") { mName = pName; mNumTextures = 0; mNumColorSets = 0; }
+    explicit Mesh(const std::string &pName = "") { mName = pName; mNumTextures = 0; mNumColorSets = 0; }
 };
 
 /** Helper structure to represent a XFile frame */
@@ -142,7 +142,7 @@ struct Node
     std::vector<Mesh*> mMeshes;
 
     Node() { mParent = NULL; }
-    Node( Node* pParent) { mParent = pParent; }
+    explicit Node( Node* pParent) { mParent = pParent; }
     ~Node()
     {
         for( unsigned int a = 0; a < mChildren.size(); a++)

+ 1 - 1
code/XFileParser.h

@@ -68,7 +68,7 @@ public:
     /** Constructor. Creates a data structure out of the XFile given in the memory block.
      * @param pBuffer Null-terminated memory buffer containing the XFile
      */
-    XFileParser( const std::vector<char>& pBuffer);
+    explicit XFileParser( const std::vector<char>& pBuffer);
 
     /** Destructor. Destroys all imported data along with it */
     ~XFileParser();

+ 1 - 1
code/irrXMLWrapper.h

@@ -76,7 +76,7 @@ public:
 
     // ----------------------------------------------------------------------------------
     //! Construction from an existing IOStream
-    CIrrXML_IOStreamReader(IOStream* _stream)
+    explicit CIrrXML_IOStreamReader(IOStream* _stream)
         : stream (_stream)
         , t (0)
     {

+ 1 - 1
include/assimp/DefaultLogger.hpp

@@ -135,7 +135,7 @@ private:
     // ----------------------------------------------------------------------
     /** @briefPrivate construction for internal use by create().
      *  @param severity Logging granularity  */
-    DefaultLogger(LogSeverity severity);
+    explicit DefaultLogger(LogSeverity severity);
 
     // ----------------------------------------------------------------------
     /** @briefDestructor    */

+ 1 - 1
include/assimp/Logger.hpp

@@ -160,7 +160,7 @@ protected:
     Logger();
 
     /** Construction with a given log severity */
-    Logger(LogSeverity severity);
+    explicit Logger(LogSeverity severity);
 
     // ----------------------------------------------------------------------
     /** @brief Called as a request to write a specific debug message

+ 1 - 1
include/assimp/color4.h

@@ -59,7 +59,7 @@ public:
     aiColor4t () : r(), g(), b(), a() {}
     aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a)
         : r(_r), g(_g), b(_b), a(_a) {}
-    aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}
+    explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}
     aiColor4t (const aiColor4t& o)
         : r(o.r), g(o.g), b(o.b), a(o.a) {}
 

+ 2 - 2
include/assimp/quaternion.h

@@ -60,7 +60,7 @@ public:
         : w(pw), x(px), y(py), z(pz) {}
 
     /** Construct from rotation matrix. Result is undefined if the matrix is not orthonormal. */
-    aiQuaterniont( const aiMatrix3x3t<TReal>& pRotMatrix);
+    explicit aiQuaterniont( const aiMatrix3x3t<TReal>& pRotMatrix);
 
     /** Construct from euler angles */
     aiQuaterniont( TReal rotx, TReal roty, TReal rotz);
@@ -69,7 +69,7 @@ public:
     aiQuaterniont( aiVector3t<TReal> axis, TReal angle);
 
     /** Construct from a normalized quaternion stored in a vec3 */
-    aiQuaterniont( aiVector3t<TReal> normalized);
+    explicit aiQuaterniont( aiVector3t<TReal> normalized);
 
     /** Returns a matrix representation of the quaternion */
     aiMatrix3x3t<TReal> GetMatrix() const;

+ 1 - 1
include/assimp/scene.h

@@ -135,7 +135,7 @@ struct aiNode
 
 
     /** Construction from a specific name */
-    aiNode(const std::string& name)
+    explicit aiNode(const std::string& name)
         // set all members to zero by default
         : mName(name)
         , mParent(NULL)

+ 1 - 1
include/assimp/types.h

@@ -160,7 +160,7 @@ struct aiColor3D
 #ifdef __cplusplus
     aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
     aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {}
-    aiColor3D (float _r) : r(_r), g(_r), b(_r) {}
+    explicit aiColor3D (float _r) : r(_r), g(_r), b(_r) {}
     aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
 
     /** Component-wise comparison */