Changed classes inherited from std::string from is-a to has-a std::string.
* Removed std::string base class for SDAI_String and SDAI_Binary. * Added necessary std::string interface functions to SDAI_String and SDAI_Binary. * Removed msvc specific code from sdaiString.h
This commit is contained in:
+24
-1
@@ -12,11 +12,34 @@
|
||||
#include <sstream>
|
||||
#include <sdai.h>
|
||||
|
||||
SDAI_Binary::SDAI_Binary( const char * str, int max ) {
|
||||
content = std::string( str, max );
|
||||
}
|
||||
|
||||
SDAI_Binary::SDAI_Binary( const std::string & s ) {
|
||||
content = std::string( s );
|
||||
}
|
||||
|
||||
SDAI_Binary::~SDAI_Binary( void ) {
|
||||
}
|
||||
|
||||
SDAI_Binary & SDAI_Binary::operator= ( const char * s ) {
|
||||
std::string::operator= ( s );
|
||||
content = std::string( s );
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SDAI_Binary::clear( void ) {
|
||||
content.clear();
|
||||
}
|
||||
|
||||
bool SDAI_Binary::empty( void ) const {
|
||||
return content.empty();
|
||||
}
|
||||
|
||||
const char * SDAI_Binary::c_str( void ) const {
|
||||
return content.c_str();
|
||||
}
|
||||
|
||||
void SDAI_Binary::STEPwrite( ostream & out ) const {
|
||||
const char * str = 0;
|
||||
if( empty() ) {
|
||||
|
||||
+10
-9
@@ -14,21 +14,22 @@
|
||||
* and is not subject to copyright.
|
||||
*/
|
||||
|
||||
class SCL_DAI_EXPORT SDAI_Binary : public std::string {
|
||||
public:
|
||||
class SCL_DAI_EXPORT SDAI_Binary {
|
||||
private:
|
||||
std::string content;
|
||||
public:
|
||||
|
||||
//constructor(s) & destructor
|
||||
SDAI_Binary( const char * str = 0, int max = 0 )
|
||||
: std::string( str, max ) { }
|
||||
|
||||
SDAI_Binary( const std::string & s ) : std::string( s ) { }
|
||||
|
||||
|
||||
~SDAI_Binary() { }
|
||||
SDAI_Binary( const char * str = 0, int max = 0 );
|
||||
SDAI_Binary( const std::string & s );
|
||||
~SDAI_Binary( void );
|
||||
|
||||
// operators
|
||||
SDAI_Binary & operator= ( const char * s );
|
||||
|
||||
void clear( void );
|
||||
bool empty( void ) const;
|
||||
const char * c_str( void ) const;
|
||||
// format for STEP
|
||||
const char * asStr() const {
|
||||
return c_str();
|
||||
|
||||
+34
-2
@@ -12,11 +12,43 @@
|
||||
#include <sdai.h>
|
||||
#include <sstream>
|
||||
|
||||
SDAI_String::SDAI_String( const char * str, int max ) {
|
||||
content = std::string( str, max );
|
||||
}
|
||||
|
||||
SDAI_String::SDAI_String( const std::string & s ) {
|
||||
content = std::string( s );
|
||||
}
|
||||
|
||||
SDAI_String::SDAI_String( const SDAI_String & s ) {
|
||||
content = std::string( s.c_str() );
|
||||
}
|
||||
|
||||
SDAI_String::~SDAI_String( void ) {
|
||||
}
|
||||
|
||||
SDAI_String & SDAI_String::operator= ( const char * s ) {
|
||||
std::string::operator= ( s );
|
||||
content = std::string( s );
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool SDAI_String::operator== ( const char * s ) const {
|
||||
return ( content == s );
|
||||
}
|
||||
|
||||
void SDAI_String::clear( void ) {
|
||||
content.clear();
|
||||
}
|
||||
|
||||
bool SDAI_String::empty( void ) const {
|
||||
return content.empty();
|
||||
}
|
||||
|
||||
const char * SDAI_String::c_str( void ) const {
|
||||
return content.c_str();
|
||||
}
|
||||
|
||||
|
||||
void SDAI_String::STEPwrite( ostream & out ) const {
|
||||
out << c_str();
|
||||
}
|
||||
@@ -46,7 +78,7 @@ Severity SDAI_String::STEPread( istream & in, ErrorDescriptor * err ) {
|
||||
|
||||
// extract the string from the inputstream
|
||||
string s = ToExpressStr( in, err );
|
||||
operator+= ( s );
|
||||
content += s;
|
||||
|
||||
// retrieve current severity
|
||||
Severity sev = err -> severity();
|
||||
|
||||
+12
-15
@@ -13,27 +13,24 @@
|
||||
|
||||
#include <scl_export.h>
|
||||
|
||||
/*
|
||||
* In MSVC2010 std::string::npos is no longer exported from it's libraries.
|
||||
* This might be a bug but following code make sure the member is known
|
||||
* and fixes the linker issue for this symbol.
|
||||
*/
|
||||
#if defined(__MSVC__) && _MSC_VER == 1600 /* MSVC2010 version */
|
||||
const std::string::size_type std::string::npos = size_t(-1);
|
||||
#endif
|
||||
|
||||
class SCL_DAI_EXPORT SDAI_String : public std::string {
|
||||
class SCL_DAI_EXPORT SDAI_String {
|
||||
private:
|
||||
std::string content;
|
||||
public:
|
||||
|
||||
//constructor(s) & destructor
|
||||
SDAI_String( const char * str = 0, int max = 0 ) : std::string( str, max ) { }
|
||||
SDAI_String( const std::string & s ) : std::string( s ) { }
|
||||
SDAI_String( const SDAI_String & s ) : std::string( s ) { }
|
||||
~SDAI_String() { }
|
||||
SDAI_String( const char * str = 0, int max = 0 );
|
||||
SDAI_String( const std::string & s );
|
||||
SDAI_String( const SDAI_String & s );
|
||||
~SDAI_String( void );
|
||||
|
||||
// operators
|
||||
SDAI_String & operator= ( const char * s );
|
||||
|
||||
bool operator== ( const char * s ) const;
|
||||
|
||||
void clear( void );
|
||||
bool empty( void ) const;
|
||||
const char * c_str( void ) const;
|
||||
// format for STEP
|
||||
const char * asStr( std::string & s ) const {
|
||||
return s.c_str();
|
||||
|
||||
@@ -560,7 +560,7 @@ Severity FindStartOfInstance( istream & in, std::string & inst ) {
|
||||
case '\'': // get past the string
|
||||
in.putback( c );
|
||||
tmp.STEPread( in, &errs );
|
||||
inst.append( tmp );
|
||||
inst.append( tmp.c_str() );
|
||||
break;
|
||||
|
||||
case '\0': // problem in input ?
|
||||
@@ -591,7 +591,7 @@ Severity SkipInstance( istream & in, std::string & inst ) {
|
||||
case '\'': // get past the string
|
||||
in.putback( c );
|
||||
tmp.STEPread( in, &errs );
|
||||
inst.append( tmp );
|
||||
inst.append( tmp.c_str() );
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -130,8 +130,9 @@ ErrorDescriptor::ErrorDescriptor( Severity s, DebugLevel d ) : _severity( s ) {
|
||||
if( d != DEBUG_OFF ) {
|
||||
_debug_level = d;
|
||||
}
|
||||
_userMsg.clear();
|
||||
_detailMsg.clear();
|
||||
}
|
||||
|
||||
ErrorDescriptor::~ErrorDescriptor( void ) {
|
||||
}
|
||||
|
||||
void ErrorDescriptor::UserMsg( const char * msg ) {
|
||||
|
||||
@@ -57,16 +57,17 @@ enum DebugLevel {
|
||||
******************************************************************/
|
||||
|
||||
class SCL_UTILS_EXPORT ErrorDescriptor {
|
||||
protected:
|
||||
private:
|
||||
std::string _userMsg, _detailMsg;
|
||||
protected:
|
||||
Severity _severity;
|
||||
|
||||
static DebugLevel _debug_level;
|
||||
static ostream * _out; // note this will not be persistent
|
||||
|
||||
std::string _userMsg, _detailMsg;
|
||||
public:
|
||||
ErrorDescriptor( Severity s = SEVERITY_NULL,
|
||||
DebugLevel d = DEBUG_OFF );
|
||||
~ErrorDescriptor( void );
|
||||
|
||||
void PrintContents( ostream & out = cout ) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user