Update of /cvsroot/plib/plib/src/pui
In directory sc8-pr-cvs1:/tmp/cvs-serv16355
Modified Files:
pu.h puValue.cxx
Log Message:
John Fay's addition of a boolean puValue
Index: pu.h
===================================================================
RCS file: /cvsroot/plib/plib/src/pui/pu.h,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -d -r1.140 -r1.141
--- pu.h 26 Jun 2003 11:31:07 -0000 1.140
+++ pu.h 12 Jul 2003 00:45:58 -0000 1.141
@@ -380,10 +380,12 @@
int integer ;
float floater ;
char *string ;
+ bool boolean ;
int *res_integer ;
float *res_floater ;
char *res_string ;
+ bool *res_bool ;
int string_size ;
[...96 lines suppressed...]
+
void getValue ( int *i ) { re_eval () ; *i = *getIntegerp () ; }
void getValue ( float *f ) { re_eval () ; *f = *getFloaterp () ; }
void getValue ( char **s ) { re_eval () ; *s = getStringp () ; }
@@ -509,6 +537,7 @@
}
void getValue ( char *s ) { getValue ( s, PUSTRING_MAX ) ; } /* Obsolete ! */
+ void getValue ( bool *b ) { re_eval () ; *b = *getBooleanp () ; }
int getValue ( void ) { return getIntegerValue () ; } /* Obsolete ! */
@@ -516,6 +545,7 @@
float getFloatValue ( void ) { re_eval () ; return *getFloaterp () ; }
char getCharValue ( void ) { re_eval () ; return getStringp ()[0]; }
char *getStringValue ( void ) { re_eval () ; return getStringp () ; }
+ bool getBooleanValue ( void ) { re_eval () ; return *getBooleanp () ; }
/* RTTI */
ulRTTItypeid getTypeInfo ( void ) const { return RTTI_vinfo () ; }
Index: puValue.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/pui/puValue.cxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- puValue.cxx 7 Feb 2003 17:01:04 -0000 1.24
+++ puValue.cxx 12 Jul 2003 00:45:58 -0000 1.25
@@ -84,6 +84,8 @@
if ( *res_integer != strtoint ( string ) )
sprintf ( string, "%d", *res_integer ) ;
+ boolean = ( *res_integer != 0 ) ;
+
puPostRefresh () ;
}
else if ( res_floater != NULL )
@@ -97,12 +99,29 @@
if ( *res_floater != strtod ( string, NULL ) )
sprintf ( string, "%g", *res_floater ) ;
+ boolean = ( *res_floater != 0.0f ) ;
+
puPostRefresh () ;
}
else if ( res_string != NULL )
{
integer = strtoint ( res_string ) ;
floater = (float) strtod ( res_string, NULL ) ;
+ boolean = ( strcmp ( res_string, "0" ) != 0 ) ;
+ puPostRefresh () ;
+ }
+ else if ( res_bool != NULL )
+ {
+ integer = *res_bool ? 1 : 0 ;
+ floater = *res_bool ? 1.0f : 0.0f ;
+
+ /*
+ Needed for puInput / puLargeInput:
+ Do not modify the string value unless necessary
+ */
+ if ( *res_bool != ( strcmp ( string, "0" ) != 0 ) )
+ sprintf ( string, "%d", *res_bool ? "1" : "0" ) ;
+
puPostRefresh () ;
}
}
@@ -152,6 +171,7 @@
{
*getIntegerp () = strtoint ( s ) ;
*getFloaterp () = (float) strtod ( s, NULL ) ;
+ *getBooleanp () = ( strcmp ( s, "0" ) != 0 ) ;
}
puPostRefresh () ;
|