bool and Switch reworked
- Switch now stores its value as an unsigned char, which gives it the same storage requirement as bool (1 byte). The original implementation had both bool+word (1+XXX bytes storage), an intermediate version with bool+enum had 8 bytes (1+4 + boundary alignment). - The reading code in boolIO.C and SwitchIO.C is now identical except for the error message. This allows Switch to accept '1', '0' as logical values, and allows bool to accept 'yes', 'no' etc. as logical values. - The Switch text translation of a bool value is now true/false instead of on/off. This is partly personal preference, but we could also output the same text when writing a bool value to Ostream. - Switch gets null and integer constructors so it feels more like bool. Added Switch::operator=(const bool); - Low-level types can be used for the constructors, and low-level return values are used for the greatest flexibility (and speed). - Fixed bugginess with dictionary lookup. The previous version actually used a bool instead of a Switch and bombed on 'on/off'. TODO? perhaps don't worry about the error message and just call the Switch routines from bool.
Showing
- src/OpenFOAM/primitives/bools/Switch/Switch.C 35 additions, 34 deletionssrc/OpenFOAM/primitives/bools/Switch/Switch.C
- src/OpenFOAM/primitives/bools/Switch/Switch.H 68 additions, 46 deletionssrc/OpenFOAM/primitives/bools/Switch/Switch.H
- src/OpenFOAM/primitives/bools/Switch/SwitchIO.C 44 additions, 6 deletionssrc/OpenFOAM/primitives/bools/Switch/SwitchIO.C
- src/OpenFOAM/primitives/bools/bool/bool.C 2 additions, 5 deletionssrc/OpenFOAM/primitives/bools/bool/bool.C
- src/OpenFOAM/primitives/bools/bool/bool.H 2 additions, 2 deletionssrc/OpenFOAM/primitives/bools/bool/bool.H
- src/OpenFOAM/primitives/bools/bool/boolIO.C 30 additions, 17 deletionssrc/OpenFOAM/primitives/bools/bool/boolIO.C