SC2API
An API for AI for StarCraft II
Public Member Functions | List of all members
sc2::SC2Type< T > Class Template Reference

#include <sc2_types.h>

Public Member Functions

 SC2Type ()
 Default constructor.
 
 SC2Type (uint32_t type_id)
 Construct from an integer, corresponds to the enum value.
 
 SC2Type (T type_id)
 Construct from the enum.
 
bool operator== (SC2Type< T > type_id) const
 
bool operator== (T type_id) const
 
bool operator== (uint32_t type_id) const
 
bool operator== (int type_id) const
 
bool operator!= (SC2Type< T > type_id) const
 
bool operator!= (T type_id) const
 
bool operator!= (uint32_t type_id) const
 
bool operator!= (int type_id) const
 
bool operator< (const SC2Type< T > &other) const
 Test comparison.
 
 operator uint32_t () const
 Cast to integer.
 
 operator T () const
 Cast to enum type.
 
bool IsValid () const
 
std::string to_string () const
 
ToType () const
 

Detailed Description

template<class T>
class sc2::SC2Type< T >

Template class for defining common game enum types. The template parameter is the enum. This class allows for seamless conversion between enum types and integers, while maintaining strong typing. This means, for example, that a unit type ID can be converted back and forth from an integer, but can't be used when another type ID, e.g., an ability ID, is required as a parameter.

Member Function Documentation

template<class T>
bool sc2::SC2Type< T >::IsValid ( ) const
inline

Determines if the value contained is valid.

Returns
'true' if the value is valid.
template<class T>
bool sc2::SC2Type< T >::operator!= ( SC2Type< T >  type_id) const
inline

Test non-equivalence.

Returns
'true' if the values are not equal.
template<class T>
bool sc2::SC2Type< T >::operator== ( SC2Type< T >  type_id) const
inline

Test equivalence.

Returns
'true' if the values are equal.
template<class T>
std::string sc2::SC2Type< T >::to_string ( ) const
inline

String of the integer value.

Returns
The string of the value.
template<class T>
T sc2::SC2Type< T >::ToType ( ) const
inline

Explicit conversion to the enum type.

Returns
The enum.

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