#include <HxRegData.h>
Public Types | |
enum | RvType { Int, String } |
The type of the data. More... | |
Public Methods | |
HxRegData () | |
Constructor. More... | |
HxRegData (HxString) | |
Constructor. More... | |
HxRegData (int) | |
Constructor. More... | |
HxRegData (const HxRegData &) | |
Constructor. More... | |
~HxRegData () | |
Desstructor. More... | |
HxRegData & | operator= (const HxRegData &) |
Assignment operator. More... | |
RvType | type () const |
Get type of data. More... | |
void | setString (HxString) |
Set string data. More... | |
HxString | getString () const |
Get string data. More... | |
void | setInt (int) |
Set int data. More... | |
int | getInt () const |
Get int data. More... | |
HxString | toString () const |
Output to string. More... | |
STD_OSTREAM & | put (STD_OSTREAM &, int cCode=0) const |
Put on stream. More... |
|
The type of the data.
00041 { Int, String } RvType; |
|
Constructor.
00084 { 00085 _type = String; 00086 new((void*)&(_val._str[0])) HxPnString(HxString()); 00087 } |
|
Constructor.
00091 { 00092 _type = String; 00093 new((void*)&(_val._str[0])) HxPnString(s); 00094 } |
|
Constructor.
00098 { 00099 _type = Int; 00100 _val._int = i; 00101 } |
|
Constructor.
|
|
Desstructor.
00105 { 00106 if (_type == String) 00107 ((HxPnString*)&(_val._str[0]))->~HxPnString(); 00108 } |
|
Assignment operator.
00030 { 00031 if (_type == String) 00032 ((HxPnString*)&(_val._str[0]))->~HxPnString(); 00033 _type = rhs._type; 00034 switch (_type) { 00035 case Int : 00036 _val._int = rhs._val._int; 00037 break; 00038 case String : 00039 new((void*)&(_val._str[0])) 00040 HxPnString(((HxPnString*)&(rhs._val._str[0]))->toString()); 00041 break; 00042 } 00043 return *this; 00044 } |
|
Get type of data.
00112 { 00113 return _type; 00114 } |
|
Set string data.
00118 { 00119 if (_type == String) 00120 ((HxPnString*)&(_val._str[0]))->~HxPnString(); 00121 new((void*)&(_val._str[0])) HxPnString(s); 00122 _type = String; 00123 } |
|
Get string data.
00127 { 00128 return (_type == String) ? 00129 ((HxPnString*)&(_val._str[0]))->toString() : 00130 HxString(); 00131 } |
|
Set int data.
00135 { 00136 if (_type == String) 00137 ((HxPnString*)&(_val._str[0]))->~HxPnString(); 00138 _val._int = i; 00139 _type = Int; 00140 } |
|
Get int data.
00144 { 00145 return (_type == Int) ? _val._int : 0 ; 00146 } |
|
Output to string.
00048 { 00049 switch (_type) { 00050 case Int : 00051 return makeString(_val._int); 00052 case String : 00053 return ((HxPnString*)&(_val._str[0]))->toString(); 00054 default : 00055 return HxString("\"") + __FILE__ + "\", line " + makeString(__LINE__) 00056 + ": Implementation error"; 00057 } 00058 } |
|
Put on stream.
00062 { 00063 HxString quote = cCode ? "\\\"" : "\""; 00064 switch (_type) { 00065 case Int : 00066 os << _val._int; 00067 break; 00068 case String : 00069 os << quote; 00070 #ifdef HxRegData_Debug 00071 (((HxPnString*)&(_val._str[0]))->toString()).dput(os); 00072 #else 00073 os << ((HxPnString*)&(_val._str[0]))->toString(); 00074 #endif 00075 os << quote; 00076 break; 00077 } 00078 return os; 00079 } |