variant Class Reference

#include <variant.hpp>

Collaboration diagram for variant:

Collaboration graph
[legend]

List of all members.

Public Types

enum  TYPE {
  TYPE_NULL, TYPE_INT, TYPE_CALLABLE, TYPE_LIST,
  TYPE_STRING, TYPE_MAP
}

Public Member Functions

 variant ()
 variant (int n)
 variant (const game_logic::formula_callable *callable)
 variant (std::vector< variant > *array)
 variant (const std::string &str)
 variant (std::map< variant, variant > *map)
 ~variant ()
 variant (const variant &v)
const variantoperator= (const variant &v)
const variantoperator[] (size_t n) const
const variantoperator[] (const variant v) const
size_t num_elements () const
variant get_member (const std::string &str) const
bool is_string () const
bool is_null () const
bool is_int () const
bool is_map () const
int as_int () const
bool as_bool () const
bool is_list () const
const std::string & as_string () const
bool is_callable () const
const
game_logic::formula_callable
as_callable () const
game_logic::formula_callablemutable_callable () const
template<typename T>
T * try_convert () const
template<typename T>
T * convert_to () const
variant operator+ (const variant &) const
variant operator- (const variant &) const
variant operator* (const variant &) const
variant operator/ (const variant &) const
variant operator^ (const variant &) const
variant operator% (const variant &) const
variant operator- () const
bool operator== (const variant &) const
bool operator!= (const variant &) const
bool operator< (const variant &) const
bool operator> (const variant &) const
bool operator<= (const variant &) const
bool operator>= (const variant &) const
std::map< variant, variantget_map () const
variant get_keys () const
variant get_values () const
void serialize_to_string (std::string &str) const
void serialize_from_string (const std::string &str)
int refcount () const
std::string string_cast () const
std::string to_debug_string (std::vector< const game_logic::formula_callable * > *seen=NULL) const

Private Member Functions

void must_be (TYPE t) const
void increment_refcount ()
void release ()

Private Attributes

TYPE type_
union {
   int   int_value_
   const
game_logic::formula_callable *   callable_
   game_logic::formula_callable *   mutable_callable_
   variant_list *   list_
   variant_string *   string_
   variant_map *   map_
}; 


Detailed Description

Definition at line 36 of file variant.hpp.


Member Enumeration Documentation

Enumerator:
TYPE_NULL 
TYPE_INT 
TYPE_CALLABLE 
TYPE_LIST 
TYPE_STRING 
TYPE_MAP 

Definition at line 118 of file variant.hpp.


Constructor & Destructor Documentation

variant::variant (  ) 

variant::variant ( int  n  )  [explicit]

Definition at line 146 of file variant.cpp.

variant::variant ( const game_logic::formula_callable callable  )  [explicit]

Definition at line 149 of file variant.cpp.

References callable_, and increment_refcount().

variant::variant ( std::vector< variant > *  array  )  [explicit]

Definition at line 156 of file variant.cpp.

References variant_list::elements, increment_refcount(), and list_.

variant::variant ( const std::string &  str  )  [explicit]

Definition at line 165 of file variant.cpp.

References increment_refcount(), variant_string::str, and string_.

variant::variant ( std::map< variant, variant > *  map  )  [explicit]

Definition at line 173 of file variant.cpp.

References variant_map::elements, increment_refcount(), and map_.

variant::~variant (  ) 

Definition at line 188 of file variant.cpp.

References release().

variant::variant ( const variant v  ) 

Definition at line 182 of file variant.cpp.

References increment_refcount().


Member Function Documentation

const variant & variant::operator= ( const variant v  ) 

Definition at line 193 of file variant.cpp.

References increment_refcount(), and release().

const variant & variant::operator[] ( size_t  n  )  const

Definition at line 203 of file variant.cpp.

References variant_list::elements, list_, must_be(), type_, TYPE_CALLABLE, and TYPE_LIST.

Referenced by operator[](), and to_debug_string().

const variant & variant::operator[] ( const variant  v  )  const

size_t variant::num_elements (  )  const

variant variant::get_member ( const std::string &  str  )  const

bool variant::is_string (  )  const [inline]

Definition at line 55 of file variant.hpp.

References type_, and TYPE_STRING.

bool variant::is_null (  )  const [inline]

bool variant::is_int (  )  const [inline]

Definition at line 57 of file variant.hpp.

