add Copy and =operators to satisfy cppcheck

This commit is contained in:
Isaac Connor 2017-11-16 09:15:04 -05:00
parent d411ed329b
commit a956ffe7b3
3 changed files with 20 additions and 9 deletions

View File

@ -43,7 +43,7 @@ public:
inline Box()
{
}
inline Box( int p_size ) : lo( 0, 0 ), hi ( p_size-1, p_size-1 ), size( Coord::Range( hi, lo ) ) { }
explicit inline Box( int p_size ) : lo( 0, 0 ), hi ( p_size-1, p_size-1 ), size( Coord::Range( hi, lo ) ) { }
inline Box( int p_x_size, int p_y_size ) : lo( 0, 0 ), hi ( p_x_size-1, p_y_size-1 ), size( Coord::Range( hi, lo ) ) { }
inline Box( int lo_x, int lo_y, int hi_x, int hi_y ) : lo( lo_x, lo_y ), hi( hi_x, hi_y ), size( Coord::Range( hi, lo ) ) { }
inline Box( const Coord &p_lo, const Coord &p_hi ) : lo( p_lo ), hi( p_hi ), size( Coord::Range( hi, lo ) ) { }

View File

@ -215,6 +215,7 @@ ConfigItem::ConfigItem( const char *p_name, const char *p_value, const char *con
accessed = false;
}
ConfigItem::ConfigItem( const ConfigItem &item ) {
name = new char[strlen(item.name)+1];
strcpy( name, item.name );
@ -227,6 +228,17 @@ ConfigItem::ConfigItem( const ConfigItem &item ) {
accessed = false;
}
void ConfigItem::Copy( const ConfigItem &item ) {
name = new char[strlen(item.name)+1];
strcpy( name, item.name );
value = new char[strlen(item.value)+1];
strcpy( value, item.value );
type = new char[strlen(item.type)+1];
strcpy( type, item.type );
//Info( "Created new config item %s = %s (%s)\n", name, value, type );
accessed = false;
}
ConfigItem::~ConfigItem() {
delete[] name;

View File

@ -31,14 +31,13 @@ private:
int x, y;
public:
inline Coord() : x(0), y(0)
{
}
inline Coord( int p_x, int p_y ) : x(p_x), y(p_y)
{
}
inline Coord( const Coord &p_coord ) : x(p_coord.x), y(p_coord.y)
{
inline Coord() : x(0), y(0) { }
inline Coord( int p_x, int p_y ) : x(p_x), y(p_y) { }
inline Coord( const Coord &p_coord ) : x(p_coord.x), y(p_coord.y) { }
inline Coord &operator =( const Coord &coord ) {
x = coord.x;
y = coord.y;
return *this;
}
inline int &X() { return( x ); }
inline const int &X() const { return( x ); }