Result Class Reference

A generic value storage class. More...

#include <Result.hpp>

List of all members.

Public Member Functions

 Result ()
 Result (void *vpValue, size_t size, std::string strType="void*")
 Result (int iValue)
 Result (double dValue)
 Result (bool bValue)
 Result (Result *pres)
void setValue (void *vpValue, size_t size, std::string strType)
void setValue (double dValue)
void setValue (int iValue)
void setValue (bool bValue)
void setValue (Result *pres)
void * getValue () const
double toDouble () const
int toInt () const
bool toBool () const
size_t getSize () const


Detailed Description

A generic value storage class.

Author:
Stephen E. Baker
Date:
2006-2007
The original idea of this class was to create a type that could be cast to or from any other type. The result fell somewhat short of that dream and is a type which can be cast from any type back to the same type, and in some cases a few others.
Note:
The resulting class could be replaced by one using templates (otherwise called generics) with some tradeoffs.


Constructor & Destructor Documentation

Result::Result (  ) 

Creates a new empty result object.

Result::Result ( void *  vpValue,
size_t  size,
std::string  strType = "void*" 
)

Creates a result object storing an arbitrary block of memory.

Parameters:
[in] vpValue A pointer to the block of memory to be stored.
[in] size The size in bytes of the memory to be stored.
[in] strType A string specifying the type of value stored in the memory being copied.

Result::Result ( int  iValue  ) 

Creates a result object storing an int.

Parameters:
[in] iValue The int to be stored

Result::Result ( double  dValue  ) 

Creates a result object storing a double.

Parameters:
[in] dValue The double to be stored

Result::Result ( bool  bValue  ) 

Creates a result object storing a bool.

Parameters:
[in] bValue The bool to be stored

Result::Result ( Result pres  ) 

Creates a result object storing the contents of another Result object.

Parameters:
[in] pres The result to be copied.


Member Function Documentation

size_t Result::getSize (  )  const

Returns the size of the data stored in the result.

void * Result::getValue (  )  const

Returns a pointer to the value stored in this result.

Note:
When the value is copied into the result it loses it's type information and must be cast back.

void Result::setValue ( Result pres  ) 

Sets this result to store the contents of another result.

Parameters:
[in] pres The result to be copied.

void Result::setValue ( bool  bValue  ) 

Sets this result to store a bool.

Parameters:
[in] bValue The bool to be stored.

void Result::setValue ( int  iValue  ) 

Sets this result to store an int.

Parameters:
[in] iValue The int to be stored.

void Result::setValue ( double  dValue  ) 

Sets this result to store a double.

Parameters:
[in] dValue The double to be stored.

void Result::setValue ( void *  vpValue,
size_t  size,
std::string  strType 
)

Set this result to store an arbitrary block of memory.

Parameters:
[in] vpValue A pointer to the block of memory to be stored.
[in] size The size in bytes of the memory to be stored.
[in] strType A string specifying the type of value stored in the memory being copied.

bool Result::toBool (  )  const

Returns the value stored in this result as a bool if the conversion is known.

double Result::toDouble (  )  const

Returns the value stored in this result as a double if the conversion is known.

int Result::toInt (  )  const

Returns the value stored in this result as an int if the conversion is known.


The documentation for this class was generated from the following files:
Generated on Mon Jan 15 01:21:05 2007 for Creatively Named Grammar Guided Genetic Programming System by  doxygen 1.4.7