Changeset 1446 for code/branches/network/src/util
- Timestamp:
- May 28, 2008, 5:30:11 AM (17 years ago)
- Location:
- code/branches/network/src/util
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/util/Convert.h
r1064 r1446 384 384 else if (input.getType() == MT_vector3) 385 385 return ConvertValue(output, input.getVector3()); 386 else if (input.getType() == MT_vector4) 387 return ConvertValue(output, input.getVector4()); 386 388 else if (input.getType() == MT_quaternion) 387 389 return ConvertValue(output, input.getQuaternion()); -
code/branches/network/src/util/Math.h
r1349 r1446 121 121 122 122 template <typename T> 123 inline int mod(T x, int max) 124 { 125 if (x >= 0) 126 return (x % max); 127 else 128 return ((x % max) + max); 129 } 130 131 template <typename T> 123 132 T interpolate(float time, const T& start, const T& end) 124 133 { -
code/branches/network/src/util/MultiType.h
r1056 r1446 54 54 MT_vector2, 55 55 MT_vector3, 56 MT_vector4, 56 57 MT_colourvalue, 57 58 MT_quaternion, -
code/branches/network/src/util/MultiTypeMath.cc
r1056 r1446 37 37 else if (type == MT_vector3) 38 38 this->vector3_ = orxonox::Vector3(0, 0, 0); 39 else if (type == MT_vector4) 40 this->vector4_ = orxonox::Vector4(0, 0, 0, 0); 39 41 else if (type == MT_colourvalue) 40 42 this->colourvalue_ = orxonox::ColourValue(0, 0, 0, 0); … … 55 57 else if (this->type_ == MT_vector3) 56 58 return (this->vector3_ == mtm.vector3_); 59 else if (this->type_ == MT_vector4) 60 return (this->vector4_ == mtm.vector4_); 57 61 else if (this->type_ == MT_colourvalue) 58 62 return (this->colourvalue_ == mtm.colourvalue_); … … 68 72 } 69 73 74 bool MultiTypeMath::operator==(const MultiTypeString& mts) const 75 { 76 return MultiTypeString::operator==(mts); 77 } 78 79 bool MultiTypeMath::operator==(const MultiTypePrimitive& mtp) const 80 { 81 return MultiTypePrimitive::operator==(mtp); 82 } 83 70 84 bool MultiTypeMath::operator!=(const MultiTypeMath& mtm) const 71 85 { … … 76 90 else if (this->type_ == MT_vector3) 77 91 return (this->vector3_ != mtm.vector3_); 92 else if (this->type_ == MT_vector4) 93 return (this->vector4_ != mtm.vector4_); 78 94 else if (this->type_ == MT_colourvalue) 79 95 return (this->colourvalue_ != mtm.colourvalue_); … … 87 103 88 104 return true; 105 } 106 107 bool MultiTypeMath::operator!=(const MultiTypeString& mts) const 108 { 109 return MultiTypeString::operator!=(mts); 110 } 111 112 bool MultiTypeMath::operator!=(const MultiTypePrimitive& mtp) const 113 { 114 return MultiTypePrimitive::operator!=(mtp); 89 115 } 90 116 … … 123 149 MultiTypeMath::operator orxonox::Vector3() const 124 150 { return (this->type_ == MT_vector3) ? this->vector3_ : getConvertedValue<MultiTypeMath, orxonox::Vector3>(*this); } 151 MultiTypeMath::operator orxonox::Vector4() const 152 { return (this->type_ == MT_vector4) ? this->vector4_ : getConvertedValue<MultiTypeMath, orxonox::Vector4>(*this); } 125 153 MultiTypeMath::operator orxonox::Quaternion() const 126 154 { return (this->type_ == MT_quaternion) ? this->quaternion_ : getConvertedValue<MultiTypeMath, orxonox::Quaternion>(*this); } … … 137 165 this->vector2_ = mtm.vector2_; 138 166 this->vector3_ = mtm.vector3_; 167 this->vector4_ = mtm.vector4_; 139 168 this->quaternion_ = mtm.quaternion_; 140 169 this->colourvalue_ = mtm.colourvalue_; … … 143 172 } 144 173 174 void MultiTypeMath::setValue(const MultiTypeString& mts) 175 { 176 MultiTypeString::setValue(mts); 177 } 178 179 void MultiTypeMath::setValue(const MultiTypePrimitive& mtp) 180 { 181 MultiTypePrimitive::setValue(mtp); 182 } 183 145 184 std::string MultiTypeMath::getTypename() const 146 185 { … … 149 188 else if (this->type_ == MT_vector3) 150 189 return "Vector3"; 190 else if (this->type_ == MT_vector4) 191 return "Vector4"; 151 192 else if (this->type_ == MT_colourvalue) 152 193 return "ColourValue"; … … 169 210 else if (this->type_ == MT_vector3) 170 211 ConvertValue(&output, this->vector3_); 212 else if (this->type_ == MT_vector4) 213 ConvertValue(&output, this->vector4_); 171 214 else if (this->type_ == MT_colourvalue) 172 215 ConvertValue(&output, this->colourvalue_); … … 189 232 else if (this->type_ == MT_vector3) 190 233 return ConvertValue(&this->vector3_, value, orxonox::Vector3(0, 0, 0)); 234 else if (this->type_ == MT_vector4) 235 return ConvertValue(&this->vector4_, value, orxonox::Vector4(0, 0, 0, 0)); 191 236 else if (this->type_ == MT_colourvalue) 192 237 return ConvertValue(&this->colourvalue_, value, orxonox::ColourValue(0, 0, 0, 0)); … … 201 246 } 202 247 248 bool MultiTypeMath::assimilate(const MultiTypeMath& mtm, const MultiTypeMath& defvalue) 249 { 250 if (this->type_ == MT_void) 251 return ConvertValue(&this->value_.void_, mtm, defvalue.value_.void_); 252 else if (this->type_ == MT_int) 253 return ConvertValue(&this->value_.int_, mtm, defvalue.value_.int_); 254 else if (this->type_ == MT_uint) 255 return ConvertValue(&this->value_.uint_, mtm, defvalue.value_.uint_); 256 else if (this->type_ == MT_char) 257 return ConvertValue(&this->value_.char_, mtm, defvalue.value_.char_); 258 else if (this->type_ == MT_uchar) 259 return ConvertValue(&this->value_.uchar_, mtm, defvalue.value_.uchar_); 260 else if (this->type_ == MT_short) 261 return ConvertValue(&this->value_.short_, mtm, defvalue.value_.short_); 262 else if (this->type_ == MT_ushort) 263 return ConvertValue(&this->value_.ushort_, mtm, defvalue.value_.ushort_); 264 else if (this->type_ == MT_long) 265 return ConvertValue(&this->value_.long_, mtm, defvalue.value_.long_); 266 else if (this->type_ == MT_ulong) 267 return ConvertValue(&this->value_.ulong_, mtm, defvalue.value_.ulong_); 268 else if (this->type_ == MT_float) 269 return ConvertValue(&this->value_.float_, mtm, defvalue.value_.float_); 270 else if (this->type_ == MT_double) 271 return ConvertValue(&this->value_.double_, mtm, defvalue.value_.double_); 272 else if (this->type_ == MT_longdouble) 273 return ConvertValue(&this->value_.longdouble_, mtm, defvalue.value_.longdouble_); 274 else if (this->type_ == MT_bool) 275 return ConvertValue(&this->value_.bool_, mtm, defvalue.value_.bool_); 276 else if (this->type_ == MT_constchar) 277 return ConvertValue(&this->string_, mtm, defvalue.string_); 278 else if (this->type_ == MT_string) 279 return ConvertValue(&this->string_, mtm, defvalue.string_); 280 else if (this->type_ == MT_vector2) 281 return ConvertValue(&this->vector2_, mtm, defvalue.vector2_); 282 else if (this->type_ == MT_vector3) 283 return ConvertValue(&this->vector3_, mtm, defvalue.vector3_); 284 else if (this->type_ == MT_vector4) 285 return ConvertValue(&this->vector4_, mtm, defvalue.vector4_); 286 else if (this->type_ == MT_colourvalue) 287 return ConvertValue(&this->colourvalue_, mtm, defvalue.colourvalue_); 288 else if (this->type_ == MT_quaternion) 289 return ConvertValue(&this->quaternion_, mtm, defvalue.quaternion_); 290 else if (this->type_ == MT_radian) 291 return ConvertValue(&this->radian_, mtm, defvalue.radian_); 292 else if (this->type_ == MT_degree) 293 return ConvertValue(&this->degree_, mtm, defvalue.degree_); 294 else 295 return false; 296 } 297 203 298 std::ostream& operator<<(std::ostream& out, MultiTypeMath& mtm) 204 299 { -
code/branches/network/src/util/MultiTypeMath.h
r1064 r1446 63 63 inline MultiTypeMath(const orxonox::Vector2& value) { this->setValue(value); } 64 64 inline MultiTypeMath(const orxonox::Vector3& value) { this->setValue(value); } 65 inline MultiTypeMath(const orxonox::Vector4& value) { this->setValue(value); } 65 66 inline MultiTypeMath(const orxonox::ColourValue& value) { this->setValue(value); } 66 67 inline MultiTypeMath(const orxonox::Quaternion& value) { this->setValue(value); } … … 68 69 inline MultiTypeMath(const orxonox::Degree& value) { this->setValue(value); } 69 70 inline MultiTypeMath(const MultiTypeMath& mtm) { this->setValue(mtm); } 71 inline MultiTypeMath(const MultiTypeString& mts) { this->setValue(mts); } 72 inline MultiTypeMath(const MultiTypePrimitive& mtp) { this->setValue(mtp); } 70 73 virtual inline ~MultiTypeMath() {} 71 74 … … 73 76 inline MultiTypeMath& operator=(const orxonox::Vector2& value) { this->setValue(value); return *this; } 74 77 inline MultiTypeMath& operator=(const orxonox::Vector3& value) { this->setValue(value); return *this; } 78 inline MultiTypeMath& operator=(const orxonox::Vector4& value) { this->setValue(value); return *this; } 75 79 inline MultiTypeMath& operator=(const orxonox::ColourValue& value) { this->setValue(value); return *this; } 76 80 inline MultiTypeMath& operator=(const orxonox::Quaternion& value) { this->setValue(value); return *this; } … … 78 82 inline MultiTypeMath& operator=(const orxonox::Degree& value) { this->setValue(value); return *this; } 79 83 inline MultiTypeMath& operator=(const MultiTypeMath& mtm) { this->setValue(mtm); return *this; } 84 inline MultiTypeMath& operator=(const MultiTypeString& mts) { this->setValue(mts); return *this; } 85 inline MultiTypeMath& operator=(const MultiTypePrimitive mtp) { this->setValue(mtp); return *this; } 80 86 81 87 using MultiTypeString::operator==; 82 88 inline bool operator==(const orxonox::Vector2& value) const { return (this->vector2_ == value); } 83 89 inline bool operator==(const orxonox::Vector3& value) const { return (this->vector3_ == value); } 90 inline bool operator==(const orxonox::Vector4& value) const { return (this->vector4_ == value); } 84 91 inline bool operator==(const orxonox::ColourValue& value) const { return (this->colourvalue_ == value); } 85 92 inline bool operator==(const orxonox::Quaternion& value) const { return (this->quaternion_ == value); } … … 87 94 inline bool operator==(const orxonox::Degree& value) const { return (this->degree_ == value); } 88 95 bool operator==(const MultiTypeMath& mtm) const; 96 bool operator==(const MultiTypeString& mts) const; 97 bool operator==(const MultiTypePrimitive& mtp) const; 89 98 90 99 using MultiTypeString::operator!=; 91 100 inline bool operator!=(const orxonox::Vector2& value) const { return (this->vector2_ != value); } 92 101 inline bool operator!=(const orxonox::Vector3& value) const { return (this->vector3_ != value); } 102 inline bool operator!=(const orxonox::Vector4& value) const { return (this->vector4_ != value); } 93 103 inline bool operator!=(const orxonox::ColourValue& value) const { return (this->colourvalue_ != value); } 94 104 inline bool operator!=(const orxonox::Quaternion& value) const { return (this->quaternion_ != value); } … … 96 106 inline bool operator!=(const orxonox::Degree& value) const { return (this->degree_ != value); } 97 107 bool operator!=(const MultiTypeMath& mtm) const; 108 bool operator!=(const MultiTypeString& mts) const; 109 bool operator!=(const MultiTypePrimitive& mtp) const; 98 110 99 111 virtual operator void*() const; … … 114 126 virtual operator orxonox::Vector2() const; 115 127 virtual operator orxonox::Vector3() const; 128 virtual operator orxonox::Vector4() const; 116 129 virtual operator orxonox::ColourValue() const; 117 130 virtual operator orxonox::Quaternion() const; … … 122 135 inline void setValue(const orxonox::Vector2& value) { this->type_ = MT_vector2; this->vector2_ = value; } 123 136 inline void setValue(const orxonox::Vector3& value) { this->type_ = MT_vector3; this->vector3_ = value; } 137 inline void setValue(const orxonox::Vector4& value) { this->type_ = MT_vector4; this->vector4_ = value; } 124 138 inline void setValue(const orxonox::ColourValue& value) { this->type_ = MT_colourvalue; this->colourvalue_ = value; } 125 139 inline void setValue(const orxonox::Quaternion& value) { this->type_ = MT_quaternion; this->quaternion_ = value; } … … 127 141 inline void setValue(const orxonox::Degree& value) { this->type_ = MT_degree; this->degree_ = value; } 128 142 void setValue(const MultiTypeMath& mtm); 143 void setValue(const MultiTypeString& mts); 144 void setValue(const MultiTypePrimitive& mtp); 129 145 130 146 inline orxonox::Vector2 getVector2() const { return this->vector2_; } 131 147 inline orxonox::Vector3 getVector3() const { return this->vector3_; } 148 inline orxonox::Vector4 getVector4() const { return this->vector4_; } 132 149 inline orxonox::ColourValue getColourValue() const { return this->colourvalue_; } 133 150 inline orxonox::Quaternion getQuaternion() const { return this->quaternion_; } … … 137 154 inline orxonox::Vector2& getVector2() { return this->vector2_; } 138 155 inline orxonox::Vector3& getVector3() { return this->vector3_; } 156 inline orxonox::Vector4& getVector4() { return this->vector4_; } 139 157 inline orxonox::ColourValue& getColourValue() { return this->colourvalue_; } 140 158 inline orxonox::Quaternion& getQuaternion() { return this->quaternion_; } … … 145 163 inline void getValue(orxonox::Vector2* variable) const { (*variable) = orxonox::Vector2 (this->vector2_); } 146 164 inline void getValue(orxonox::Vector3* variable) const { (*variable) = orxonox::Vector3 (this->vector3_); } 165 inline void getValue(orxonox::Vector4* variable) const { (*variable) = orxonox::Vector4 (this->vector4_); } 147 166 inline void getValue(orxonox::ColourValue* variable) const { (*variable) = orxonox::ColourValue (this->colourvalue_); } 148 167 inline void getValue(orxonox::Quaternion* variable) const { (*variable) = orxonox::Quaternion (this->quaternion_); } … … 155 174 virtual bool fromString(const std::string value); 156 175 176 virtual bool assimilate(const MultiTypeMath& mtm, const MultiTypeMath& defvalue = MultiTypeMath()); 177 157 178 protected: 158 179 orxonox::Vector2 vector2_; 159 180 orxonox::Vector3 vector3_; 181 orxonox::Vector4 vector4_; 160 182 orxonox::ColourValue colourvalue_; 161 183 orxonox::Quaternion quaternion_; -
code/branches/network/src/util/MultiTypePrimitive.cc
r1056 r1446 266 266 } 267 267 268 bool MultiTypePrimitive::assimilate(const MultiTypePrimitive& mtp, const MultiTypePrimitive& defvalue) 269 { 270 if (this->type_ == MT_void) 271 return ConvertValue(&this->value_.void_, mtp, defvalue.value_.void_); 272 else if (this->type_ == MT_int) 273 return ConvertValue(&this->value_.int_, mtp, defvalue.value_.int_); 274 else if (this->type_ == MT_uint) 275 return ConvertValue(&this->value_.uint_, mtp, defvalue.value_.uint_); 276 else if (this->type_ == MT_char) 277 return ConvertValue(&this->value_.char_, mtp, defvalue.value_.char_); 278 else if (this->type_ == MT_uchar) 279 return ConvertValue(&this->value_.uchar_, mtp, defvalue.value_.uchar_); 280 else if (this->type_ == MT_short) 281 return ConvertValue(&this->value_.short_, mtp, defvalue.value_.short_); 282 else if (this->type_ == MT_ushort) 283 return ConvertValue(&this->value_.ushort_, mtp, defvalue.value_.ushort_); 284 else if (this->type_ == MT_long) 285 return ConvertValue(&this->value_.long_, mtp, defvalue.value_.long_); 286 else if (this->type_ == MT_ulong) 287 return ConvertValue(&this->value_.ulong_, mtp, defvalue.value_.ulong_); 288 else if (this->type_ == MT_float) 289 return ConvertValue(&this->value_.float_, mtp, defvalue.value_.float_); 290 else if (this->type_ == MT_double) 291 return ConvertValue(&this->value_.double_, mtp, defvalue.value_.double_); 292 else if (this->type_ == MT_longdouble) 293 return ConvertValue(&this->value_.longdouble_, mtp, defvalue.value_.longdouble_); 294 else if (this->type_ == MT_bool) 295 return ConvertValue(&this->value_.bool_, mtp, defvalue.value_.bool_); 296 else 297 return false; 298 299 } 300 268 301 std::ostream& operator<<(std::ostream& out, const MultiTypePrimitive& mtp) 269 302 { -
code/branches/network/src/util/MultiTypePrimitive.h
r1062 r1446 138 138 void setValue(const MultiTypePrimitive& mtp); 139 139 140 inline void* getVoid() const { return this->value_.void_; 140 inline void* getVoid() const { return this->value_.void_; } 141 141 inline int getInt() const { return this->value_.int_; } 142 142 inline unsigned int getUnsignedInt() const { return this->value_.uint_; } … … 187 187 virtual bool fromString(const std::string value); 188 188 189 virtual bool assimilate(const MultiTypePrimitive& mtp, const MultiTypePrimitive& defvalue = MultiTypePrimitive()); 190 189 191 protected: 190 192 MultiTypeValue value_; -
code/branches/network/src/util/MultiTypeString.cc
r1064 r1446 33 33 MultiTypeString::MultiTypeString(MultiType type) : MultiTypePrimitive(type) 34 34 { 35 // Nothing to do for string and xml-element35 // Nothing to do for string 36 36 } 37 37 … … 49 49 } 50 50 51 bool MultiTypeString::operator==(const MultiTypePrimitive& mtp) const 52 { 53 return MultiTypePrimitive::operator==(mtp); 54 } 55 51 56 bool MultiTypeString::operator!=(const MultiTypeString& mts) const 52 57 { … … 60 65 61 66 return true; 67 } 68 69 bool MultiTypeString::operator!=(const MultiTypePrimitive& mtp) const 70 { 71 return MultiTypePrimitive::operator!=(mtp); 62 72 } 63 73 … … 99 109 } 100 110 111 void MultiTypeString::setValue(const MultiTypePrimitive& mtp) 112 { 113 MultiTypePrimitive::setValue(mtp); 114 } 115 101 116 std::string MultiTypeString::getTypename() const 102 117 { … … 136 151 } 137 152 153 bool MultiTypeString::assimilate(const MultiTypeString& mts, const MultiTypeString& defvalue) 154 { 155 if (this->type_ == MT_void) 156 return ConvertValue(&this->value_.void_, mts, defvalue.value_.void_); 157 else if (this->type_ == MT_int) 158 return ConvertValue(&this->value_.int_, mts, defvalue.value_.int_); 159 else if (this->type_ == MT_uint) 160 return ConvertValue(&this->value_.uint_, mts, defvalue.value_.uint_); 161 else if (this->type_ == MT_char) 162 return ConvertValue(&this->value_.char_, mts, defvalue.value_.char_); 163 else if (this->type_ == MT_uchar) 164 return ConvertValue(&this->value_.uchar_, mts, defvalue.value_.uchar_); 165 else if (this->type_ == MT_short) 166 return ConvertValue(&this->value_.short_, mts, defvalue.value_.short_); 167 else if (this->type_ == MT_ushort) 168 return ConvertValue(&this->value_.ushort_, mts, defvalue.value_.ushort_); 169 else if (this->type_ == MT_long) 170 return ConvertValue(&this->value_.long_, mts, defvalue.value_.long_); 171 else if (this->type_ == MT_ulong) 172 return ConvertValue(&this->value_.ulong_, mts, defvalue.value_.ulong_); 173 else if (this->type_ == MT_float) 174 return ConvertValue(&this->value_.float_, mts, defvalue.value_.float_); 175 else if (this->type_ == MT_double) 176 return ConvertValue(&this->value_.double_, mts, defvalue.value_.double_); 177 else if (this->type_ == MT_longdouble) 178 return ConvertValue(&this->value_.longdouble_, mts, defvalue.value_.longdouble_); 179 else if (this->type_ == MT_bool) 180 return ConvertValue(&this->value_.bool_, mts, defvalue.value_.bool_); 181 else if (this->type_ == MT_constchar) 182 return ConvertValue(&this->string_, mts, defvalue.string_); 183 else if (this->type_ == MT_string) 184 return ConvertValue(&this->string_, mts, defvalue.string_); 185 else 186 return false; 187 } 188 138 189 std::ostream& operator<<(std::ostream& out, MultiTypeString& mts) 139 190 { -
code/branches/network/src/util/MultiTypeString.h
r1064 r1446 61 61 inline MultiTypeString(long double value) : MultiTypePrimitive(value) {} 62 62 inline MultiTypeString(bool value) : MultiTypePrimitive(value) {} 63 inline MultiTypeString(const char* value) { this->setValue(value); } 64 inline MultiTypeString(const std::string& value) { this->setValue(value); } 65 inline MultiTypeString(const MultiTypeString& mts) { this->setValue(mts); } 63 inline MultiTypeString(const char* value) { this->setValue(value); } 64 inline MultiTypeString(const std::string& value) { this->setValue(value); } 65 inline MultiTypeString(const MultiTypeString& mts) { this->setValue(mts); } 66 inline MultiTypeString(const MultiTypePrimitive& mtp) { this->setValue(mtp); } 66 67 virtual inline ~MultiTypeString() {} 67 68 68 69 using MultiTypePrimitive::operator=; 69 inline MultiTypeString& operator=(const char* value) { this->setValue(value); return *this; } 70 inline MultiTypeString& operator=(const std::string& value) { this->setValue(value); return *this; } 71 inline MultiTypeString& operator=(const MultiTypeString& mts) { this->setValue(mts); return *this; } 70 inline MultiTypeString& operator=(const char* value) { this->setValue(value); return *this; } 71 inline MultiTypeString& operator=(const std::string& value) { this->setValue(value); return *this; } 72 inline MultiTypeString& operator=(const MultiTypeString& mts) { this->setValue(mts); return *this; } 73 inline MultiTypeString& operator=(const MultiTypePrimitive& mtp) { this->setValue(mtp); return *this; } 72 74 73 75 using MultiTypePrimitive::operator==; 74 inline bool operator==(const char* value) const { return (this->string_ == std::string(value)); } 75 inline bool operator==(const std::string& value) const { return (this->string_ == value); } 76 bool operator==(const MultiTypeString& mts) const; 76 inline bool operator==(const char* value) const { return (this->string_ == std::string(value)); } 77 inline bool operator==(const std::string& value) const { return (this->string_ == value); } 78 bool operator==(const MultiTypeString& mts) const; 79 bool operator==(const MultiTypePrimitive& mtp) const; 77 80 78 81 using MultiTypePrimitive::operator!=; 79 inline bool operator!=(const char* value) const { return (this->string_ != std::string(value)); } 80 inline bool operator!=(const std::string& value) const { return (this->string_ != value); } 81 bool operator!=(const MultiTypeString& mts) const; 82 inline bool operator!=(const char* value) const { return (this->string_ != std::string(value)); } 83 inline bool operator!=(const std::string& value) const { return (this->string_ != value); } 84 bool operator!=(const MultiTypeString& mts) const; 85 bool operator!=(const MultiTypePrimitive& mtp) const; 82 86 83 virtual operator void*() 84 virtual operator int() 85 virtual operator unsigned int() 86 virtual operator char() 87 virtual operator unsigned char() 88 virtual operator short() 89 virtual operator unsigned short() 90 virtual operator long() 91 virtual operator unsigned long() 92 virtual operator float () 93 virtual operator double () 94 virtual operator long double() 95 virtual operator bool() 96 virtual operator std::string() 97 virtual operator const char*() 87 virtual operator void*() const; 88 virtual operator int() const; 89 virtual operator unsigned int() const; 90 virtual operator char() const; 91 virtual operator unsigned char() const; 92 virtual operator short() const; 93 virtual operator unsigned short() const; 94 virtual operator long() const; 95 virtual operator unsigned long() const; 96 virtual operator float () const; 97 virtual operator double () const; 98 virtual operator long double() const; 99 virtual operator bool() const; 100 virtual operator std::string() const; 101 virtual operator const char*() const; 98 102 99 103 using MultiTypePrimitive::setValue; 100 inline void setValue(const char* value) { this->type_ = MT_string; this->string_ = std::string(value); } 101 inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value; } 102 void setValue(const MultiTypeString& mts); 104 inline void setValue(const char* value) { this->type_ = MT_string; this->string_ = std::string(value); } 105 inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value; } 106 void setValue(const MultiTypeString& mts); 107 void setValue(const MultiTypePrimitive& mtp); 103 108 104 inline std::string getString() 105 inline const char* getConstChar() 109 inline std::string getString() const { return this->string_; } 110 inline const char* getConstChar() const { return this->string_.c_str(); } 106 111 107 inline std::string& getString() 108 inline const char* getConstChar() 112 inline std::string& getString() { return this->string_; } 113 inline const char* getConstChar() { return this->string_.c_str(); } 109 114 110 115 using MultiTypePrimitive::getValue; 111 inline void getValue(std::string* 112 inline void getValue(const char** 116 inline void getValue(std::string* variable) const { (*variable) = this->string_; } 117 inline void getValue(const char** variable) const { (*variable) = this->string_.c_str(); } 113 118 114 119 virtual std::string getTypename() const; … … 116 121 virtual std::string toString() const; 117 122 virtual bool fromString(const std::string value); 123 124 virtual bool assimilate(const MultiTypeString& mts, const MultiTypeString& defvalue = MultiTypeString()); 118 125 119 126 protected: -
code/branches/network/src/util/String.cc
r1219 r1446 185 185 else 186 186 return str; 187 } 188 189 /** 190 @brief Removes enclosing {braces}. 191 @param str The string to strip 192 @return The striped string 193 */ 194 std::string stripEnclosingBraces(const std::string& str) 195 { 196 std::string output = str; 197 198 while (output.size() >= 2 && output[0] == '{' && output[output.size() - 1] == '}') 199 output = output.substr(1, output.size() - 2); 200 201 return output; 187 202 } 188 203 -
code/branches/network/src/util/String.h
r1062 r1446 47 47 48 48 _UtilExport std::string stripEnclosingQuotes(const std::string& str); 49 _UtilExport std::string stripEnclosingBraces(const std::string& str); 49 50 50 51 _UtilExport bool isEmpty(const std::string& str);
Note: See TracChangeset
for help on using the changeset viewer.