Changeset 1052 for code/trunk/src/util/MultiTypeString.cc
- Timestamp:
- Apr 14, 2008, 3:42:49 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/util/MultiTypeString.cc
r871 r1052 32 32 MultiTypeString::MultiTypeString(MultiType type) : MultiTypePrimitive(type) 33 33 { 34 if (type == MT_constchar) 35 this->string_ = std::string(""); 36 else if (type == MT_string) 37 this->string_ = std::string(""); 34 // Nothing to do for string and xml-element 38 35 } 39 36 … … 64 61 } 65 62 63 MultiTypeString::operator void*() const 64 { return (this->type_ == MT_void) ? this->value_.void_ : getConvertedValue<MultiTypeString, void*>(*this, 0); } 66 65 MultiTypeString::operator int() const 67 { return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypeString, int>(*this); }66 { return (this->type_ == MT_int) ? this->value_.int_ : getConvertedValue<MultiTypeString, int>(*this, 0); } 68 67 MultiTypeString::operator unsigned int() const 69 { return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypeString, unsigned int>(*this); }68 { return (this->type_ == MT_uint) ? this->value_.uint_ : getConvertedValue<MultiTypeString, unsigned int>(*this, 0); } 70 69 MultiTypeString::operator char() const 71 { return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypeString, char>(*this); }70 { return (this->type_ == MT_char) ? this->value_.char_ : getConvertedValue<MultiTypeString, char>(*this, 0); } 72 71 MultiTypeString::operator unsigned char() const 73 { return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypeString, unsigned char>(*this); }72 { return (this->type_ == MT_uchar) ? this->value_.uchar_ : getConvertedValue<MultiTypeString, unsigned char>(*this, 0); } 74 73 MultiTypeString::operator short() const 75 { return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypeString, short>(*this); }74 { return (this->type_ == MT_short) ? this->value_.short_ : getConvertedValue<MultiTypeString, short>(*this, 0); } 76 75 MultiTypeString::operator unsigned short() const 77 { return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypeString, unsigned short>(*this); }76 { return (this->type_ == MT_ushort) ? this->value_.ushort_ : getConvertedValue<MultiTypeString, unsigned short>(*this, 0); } 78 77 MultiTypeString::operator long() const 79 { return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypeString, long>(*this); }78 { return (this->type_ == MT_long) ? this->value_.long_ : getConvertedValue<MultiTypeString, long>(*this, 0); } 80 79 MultiTypeString::operator unsigned long() const 81 { return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypeString, unsigned long>(*this); }80 { return (this->type_ == MT_ulong) ? this->value_.ulong_ : getConvertedValue<MultiTypeString, unsigned long>(*this, 0); } 82 81 MultiTypeString::operator float() const 83 { return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypeString, float>(*this); }82 { return (this->type_ == MT_float) ? this->value_.float_ : getConvertedValue<MultiTypeString, float>(*this, 0); } 84 83 MultiTypeString::operator double() const 85 { return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypeString, double>(*this); }84 { return (this->type_ == MT_double) ? this->value_.double_ : getConvertedValue<MultiTypeString, double>(*this, 0); } 86 85 MultiTypeString::operator long double() const 87 { return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypeString, long double>(*this); }86 { return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : getConvertedValue<MultiTypeString, long double>(*this, 0); } 88 87 MultiTypeString::operator bool() const 89 { return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypeString, bool>(*this); }88 { return (this->type_ == MT_bool) ? this->value_.bool_ : getConvertedValue<MultiTypeString, bool>(*this, 0); } 90 89 MultiTypeString::operator std::string() const 91 { return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this); }90 { return (this->type_ == MT_string) ? this->string_ : getConvertedValue<MultiTypeString, std::string>(*this); } 92 91 MultiTypeString::operator const char*() const 93 { return ((this->type_ == MT_constchar) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this)).c_str(); }92 { return ((this->type_ == MT_constchar) ? this->string_ : getConvertedValue<MultiTypeString, std::string>(*this)).c_str(); } 94 93 95 94 void MultiTypeString::setValue(const MultiTypeString& mts) … … 99 98 } 100 99 100 std::string MultiTypeString::getTypename() const 101 { 102 if (this->type_ == MT_constchar) 103 return "string"; 104 else if (this->type_ == MT_string) 105 return "string"; 106 else 107 return MultiTypePrimitive::getTypename(); 108 } 109 101 110 std::string MultiTypeString::toString() const 102 111 { 112 std::string output; 113 103 114 if (this->type_ == MT_constchar) 104 115 return this->string_; … … 107 118 else 108 119 return MultiTypePrimitive::toString(); 120 121 return output; 109 122 } 110 123
Note: See TracChangeset
for help on using the changeset viewer.