References type_, and TYPE_INT.

bool variant::is_map (  )  const [inline]

Definition at line 58 of file variant.hpp.

References type_, and TYPE_MAP.

int variant::as_int (  )  const [inline]

Definition at line 59 of file variant.hpp.

References int_value_, must_be(), type_, TYPE_INT, and TYPE_NULL.

Referenced by operator%(), operator*(), operator+(), operator-(), operator/(), operator[](), and operator^().

bool variant::as_bool (  )  const

bool variant::is_list (  )  const [inline]

Definition at line 62 of file variant.hpp.

References type_, and TYPE_LIST.

Referenced by formula_ai::do_recruitment(), and formula_ai::execute_variant().

const std::string & variant::as_string (  )  const

Definition at line 321 of file variant.cpp.

References must_be(), variant_string::str, string_, and TYPE_STRING.

bool variant::is_callable (  )  const [inline]

Definition at line 66 of file variant.hpp.

References type_, and TYPE_CALLABLE.

Referenced by get_member(), try_convert(), and try_convert_variant().

const game_logic::formula_callable* variant::as_callable (  )  const [inline]

Definition at line 67 of file variant.hpp.

References callable_, must_be(), and TYPE_CALLABLE.

Referenced by game_logic::formula_function_expression::execute().

game_logic::formula_callable* variant::mutable_callable (  )  const [inline]

Definition at line 69 of file variant.hpp.

References must_be(), mutable_callable_, and TYPE_CALLABLE.

Referenced by convert_to(), convert_variant(), try_convert(), and try_convert_variant().

template<typename T>
T* variant::try_convert (  )  const [inline]

Definition at line 73 of file variant.hpp.

References is_callable(), and mutable_callable().

template<typename T>
T* variant::convert_to (  )  const [inline]

Definition at line 82 of file variant.hpp.

References mutable_callable().

variant variant::operator+ ( const variant v  )  const

variant variant::operator- ( const variant v  )  const

Definition at line 362 of file variant.cpp.

References as_int(), and variant().

variant variant::operator* ( const variant v  )  const

Definition at line 367 of file variant.cpp.

References as_int(), and variant().

variant variant::operator/ ( const variant v  )  const

Definition at line 372 of file variant.cpp.

References as_int(), and variant().

variant variant::operator^ ( const variant v  )  const

Definition at line 394 of file variant.cpp.

References as_int(), and variant().

variant variant::operator% ( const variant v  )  const

Definition at line 383 of file variant.cpp.

References as_int(), and variant().

variant variant::operator- (  )  const

Definition at line 399 of file variant.cpp.

References as_int(), and variant().

bool variant::operator== ( const variant v  )  const

bool variant::operator!= ( const variant v  )  const

Definition at line 450 of file variant.cpp.

References operator==().

bool variant::operator< ( const variant v  )  const

Definition at line 504 of file variant.cpp.

bool variant::operator> ( const variant v  )  const

Definition at line 509 of file variant.cpp.

bool variant::operator<= ( const variant v  )  const

bool variant::operator>= ( const variant v  )  const

Definition at line 499 of file variant.cpp.

std::map< variant, variant > variant::get_map (  )  const

Definition at line 242 of file variant.cpp.

References variant_map::elements, map_, must_be(), and TYPE_MAP.

variant variant::get_keys (  )  const

Definition at line 248 of file variant.cpp.

References variant_map::elements, map_, must_be(), TYPE_MAP, and variant().

variant variant::get_values (  )  const

Definition at line 259 of file variant.cpp.

References variant_map::elements, map_, must_be(), TYPE_MAP, and variant().

void variant::serialize_to_string ( std::string &  str  )  const

void variant::serialize_from_string ( const std::string &  str  ) 

Definition at line 571 of file variant.cpp.

References variant().

Referenced by unit::read().

int variant::refcount (  )  const

std::string variant::string_cast (  )  const

std::string variant::to_debug_string ( std::vector< const game_logic::formula_callable * > *  seen = NULL  )  const

void variant::must_be ( variant::TYPE  t  )  const [private]

void variant::increment_refcount (  )  [private]

void variant::release (  )  [private]


Member Data Documentation

TYPE variant::type_ [private]

Definition at line 125 of file variant.hpp.

Referenced by mutable_callable().

union { ... } [private]


The documentation for this class was generated from the following files:

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs