Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid conversion constructors by using "explicit" #135

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions include/E57Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected:
{
public:
StructureNode() = delete;
StructureNode( ImageFile destImageFile );
explicit StructureNode( ImageFile destImageFile );

int64_t childCount() const;
bool isDefined( const ustring &pathName ) const;
Expand Down Expand Up @@ -246,8 +246,8 @@ protected:
private:
friend class ImageFile;

StructureNode( std::shared_ptr<StructureNodeImpl> ni ); // internal use only
StructureNode( std::weak_ptr<ImageFileImpl> fileParent ); // internal use only
explicit StructureNode( std::shared_ptr<StructureNodeImpl> ni ); // internal use only
explicit StructureNode( std::weak_ptr<ImageFileImpl> fileParent ); // internal use only

E57_OBJECT_IMPLEMENTATION( StructureNode ) // Internal implementation details, not part of API, must
// be last in object
Expand Down Expand Up @@ -289,7 +289,7 @@ protected:
private:
friend class CompressedVectorNode;

VectorNode( std::shared_ptr<VectorNodeImpl> ni ); // internal use only
explicit VectorNode( std::shared_ptr<VectorNodeImpl> ni ); // internal use only

E57_OBJECT_IMPLEMENTATION( VectorNode ) // Internal implementation details, not part of API, must be
// last in object
Expand Down Expand Up @@ -361,7 +361,7 @@ protected:
private:
friend class CompressedVectorNode;

CompressedVectorReader( std::shared_ptr<CompressedVectorReaderImpl> ni );
explicit CompressedVectorReader( std::shared_ptr<CompressedVectorReaderImpl> ni );

E57_OBJECT_IMPLEMENTATION( CompressedVectorReader ) // Internal implementation details, not
// part of API, must be last in object
Expand All @@ -387,7 +387,7 @@ protected:
private:
friend class CompressedVectorNode;

CompressedVectorWriter( std::shared_ptr<CompressedVectorWriterImpl> ni );
explicit CompressedVectorWriter( std::shared_ptr<CompressedVectorWriterImpl> ni );

E57_OBJECT_IMPLEMENTATION( CompressedVectorWriter ) // Internal implementation details, not
// part of API, must be last in object
Expand Down Expand Up @@ -468,7 +468,7 @@ protected:
//! \cond documentNonPublic The following isn't part of the API, and isn't
//! documented.
private:
IntegerNode( std::shared_ptr<IntegerNodeImpl> ni ); // internal use only
explicit IntegerNode( std::shared_ptr<IntegerNodeImpl> ni ); // internal use only

E57_OBJECT_IMPLEMENTATION( IntegerNode ) // Internal implementation details, not part of API, must be
// last in object
Expand Down Expand Up @@ -516,7 +516,7 @@ protected:
//! \cond documentNonPublic The following isn't part of the API, and isn't
//! documented.
private:
ScaledIntegerNode( std::shared_ptr<ScaledIntegerNodeImpl> ni ); // internal use only
explicit ScaledIntegerNode( std::shared_ptr<ScaledIntegerNodeImpl> ni ); // internal use only

E57_OBJECT_IMPLEMENTATION( ScaledIntegerNode ) // Internal implementation details, not part of
// API, must be last in object
Expand Down Expand Up @@ -554,7 +554,7 @@ protected:
//! \cond documentNonPublic The following isn't part of the API, and isn't
//! documented.
private:
FloatNode( std::shared_ptr<FloatNodeImpl> ni ); // internal use only
explicit FloatNode( std::shared_ptr<FloatNodeImpl> ni ); // internal use only

E57_OBJECT_IMPLEMENTATION( FloatNode ) // Internal implementation details, not part of API, must be
// last in object
Expand Down Expand Up @@ -589,7 +589,7 @@ protected:
//! documented.
private:
friend class StringNodeImpl;
StringNode( std::shared_ptr<StringNodeImpl> ni ); // internal use only
explicit StringNode( std::shared_ptr<StringNodeImpl> ni ); // internal use only

E57_OBJECT_IMPLEMENTATION( StringNode ) // Internal implementation details, not part of API, must be
// last in object
Expand Down Expand Up @@ -627,7 +627,7 @@ protected:
private:
friend class E57XmlParser;

BlobNode( std::shared_ptr<BlobNodeImpl> ni ); // internal use only
explicit BlobNode( std::shared_ptr<BlobNodeImpl> ni ); // internal use only

// Internal use only, create blob already in a file
BlobNode( ImageFile destImageFile, int64_t fileOffset, int64_t length );
Expand Down Expand Up @@ -674,8 +674,8 @@ protected:
//! \cond documentNonPublic The following isn't part of the API, and isn't
//! documented.
private:
ImageFile( double ); // Give a second dummy constructor, better error msg
// for: ImageFile(0)
explicit ImageFile( double ); // Give a second dummy constructor, better error msg
// for: ImageFile(0)

friend class Node;
friend class StructureNode;
Expand All @@ -687,7 +687,7 @@ protected:
friend class StringNode;
friend class BlobNode;

ImageFile( std::shared_ptr<ImageFileImpl> imfi ); // internal use only
explicit ImageFile( std::shared_ptr<ImageFileImpl> imfi ); // internal use only

E57_OBJECT_IMPLEMENTATION( ImageFile ) // Internal implementation details, not part of API, must be
// last in object
Expand Down
2 changes: 1 addition & 1 deletion include/E57SimpleReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace e57
public:
//! @brief This function is the constructor for the reader class
//! @param [in] filePath file path to E57 file
Reader( const ustring &filePath );
explicit Reader( const ustring &filePath );

//! @brief This function returns true if the file is open
bool IsOpen() const;
Expand Down
2 changes: 1 addition & 1 deletion src/CompressedVectorNodeImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace e57
class CompressedVectorNodeImpl : public NodeImpl
{
public:
CompressedVectorNodeImpl( ImageFileImplWeakPtr destImageFile );
explicit CompressedVectorNodeImpl( ImageFileImplWeakPtr destImageFile );
~CompressedVectorNodeImpl() override = default;

NodeType type() const override
Expand Down
2 changes: 1 addition & 1 deletion src/Decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace e57
#endif

protected:
Decoder( unsigned bytestreamNumber );
explicit Decoder( unsigned bytestreamNumber );

unsigned int bytestreamNumber_;
};
Expand Down
2 changes: 1 addition & 1 deletion src/E57XmlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace e57
class E57XmlParser : public DefaultHandler
{
public:
E57XmlParser( ImageFileImplSharedPtr imf );
explicit E57XmlParser( ImageFileImplSharedPtr imf );
~E57XmlParser() override;

void init();
Expand Down
2 changes: 1 addition & 1 deletion src/Encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace e57
virtual void dump( int indent = 0, std::ostream &os = std::cout ) const;
#endif
protected:
Encoder( unsigned bytestreamNumber );
explicit Encoder( unsigned bytestreamNumber );

unsigned bytestreamNumber_;
};
Expand Down
5 changes: 3 additions & 2 deletions src/FloatNodeImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ namespace e57
class FloatNodeImpl : public NodeImpl
{
public:
FloatNodeImpl( ImageFileImplWeakPtr destImageFile, double value = 0, FloatPrecision precision = E57_DOUBLE,
double minimum = E57_DOUBLE_MIN, double maximum = E57_DOUBLE_MAX );
explicit FloatNodeImpl( ImageFileImplWeakPtr destImageFile, double value = 0,
FloatPrecision precision = E57_DOUBLE, double minimum = E57_DOUBLE_MIN,
double maximum = E57_DOUBLE_MAX );
~FloatNodeImpl() override = default;

NodeType type() const override
Expand Down
2 changes: 1 addition & 1 deletion src/ImageFileImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace e57
class ImageFileImpl : public std::enable_shared_from_this<ImageFileImpl>
{
public:
ImageFileImpl( ReadChecksumPolicy policy );
explicit ImageFileImpl( ReadChecksumPolicy policy );
void construct2( const ustring &fileName, const ustring &mode );
void construct2( const char *input, uint64_t size );
std::shared_ptr<StructureNodeImpl> root();
Expand Down
4 changes: 2 additions & 2 deletions src/IntegerNodeImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace e57
class IntegerNodeImpl : public NodeImpl
{
public:
IntegerNodeImpl( ImageFileImplWeakPtr destImageFile, int64_t value = 0, int64_t minimum = 0,
int64_t maximum = 0 );
explicit IntegerNodeImpl( ImageFileImplWeakPtr destImageFile, int64_t value = 0, int64_t minimum = 0,
int64_t maximum = 0 );
~IntegerNodeImpl() override = default;

NodeType type() const override
Expand Down
2 changes: 1 addition & 1 deletion src/NodeImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace e57
friend class Decoder;
friend class Encoder;

NodeImpl( ImageFileImplWeakPtr destImageFile );
explicit NodeImpl( ImageFileImplWeakPtr destImageFile );
NodeImpl &operator=( NodeImpl &n );
virtual NodeImplSharedPtr lookup( const ustring & /*pathName*/ )
{
Expand Down
2 changes: 1 addition & 1 deletion src/ReaderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace e57
class ReaderImpl
{
public:
ReaderImpl( const ustring &filePath );
explicit ReaderImpl( const ustring &filePath );

~ReaderImpl();

Expand Down
9 changes: 5 additions & 4 deletions src/ScaledIntegerNodeImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ namespace e57
class ScaledIntegerNodeImpl : public NodeImpl
{
public:
ScaledIntegerNodeImpl( ImageFileImplWeakPtr destImageFile, int64_t value = 0, int64_t minimum = 0,
int64_t maximum = 0, double scale = 1.0, double offset = 0.0 );
explicit ScaledIntegerNodeImpl( ImageFileImplWeakPtr destImageFile, int64_t value = 0, int64_t minimum = 0,
int64_t maximum = 0, double scale = 1.0, double offset = 0.0 );

ScaledIntegerNodeImpl( ImageFileImplWeakPtr destImageFile, double scaledValue = 0., double scaledMinimum = 0.,
double scaledMaximum = 0., double scale = 1.0, double offset = 0.0 );
explicit ScaledIntegerNodeImpl( ImageFileImplWeakPtr destImageFile, double scaledValue = 0.,
double scaledMinimum = 0., double scaledMaximum = 0., double scale = 1.0,
double offset = 0.0 );

~ScaledIntegerNodeImpl() override = default;

Expand Down
2 changes: 1 addition & 1 deletion src/StructureNodeImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace e57
class StructureNodeImpl : public NodeImpl
{
public:
StructureNodeImpl( ImageFileImplWeakPtr destImageFile );
explicit StructureNodeImpl( ImageFileImplWeakPtr destImageFile );
~StructureNodeImpl() override = default;

NodeType type() const override;
Expand Down