- Timestamp:
- Nov 11, 2005, 1:13:07 PM (19 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/multi_type.cc
r5539 r5540 24 24 using namespace std; 25 25 26 MultiType::MultiType() 27 { 28 this->type = MT_NULL; 29 this->storedString = NULL; 30 } 31 32 26 33 MultiType::MultiType(bool value) 27 34 { 28 35 this->init(); 29 this->type = MT_BOOL; 30 this->value.Bool = value; 31 36 this->setBool(value); 32 37 } 33 38 … … 35 40 { 36 41 this->init(); 37 this->type = MT_INT; 38 this->value.Int = value; 42 this->setInt(value); 39 43 } 40 44 … … 43 47 { 44 48 this->init(); 45 this->type = MT_FLOAT; 46 this->value.Float = value; 49 this->setFloat(value); 47 50 } 48 51 … … 51 54 { 52 55 this->init(); 53 this->type = MT_CHAR; 54 this->value.Char = value; 56 this->setChar(value); 55 57 } 56 58 … … 59 61 { 60 62 this->init(); 61 this->type = MT_STRING; 62 this->value.String = new char[strlen(value)+1]; 63 strcpy(this->value.String, value); 64 65 this->storedString = this->value.String; 63 this->setString(value); 66 64 } 67 65 … … 75 73 } 76 74 75 /** 76 * copy Constructor 77 * @param mt: the entity to copy 78 * @returns a Copy of itself. (strings inside are copied as well) 79 */ 80 MultiType MultiType::operator= (const MultiType& mt) 81 { 82 this->type = mt.type; 83 this->value = mt.value; 84 85 if (mt.type == MT_STRING) 86 { 87 this->storedString = new char[strlen (mt.storedString)+1]; 88 strcpy(this->storedString, mt.storedString); 89 this->value.String = this->storedString; 90 } 91 } 92 77 93 void MultiType::init() 78 94 { 95 this->type = MT_NULL; 79 96 this->storedString = NULL; 80 97 } 98 99 100 101 void MultiType::setType(MT_Type) 102 { 103 104 } 105 106 void MultiType::setBool(bool value) 107 { 108 this->type = MT_BOOL; 109 this->value.Bool = value; 110 } 111 112 113 void MultiType::setInt(int value) 114 { 115 this->type = MT_INT; 116 this->value.Int = value; 117 } 118 119 120 void MultiType::setFloat(float value) 121 { 122 this->type = MT_FLOAT; 123 this->value.Float = value; 124 125 } 126 127 128 void MultiType::setChar(char value) 129 { 130 this->type = MT_CHAR; 131 this->value.Char = value; 132 } 133 134 135 void MultiType::setString(const char* value) 136 { 137 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 81 147 82 148 -
trunk/src/lib/util/multi_type.h
r5539 r5540 30 30 31 31 public: 32 MultiType(); 32 33 MultiType(bool value); 33 34 MultiType(int value); … … 38 39 void init(); 39 40 41 MultiType operator= (const MultiType& mt); 42 43 void setType(MT_Type); 44 45 void setBool(bool value); 46 void setInt(int value); 47 void setFloat(float value); 48 void setChar(char value); 49 void setString(const char* value); 40 50 41 51 /** @returns the Type of the Value stored in this MultiType */
Note: See TracChangeset
for help on using the changeset viewer.