Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

lrt::Variant Class Reference

This data type can hold either a String, an integer or a floating-point (double) value. More...

#include <rtdelphi.h>

List of all members.

Public Types

enum  VariantType { typeString = 0, typeInt, typeDouble }
 The possible types this variable may have. More...


Public Methods

 Variant ()
 Creates a Variant which contains the integer 0.

 Variant (const Variant &)
 Copies the data over from the other variant.

Variant & operator= (const Variant &)
 Copies the data over from the other variant.

 ~Variant ()
 Variant (int)
 Creates a Variant which contains the given integer.

 Variant (double)
 Creates a Variant which contains the given double.

 Variant (const String &)
 Creates a Variant which contains the given String.

void set (int)
 Sets this variant's value to the given integer.

void set (double)
 Sets this variant's value to the given double.

void set (const String &)
 Sets this variant's value to the given String.

int getInt (int def=0) const
 Extracts an integer from this variant. More...

double getDouble (double def=0.) const
 Extracts a double from this variant. More...

String getString () const
 Converts this variant's data to a String representation and returns it. More...

VariantType getCurrentType () const
 Returns the current type of this variant.


Detailed Description

This data type can hold either a String, an integer or a floating-point (double) value.

It is much like a typesafe union of these types.


Member Enumeration Documentation

enum lrt::Variant::VariantType
 

The possible types this variable may have.

Enumeration values:
typeString  The variant is currently a string.
typeInt  The variant is currently an integer.
typeDouble  The variant is currently a double.


Member Function Documentation

double lrt::Variant::getDouble (  double    def = 0. )  const
 

Extracts a double from this variant.

Note that it is unimportant which type this variant actually contains, a double will be generated from it.

Parameters:
def  (optional) The default value which is used if this variant is currently a String and not interpretable as a double.

int lrt::Variant::getInt (  int    def = 0 )  const
 

Extracts an integer from this variant.

Note that it is unimportant which type this variant actually contains, an integer will be generated from it.

Parameters:
def  (optional) The default value which is used if this variant is currently a String and not interpretable as an integer.

String lrt::Variant::getString (    )  const
 

Converts this variant's data to a String representation and returns it.

The operation does not change the variant itself.


The documentation for this class was generated from the following files:
This is the RoboTour API documentation version 0.1 • Copyright (C) by Florian Fischer