Ares
Public Types | Public Member Functions

ValueableVector< T > Class Template Reference

#include <src/Utilities/Template.h>

Inheritance diagram for ValueableVector< T >:
vector

List of all members.

Public Types

typedef T MyType
typedef CompoundT< T >::BaseT MyBase

Public Member Functions

void Read (INI_EX *parser, const char *pSection, const char *pKey)
bool operator== (AbstractTypeClass *other) const
template<>
void Read (INI_EX *parser, const char *pSection, const char *pKey)

template<class T>
class ValueableVector< T >


Member Typedef Documentation

template<class T>
typedef CompoundT<T>::BaseT ValueableVector< T >::MyBase
template<class T>
typedef T ValueableVector< T >::MyType

Member Function Documentation

template<class T>
bool ValueableVector< T >::operator== ( AbstractTypeClass *  other) const [inline]

This will return true for Valuable<std::vector<AbstractTypeClass *> > Foo == AbstractTypeClass * Bar if Bar is among the objects listed in Foo.

This way, we can do stuff like if(SomeExt->AllowedUnits == someUnit) { ... even if AllowedUnits is a list.

                                                          {
                if(this->empty()) {
                        return false;
                }

                int listSize = this->size();
                for( int i = 0; i < listSize; ++i ) {
                        if(this->at(i) == other) {
                                return true;
                        }
                }

                // if we ended up here, other is not among the listed object types
                return false;
        }
template<>
void ValueableVector< TechnoTypeClass * >::Read ( INI_EX parser,
const char *  pSection,
const char *  pKey 
)
                                                                                                    {
        if(parser->ReadString(pSection, pKey)) {
                // if we were able to get the flag in question, take it apart and check the tokens...
                // ...against the various object types; if we find one, place it in the value list
                for(char *cur = strtok(Ares::readBuffer, ","); cur; cur = strtok(NULL, ",")) {
                        TechnoTypeClass * thisObject = NULL;
                        if(thisObject = AircraftTypeClass::Find(cur)) {
                                this->push_back(thisObject);
                                continue;
                        }
                        if(thisObject = BuildingTypeClass::Find(cur)) {
                                this->push_back(thisObject);
                                continue;
                        }
                        if(thisObject = InfantryTypeClass::Find(cur)) {
                                this->push_back(thisObject);
                                continue;
                        }
                        if(thisObject = UnitTypeClass::Find(cur)) {
                                this->push_back(thisObject);
                                continue;
                        }
                        Debug::INIParseFailed(pSection, pKey, cur);
                }
        }
}
template<class T>
void ValueableVector< T >::Read ( INI_EX parser,
const char *  pSection,
const char *  pKey 
) [inline]
                                                                          {
                if(parser->ReadString(pSection, pKey)) {
                        // if we were able to get the flag in question, take it apart and check the tokens...
                        // ...against the various object types; if we find one, place it in the value list
                        for(char *cur = strtok(Ares::readBuffer, ","); cur; cur = strtok(NULL, ",")) {
                                if(T thisObject = MyBase::Find(cur)) {
                                        this->push_back(thisObject);
                                        continue;
                                }
                        }
                }
        }

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines