Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Value Class Reference

#include <parser.h>

Collaboration diagram for Value:

Collaboration graph
List of all members.

Public Types

enum  ValueType {
  NumberType = 0, StringType = 1, ArrayType = 2, HashType = 3,
  BooleanType = 4
}

Public Member Functions

ArraygetArray () const
bool getBoolean () const
HashgetHash () const
double getNumber () const
string getString () const
ValueType getType () const
 Value (bool)
 Value (Hash *)
 Value (Array *)
 Value (string)
 Value (double)
 ~Value ()

Private Attributes

union {
   Array *   a
   double   d
   Hash *   h
   string *   s
data
ValueType type

Member Enumeration Documentation

enum Value::ValueType
 

Enumeration values:
NumberType 
StringType 
ArrayType 
HashType 
BooleanType 

Definition at line 51 of file parser.h.

00051                    {
00052         NumberType     = 0,
00053         StringType     = 1,
00054         ArrayType      = 2,
00055         HashType       = 3,
00056         BooleanType    = 4
00057     };


Constructor & Destructor Documentation

Value::Value double   ) 
 

Definition at line 15 of file parser.cpp.

References data, NumberType, and type.

00016 {
00017     type = NumberType;
00018     data.d = d;
00019 }

Value::Value string   ) 
 

Definition at line 21 of file parser.cpp.

References data, StringType, and type.

00022 {
00023     type = StringType;
00024     data.s = new string(s);
00025 }

Value::Value Array  ) 
 

Definition at line 27 of file parser.cpp.

References a, ArrayType, data, and type.

00028 {
00029     type = ArrayType;
00030     data.a = a;
00031 }

Value::Value Hash  ) 
 

Definition at line 33 of file parser.cpp.

References data, h, HashType, and type.

00034 {
00035     type = HashType;
00036     data.h = h;
00037 }

Value::Value bool   ) 
 

Definition at line 39 of file parser.cpp.

References BooleanType, data, and type.

00040 {
00041     type = BooleanType;
00042     data.d = b ? 1.0 : 0.0;
00043 }

Value::~Value  ) 
 

Definition at line 45 of file parser.cpp.

References ArrayType, data, HashType, StringType, and type.

00046 {
00047     if (type == StringType)
00048     {
00049         delete data.s;
00050     }
00051     else if (type == ArrayType)
00052     {
00053         if (data.a != NULL)
00054         {
00055             for (unsigned int i = 0; i < data.a->size(); i++)
00056                 delete (*data.a)[i];
00057             delete data.a;
00058         }
00059     }
00060     else if (type == HashType)
00061     {
00062         if (data.h != NULL)
00063         {
00064 #if 0
00065             Hash::iterator iter = data.h->begin();
00066             while (iter != data.h->end())
00067             {
00068                 delete iter->second;
00069                 iter++;
00070             }
00071 #endif
00072             delete data.h;
00073         }
00074     }
00075 }


Member Function Documentation

Array * Value::getArray  )  const
 

Definition at line 94 of file parser.cpp.

References data.

Referenced by AssociativeArray::getRotation(), AssociativeArray::getVector(), ReadAsterismList(), and ReadCelestiaConfig().

00095 {
00096     // ASSERT(type == ArrayType);
00097     return data.a;
00098 }

bool Value::getBoolean  )  const
 

Definition at line 106 of file parser.cpp.

References data.

Referenced by AssociativeArray::getBoolean().

00107 {
00108     // ASSERT(type == BooleanType);
00109     return (data.d != 0.0);
00110 }

Hash * Value::getHash  )  const
 

Definition at line 100 of file parser.cpp.

References data.

Referenced by CreateOrbit(), CreatePlanet(), StarDatabase::load(), DSODatabase::load(), LoadCelestiaMesh(), LoadSolarSystemObjects(), LoadVirtualTexture(), CommandParser::parseCommand(), ReadCelestiaConfig(), ReadDestinationList(), and ReadFavoritesList().

00101 {
00102     // ASSERT(type == HashType);
00103     return data.h;
00104 }

double Value::getNumber  )  const
 

Definition at line 82 of file parser.cpp.

References data.

Referenced by AssociativeArray::getNumber(), AssociativeArray::getRotation(), and AssociativeArray::getVector().

00083 {
00084     // ASSERT(type == NumberType);
00085     return data.d;
00086 }

string Value::getString  )  const
 

Definition at line 88 of file parser.cpp.

References data.

Referenced by AssociativeArray::getString(), and ReadCelestiaConfig().

00089 {
00090     // ASSERT(type == StringType);
00091     return *data.s;
00092 }

Value::ValueType Value::getType  )  const
 

Definition at line 77 of file parser.cpp.

References type.

Referenced by CreateOrbit(), CreatePlanet(), AssociativeArray::getBoolean(), AssociativeArray::getNumber(), AssociativeArray::getRotation(), AssociativeArray::getString(), AssociativeArray::getVector(), StarDatabase::load(), DSODatabase::load(), LoadCelestiaMesh(), LoadSolarSystemObjects(), LoadVirtualTexture(), CommandParser::parseCommand(), ReadAsterismList(), ReadCelestiaConfig(), ReadDestinationList(), and ReadFavoritesList().

00078 {
00079     return type;
00080 }


Member Data Documentation

Array* Value::a [private]
 

Definition at line 80 of file parser.h.

Referenced by Value().

double Value::d [private]
 

Definition at line 79 of file parser.h.

union { ... } Value::data [private]
 

Referenced by getArray(), getBoolean(), getHash(), getNumber(), getString(), Value(), and ~Value().

Hash* Value::h [private]
 

Definition at line 81 of file parser.h.

Referenced by Value().

string* Value::s [private]
 

Definition at line 78 of file parser.h.

ValueType Value::type [private]
 

Definition at line 75 of file parser.h.

Referenced by getType(), Value(), and ~Value().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:41 2006 for Celestia by  doxygen 1.4.1