Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5545 in orxonox.OLD for trunk/src/lib/util/multi_type.cc


Ignore:
Timestamp:
Nov 11, 2005, 4:32:28 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: renaming of BaseLoadParam to LoadParamBase

File:
1 edited

Legend:

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

    r5544 r5545  
    1717
    1818#include "multi_type.h"
    19 #include <stddef.h>
    20 #include <stdlib.h>
    21 #include <string.h>
    22 #include <stdio.h>
     19#include "stdincl.h"
     20// #include <stddef.h>
     21// #include <stdlib.h>
     22// #include <string.h>
     23// #include <stdio.h>
    2324
    2425using namespace std;
    2526
     27/**
     28 * creates a multiType without any stored value at all.
     29 */
    2630MultiType::MultiType()
    2731{
     
    3034}
    3135
    32 
     36/**
     37 * creates a multiType out of a boolean
     38 * @param value the Value of this MulitType
     39 */
    3340MultiType::MultiType(bool value)
    3441{
     
    3744}
    3845
     46/**
     47 * creates a multiType out of an integer
     48 * @param value the Value of this MulitType
     49 */
    3950MultiType::MultiType(int value)
    4051{
     
    4354}
    4455
    45 
     56/**
     57 * creates a multiType out of a float (double)
     58 * @param value the Value of this MulitType
     59 */
    4660MultiType::MultiType(double value)
    4761{
     
    5064}
    5165
    52 
     66/**
     67 * creates a multiType out of a char
     68 * @param value the Value of this MulitType
     69 */
    5370MultiType::MultiType(char value)
    5471{
     
    5774}
    5875
    59 
     76/**
     77 * creates a multiType out of a String
     78 * @param value the Value of this MulitType
     79 */
    6080MultiType::MultiType(const char* value)
    6181{
     
    91111}
    92112
     113/**
     114 * initializes the MultiType
     115 */
    93116void MultiType::init()
    94117{
     
    104127}
    105128
     129/**
     130 * sets a new Value to the MultiType
     131 * @param value the new Value as a bool
     132 */
    106133void MultiType::setBool(bool value)
    107134{
     
    110137}
    111138
    112 
     139/**
     140 * sets a new Value to the MultiType
     141 * @param value the new Value as an int
     142 */
    113143void MultiType::setInt(int value)
    114144{
     
    117147}
    118148
    119 
     149/**
     150 * sets a new Value to the MultiType
     151 * @param value the new Value as a float
     152 */
    120153void MultiType::setFloat(float value)
    121154{
     
    125158}
    126159
    127 
     160/**
     161 * sets a new Value to the MultiType
     162 * @param value the new Value as a char
     163 */
    128164void MultiType::setChar(char value)
    129165{
     
    132168}
    133169
    134 
     170/**
     171 * sets a new Value to the MultiType
     172 * @param value the new Value as a String
     173 */
    135174void MultiType::setString(const char* value)
    136175{
    137176  this->type = MT_STRING;
    138   this->value.String = new char[strlen(value)+1];
    139   strcpy(this->value.String, value);
    140 
    141   this->storedString = this->value.String;
    142 }
    143 
    144 
    145 
    146 
    147 
    148 
     177
     178  if (this->storedString != NULL)
     179    delete[] this->storedString;
     180  this->storedString = new char[strlen(value)+1];
     181  strcpy(storedString, value);
     182
     183  this->value.String = this->storedString;
     184}
     185
     186
     187
     188
     189
     190/**
     191 * @returns the Value of this MultiType as a int
     192 */
    149193bool MultiType::getBool() const
    150194{
     
    161205}
    162206
    163 
     207/**
     208 * @returns the Value of this MultiType as a int
     209 */
    164210int MultiType::getInt() const
    165211{
     
    182228}
    183229
    184 
     230/**
     231 * @returns the Value of this MultiType as a float
     232 */
    185233float MultiType::getFloat() const
    186234{
     
    204252
    205253
     254/**
     255 * @returns the Value of this MultiType as a char
     256 */
    206257char MultiType::getChar() const
    207258{
     
    217268}
    218269
     270/**
     271 * @returns the Value of this MultiType as a String
     272 */
    219273const char* MultiType::getString()
    220274{
     
    253307}
    254308
    255 
     309/**
     310 * prints out some nice debug output
     311 */
    256312void MultiType::debug()
    257313{
     
    268324}
    269325
     326/**
     327 * converts a MT_Type into a String
     328 * @param type: the MT_Type
     329 * @returns: the Type as a constant String (do not delete)
     330 */
    270331const char* MultiType::MultiTypeToString(MT_Type type)
    271332{
     
    287348}
    288349
     350/**
     351 * converts a String into a MT_Type
     352 * @param type: the Type as a String
     353 * @returns: the Type as MT_Type
     354 */
    289355MT_Type MultiType::StringToMultiType(const char* type)
    290356{
Note: See TracChangeset for help on using the changeset viewer.