BWAPI  4.1.2
An API for interacting with Starcraft: Broodwar (1.16.1)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
BWAPI::Type< T, UnknownId > Class Template Reference
Inheritance diagram for BWAPI::Type< T, UnknownId >:
Inheritance graph

Public Types

typedef std::deque< T > list
 
typedef SetContainer< T > set
 

Public Member Functions

 Type (int id)
 
const char * c_str () const
 
int getID () const
 
const std::stringgetName () const
 
bool isValid () const
 
 operator int () const
 
const std::stringtoString () const
 

Static Public Member Functions

static T getType (std::string name)
 

Friends

std::ostreamoperator<< (std::ostream &out, const Type< T, UnknownId > &t)
 
std::wostreamoperator<< (std::wostream &out, const Type< T, UnknownId > &t)
 

Detailed Description

template<class T, int UnknownId>
class BWAPI::Type< T, UnknownId >

Base superclass for all BWAPI Types.

Template Parameters
TThe type class that this Type is representing.
UnknownIdThe enum ID of the unknown entry, which is also treated as the last entry for type validity.

Member Typedef Documentation

template<class T, int UnknownId>
typedef SetContainer<T> BWAPI::Type< T, UnknownId >::set

A set type that contains the current type.

template<class T, int UnknownId>
typedef std::deque<T> BWAPI::Type< T, UnknownId >::list

A list type that contains the current type.

Constructor & Destructor Documentation

template<class T, int UnknownId>
BWAPI::Type< T, UnknownId >::Type ( int  id)
explicit

Expected type constructor.

If the type is an invalid type, then it becomes Types::Unknown. A type is invalid if its value is less than 0 or greater than Types::Unknown.

Parameters
idThe id that corresponds to this type. It is typically an integer value that corresponds to an internal Broodwar type. If the given id is invalid, then it becomes Types::Unknown.

Member Function Documentation

template<class T, int UnknownId>
BWAPI::Type< T, UnknownId >::operator int ( ) const

Conversion/convenience operator to convert this type to its primitive type.

Returns
An integer representation of this type.
template<class T, int UnknownId>
int BWAPI::Type< T, UnknownId >::getID ( ) const

Retrieves this type's identifier as an integer.

Returns
An integer representation of this type.
template<class T, int UnknownId>
bool BWAPI::Type< T, UnknownId >::isValid ( ) const

Checks if the current type has a valid identifier.

The purpose of this function is to prevent buffer overflows if a type has been handled improperly.

A type is valid if it is between 0 and Unknown (inclusive).

Returns
true If this type is valid and false otherwise.

Referenced by BWAPI::Type< T, UnknownId >::getName().

template<class T, int UnknownId>
const std::string& BWAPI::Type< T, UnknownId >::getName ( ) const

Retrieves the variable name of the type.

Returns
Reference to std::string object containing the name.

References BWAPI::Type< T, UnknownId >::isValid().

Referenced by BWAPI::Type< T, UnknownId >::c_str(), and BWAPI::Type< T, UnknownId >::toString().

template<class T, int UnknownId>
const std::string& BWAPI::Type< T, UnknownId >::toString ( ) const

Retrieves the variable name of the type.

Returns
Reference to std::string object containing the name.

References BWAPI::Type< T, UnknownId >::getName().

template<class T, int UnknownId>
const char* BWAPI::Type< T, UnknownId >::c_str ( ) const

Retrieves the variable name of the type as a c-style string.

Meant to be a convenience member.

Returns
Pointer to constant c-style string containing the name.

References std::string::c_str(), and BWAPI::Type< T, UnknownId >::getName().

template<class T, int UnknownId>
static T BWAPI::Type< T, UnknownId >::getType ( std::string  name)
static

Searches for the type associated with the given string and returns it.

Parameters
nameA string containing the name of the type.
Returns
The type that resolves to the given name.

References std::string::begin(), std::string::end(), std::string::erase(), std::remove_if(), and std::transform().

Friends And Related Function Documentation

template<class T, int UnknownId>
std::ostream& operator<< ( std::ostream out,
const Type< T, UnknownId > &  t 
)
friend

Output stream operator overload.

Allows printing of the type without calling Type::getName.

Parameters
outThe destination output stream.
tThe type to write as a string.
template<class T, int UnknownId>
std::wostream& operator<< ( std::wostream out,
const Type< T, UnknownId > &  t 
)
friend

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.