#include <HxValue.h>
Constructors | |
| HxValue (int i=0) | |
| Construction from native integer. More... | |
| HxValue (double d) | |
| Construction from native double. More... | |
| HxValue (HxScalarInt i) | |
| Construction from scalar integer. More... | |
| HxValue (HxScalarDouble d) | |
| Construction from scalar double. More... | |
| HxValue (HxVec2Int v) | |
| Construction from vector of 2 integers. More... | |
| HxValue (HxVec2Double v) | |
| Construction from vector of 2 doubles. More... | |
| HxValue (HxVec3Int v) | |
| Construction from vector of 3 integers. More... | |
| HxValue (HxVec3Double v) | |
| Construction from vector of 3 doubles. More... | |
| HxValue (HxComplex v) | |
| Construction from complex. More... | |
Inquiry | |
| Tag | tag () const |
| The type of the value stored. More... | |
Data access | |
| HxScalarInt & | HxScalarIntValue () |
| Access value as HxScalarInt. More... | |
| HxScalarDouble & | HxScalarDoubleValue () |
| Access value as HxScalarDouble. More... | |
| HxVec2Int & | HxVec2IntValue () |
| Access value as HxVec2Int. More... | |
| HxVec2Double & | HxVec2DoubleValue () |
| Access value as HxVec2Double. More... | |
| HxVec3Int & | HxVec3IntValue () |
| Access value as HxVec3Int. More... | |
| HxVec3Double & | HxVec3DoubleValue () |
| Access value as HxVec3Double. More... | |
| HxComplex & | HxComplexValue () |
| Access value as HxComplex. More... | |
Conversion | |
| operator HxScalarInt () const | |
| Cast to HxScalarInt. More... | |
| operator HxScalarDouble () const | |
| Cast to HxScalarDouble. More... | |
| operator HxVec2Int () const | |
| Cast to HxVec2Int. More... | |
| operator HxVec2Double () const | |
| Cast to HxVec2Double. More... | |
| operator HxVec3Int () const | |
| Cast to HxVec3Int. More... | |
| operator HxVec3Double () const | |
| Cast to HxVec3Double. More... | |
| operator HxComplex () const | |
| Cast to HxComplex. More... | |
Public Types | |
| enum | Tag { SI, SD, V2I, V2D, V3I, V3D, CPL } |
| The arithmetic data types that may be stored. More... | |
Public Methods | |
| HxString | toString () const |
Friends | |
| STD_OSTREAM & | operator<< (STD_OSTREAM &os, const HxValue val) |
An HxValue is capable of storing each of the arithmetic data types. HxValue is used to pass arbitrary values using a single function interface. HxValue is not meant to do arithmetic on arbitrary values and hence no such operations are defined in the interface.
|
|
The arithmetic data types that may be stored. SI: scalar integer, SD: scalar double, V2I: vector of 2 integers, V2D: vector of 2 doubles, V3I: vector of 3 integers, V3D: vector of 3 doubles. CPL: complex number (2 doubles).
00042 { SI, SD, V2I, V2D, V3I, V3D, CPL };
|
|
|
Construction from native integer.
00159 {
00160 _tag._tag = SI;
00161 new(&_val[0]) HxScalarInt(v);
00162 }
|
|
|
Construction from native double.
00166 {
00167 _tag._tag = SD;
00168 new(&_val[0]) HxScalarDouble(v);
00169 }
|
|
|
Construction from scalar integer.
00173 {
00174 _tag._tag = SI;
00175 new(&_val[0]) HxScalarInt(v);
00176 }
|
|
|
Construction from scalar double.
00180 {
00181 _tag._tag = SD;
00182 new(&_val[0]) HxScalarDouble(v);
00183 }
|
|
|
Construction from vector of 2 integers.
00187 {
00188 _tag._tag = V2I;
00189 new(&_val[0]) HxVec2Int(v);
00190 }
|
|
|
Construction from vector of 2 doubles.
00194 {
00195 _tag._tag = V2D;
00196 new(&_val[0]) HxVec2Double(v);
00197 }
|
|
|
Construction from vector of 3 integers.
00201 {
00202 _tag._tag = V3I;
00203 new(&_val[0]) HxVec3Int(v);
00204 }
|
|
|
Construction from vector of 3 doubles.
00208 {
00209 _tag._tag = V3D;
00210 new(&_val[0]) HxVec3Double(v);
00211 }
|
|
|
Construction from complex.
00215 {
00216 _tag._tag = CPL;
00217 new(&_val[0]) HxComplex(v);
00218 }
|
|
|
The type of the value stored.
00222 {
00223 return _tag._tag;
00224 }
|
|
|
Access value as HxScalarInt.
00228 {
00229 check(SI);
00230 return *(HxScalarInt *) &_val[0];
00231 }
|
|
|
Access value as HxScalarDouble.
00235 {
00236 check(SD);
00237 return *(HxScalarDouble *) &_val[0];
00238 }
|
|
|
Access value as HxVec2Int.
00242 {
00243 check(V2I);
00244 return *(HxVec2Int *) &_val[0];
00245 }
|
|
|
Access value as HxVec2Double.
00249 {
00250 check(V2D);
00251 return *(HxVec2Double *) &_val[0];
00252 }
|
|
|
Access value as HxVec3Int.
00256 {
00257 check(V3I);
00258 return *(HxVec3Int *) &_val[0];
00259 }
|
|
|
Access value as HxVec3Double.
00263 {
00264 check(V3D);
00265 return *(HxVec3Double *) &_val[0];
00266 }
|
|
|
Access value as HxComplex.
00270 {
00271 check(CPL);
00272 return *(HxComplex *) &_val[0];
00273 }
|
|
|
Cast to HxScalarInt.
00277 {
00278 switch(_tag._tag)
00279 {
00280 case SI: return (HxScalarInt) *(HxScalarInt *) &_val[0];
00281 case SD: return (*(HxScalarDouble *) &_val[0]).operator HxScalarInt();
00282 case V2I: return (HxScalarInt) *(HxVec2Int *) &_val[0];
00283 case V2D: return (HxScalarInt) *(HxVec2Double *) &_val[0];
00284 case V3I: return (HxScalarInt) *(HxVec3Int *) &_val[0];
00285 case V3D: return (HxScalarInt) *(HxVec3Double *) &_val[0];
00286 case CPL: return (HxScalarInt) *(HxComplex *) &_val[0];
00287 default: return (HxScalarInt) *(HxScalarInt *) &_val[0];
00288 }
00289 }
|
|
|
Cast to HxScalarDouble.
00293 {
00294 switch(_tag._tag)
00295 {
00296 case SI: return (HxScalarDouble) *(HxScalarInt *) &_val[0];
00297 case SD: return (HxScalarDouble) *(HxScalarDouble *) &_val[0];
00298 case V2I: return (HxScalarDouble) *(HxVec2Int *) &_val[0];
00299 case V2D: return (HxScalarDouble) *(HxVec2Double *) &_val[0];
00300 case V3I: return (HxScalarDouble) *(HxVec3Int *) &_val[0];
00301 case V3D: return (HxScalarDouble) *(HxVec3Double *) &_val[0];
00302 case CPL: return (HxScalarDouble) *(HxComplex *) &_val[0];
00303 default: return (HxScalarDouble) *(HxScalarDouble *) &_val[0];
00304 }
00305 }
|
|
|
Cast to HxVec2Int.
00309 {
00310 switch(_tag._tag)
00311 {
00312 case SI: return (HxVec2Int) *(HxScalarInt *) &_val[0];
00313 case SD: return (HxVec2Int) *(HxScalarDouble *) &_val[0];
00314 case V2I: return (HxVec2Int) *(HxVec2Int *) &_val[0];
00315 case V2D: return (HxVec2Int) *(HxVec2Double *) &_val[0];
00316 case V3I: return (HxVec2Int) *(HxVec3Int *) &_val[0];
00317 case V3D: return (HxVec2Int) *(HxVec3Double *) &_val[0];
00318 case CPL: return (HxVec2Int) *(HxComplex *) &_val[0];
00319 default: return (HxVec2Int) *(HxVec2Int *) &_val[0];
00320 }
00321 }
|
|
|
Cast to HxVec2Double.
00325 {
00326 switch(_tag._tag)
00327 {
00328 case SI: return (HxVec2Double) *(HxScalarInt *) &_val[0];
00329 case SD: return (HxVec2Double) *(HxScalarDouble *) &_val[0];
00330 case V2I: return (HxVec2Double) *(HxVec2Int *) &_val[0];
00331 case V2D: return (HxVec2Double) *(HxVec2Double *) &_val[0];
00332 case V3I: return (HxVec2Double) *(HxVec3Int *) &_val[0];
00333 case V3D: return (HxVec2Double) *(HxVec3Double *) &_val[0];
00334 case CPL: return (HxVec2Double) *(HxComplex *) &_val[0];
00335 default: return (HxVec2Double) *(HxVec2Double *) &_val[0];
00336 }
00337 }
|
|
|
Cast to HxVec3Int.
00341 {
00342 switch(_tag._tag)
00343 {
00344 case SI: return (HxVec3Int) *(HxScalarInt *) &_val[0];
00345 case SD: return (HxVec3Int) *(HxScalarDouble *) &_val[0];
00346 case V2I: return (HxVec3Int) *(HxVec2Int *) &_val[0];
00347 case V2D: return (HxVec3Int) *(HxVec2Double *) &_val[0];
00348 case V3I: return (HxVec3Int) *(HxVec3Int *) &_val[0];
00349 case V3D: return (HxVec3Int) *(HxVec3Double *) &_val[0];
00350 case CPL: return (HxVec3Int) *(HxComplex *) &_val[0];
00351 default: return (HxVec3Int) *(HxVec3Int *) &_val[0];
00352 }
00353 }
|
|
|
Cast to HxVec3Double.
00357 {
00358 switch(_tag._tag)
00359 {
00360 case SI: return (HxVec3Double) *(HxScalarInt *) &_val[0];
00361 case SD: return (HxVec3Double) *(HxScalarDouble *) &_val[0];
00362 case V2I: return (HxVec3Double) *(HxVec2Int *) &_val[0];
00363 case V2D: return (HxVec3Double) *(HxVec2Double *) &_val[0];
00364 case V3I: return (HxVec3Double) *(HxVec3Int *) &_val[0];
00365 case V3D: return (HxVec3Double) *(HxVec3Double *) &_val[0];
00366 case CPL: return (HxVec3Double) *(HxComplex *) &_val[0];
00367 default: return (HxVec3Double) *(HxVec3Double *) &_val[0];
00368 }
00369 }
|
|
|
Cast to HxComplex.
00373 {
00374 switch(_tag._tag)
00375 {
00376 case SI: return (HxComplex) *(HxScalarInt *) &_val[0];
00377 case SD: return (HxComplex) *(HxScalarDouble *) &_val[0];
00378 case V2I: return (HxComplex) *(HxVec2Int *) &_val[0];
00379 case V2D: return (HxComplex) *(HxVec2Double *) &_val[0];
00380 case V3I: return (HxComplex) *(HxVec3Int *) &_val[0];
00381 case V3D: return (HxComplex) *(HxVec3Double *) &_val[0];
00382 case CPL: return (HxComplex) *(HxComplex *) &_val[0];
00383 default: return (HxComplex) *(HxComplex *) &_val[0];
00384 }
00385 }
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001