Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7199 in orxonox.OLD for trunk/src/lib/util/multi_type.h


Ignore:
Timestamp:
Mar 8, 2006, 10:46:37 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: MultiType rework (now uses std::string) this is more compliant, and better to handle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/multi_type.h

    r7197 r7199  
    11/*!
    22 * @file multi_type.h
    3  * @brief Definition of ...
     3 * @brief Definition of a MultiType, that is able to hold one Value of many types.
    44 */
    55
    66#ifndef _MULTI_TYPE_H
    77#define _MULTI_TYPE_H
     8
     9#include <string>
    810
    911// FORWARD DECLARATION
     
    3840    MultiType(char value);
    3941    MultiType(const char* value);
     42    MultiType(const std::string& value);
    4043    MultiType(const MultiType& multiType);
    4144    virtual ~MultiType();
     
    4750    MultiType& operator=(char value) { this->setChar(value); return *this; };
    4851    MultiType& operator=(const char* value) { this->setString(value); return *this; };
     52    MultiType& operator=(const std::string& value) { this->setString(value); return *this; };
    4953
    5054    bool operator==(const MultiType& mt) const;
     
    5357    bool operator==(float value) const { return (this->getFloat() ==  value); };
    5458    bool operator==(char value) const { return (this->getChar() == value); };
    55     bool operator==(const char* value) const;
     59    bool operator==(const std::string& value) const { return (this->getString() == value); };
    5660    bool operator==(MT_Type type) const { return (this->type == type); }
    5761    bool operator!=(MT_Type type) const { return (this->type != type); }
     
    6367    void setFloat(float value);
    6468    void setChar(char value);
    65     void setString(const char* value);
     69    void setString(const std::string& value);
    6670
    6771    // for your convenience.
     
    7175    inline void setValue(char value) { this->setChar(value); };
    7276    inline void setValue(const char* value) { this->setString(value); };
     77    inline void setValue(const std::string& value) { this->setString(value); };
     78    void setValueOf(const MultiType& mt);
    7379
    7480    /** @returns the Type of the Value stored in this MultiType */
     
    8187    float getFloat() const;
    8288    char getChar() const;
    83     const char* getString();
     89    const char* getCString();
     90    std::string getString() const;
    8491
    8592    void reset();
    8693
    87     void debug();
     94    void debug() const;
    8895
    8996    static const char* MultiTypeToString(MT_Type type);
     
    101108      float             Float;
    102109      char              Char;
    103       char*             String;
    104 
     110//      std::string*      String;
    105111    }                   value;
    106112
    107113    MT_Type             type;
    108114
    109     char*               storedString;
     115    std::string         storedString;
    110116};
    111117
Note: See TracChangeset for help on using the changeset viewer.