BWAPI  4.2.0
An API for interacting with Starcraft: Broodwar (1.16.1)
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

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

Static Public Member Functions

static T getType (std::string name)

Friends

std::ostreamoperator<< (std::ostream &os, const Type< T, UnknownId > &t)
std::wostreamoperator<< (std::wostream &os, 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

typedef SetContainer<T> BWAPI::Type< T, UnknownId >::set

A set type that contains the current type.

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

A list type that contains the current type.

Constructor & Destructor Documentation

constexpr 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

constexpr 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.
constexpr int BWAPI::Type< T, UnknownId >::getID () const

Retrieves this type's identifier as an integer.

Returns
An integer representation of this type.
constexpr 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().

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().

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().

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().

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(), std::tolower(), and std::transform().

Friends And Related Function Documentation

std::ostream& operator<< (std::ostreamos, const Type< T, UnknownId > & t ) friend

Output stream operator overload.

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

Parameters
osThe destination output stream.
tThe type to write as a string.
std::wostream& operator<< (std::wostreamos, 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.