|
From: <cn...@us...> - 2009-08-22 16:05:07
|
Revision: 508
http://hgengine.svn.sourceforge.net/hgengine/?rev=508&view=rev
Author: cnlohr
Date: 2009-08-22 16:04:58 +0000 (Sat, 22 Aug 2009)
Log Message:
-----------
move StrToBool to its own function
Modified Paths:
--------------
Mercury2/src/MercuryNamedResource.cpp
Mercury2/src/MercuryUtil.cpp
Mercury2/src/MercuryUtil.h
Modified: Mercury2/src/MercuryNamedResource.cpp
===================================================================
--- Mercury2/src/MercuryNamedResource.cpp 2009-08-22 06:16:33 UTC (rev 507)
+++ Mercury2/src/MercuryNamedResource.cpp 2009-08-22 16:04:58 UTC (rev 508)
@@ -47,18 +47,8 @@
{
MString tmpret;
if( GetValue( sDataPointer, tmpret ) )
- {
- tmpret = ToUpper( tmpret );
- if( tmpret.compare( "TRUE" ) == 0 ) return 1;
- if( tmpret.compare( "FALSE" ) == 0 ) return 0;
- if( tmpret.compare( "ON" ) == 0 ) return 1;
- if( tmpret.compare( "OFF" ) == 0 ) return 0;
- if( tmpret.compare( "YES" ) == 0 ) return 1;
- if( tmpret.compare( "NO" ) == 0 ) return 0;
+ return StrToBool( tmpret );
- return StrToInt( tmpret ) != 0;
- }
-
if( bSetValue )
SetValueB( sDataPointer, bDefaultValue );
Modified: Mercury2/src/MercuryUtil.cpp
===================================================================
--- Mercury2/src/MercuryUtil.cpp 2009-08-22 06:16:33 UTC (rev 507)
+++ Mercury2/src/MercuryUtil.cpp 2009-08-22 16:04:58 UTC (rev 508)
@@ -151,7 +151,22 @@
return x;
}
+bool StrToBool( const MString & s, bool d )
+{
+ MString tmpret = s;
+ tmpret = ToUpper( tmpret );
+ if( tmpret.compare( "TRUE" ) == 0 ) return 1;
+ if( tmpret.compare( "FALSE" ) == 0 ) return 0;
+ if( tmpret.compare( "ON" ) == 0 ) return 1;
+ if( tmpret.compare( "OFF" ) == 0 ) return 0;
+ if( tmpret.compare( "YES" ) == 0 ) return 1;
+ if( tmpret.compare( "NO" ) == 0 ) return 0;
+
+ return StrToInt( tmpret, d ) != 0;
+}
+
+
void fail_m( const char * message, const char * file, int line )
{
char backtracebuffer[2048];
Modified: Mercury2/src/MercuryUtil.h
===================================================================
--- Mercury2/src/MercuryUtil.h 2009-08-22 06:16:33 UTC (rev 507)
+++ Mercury2/src/MercuryUtil.h 2009-08-22 16:04:58 UTC (rev 508)
@@ -36,6 +36,7 @@
float StrToFloat(const MString & s, float d = 0);
int32_t StrToInt(const MString & s, int32_t d = 0);
+bool StrToBool( const MString & s, bool d = false );
template<typename T>
const T& MAX(const T& t1, const T& t2)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|