- Timestamp:
- Dec 31, 2015, 1:04:04 AM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/libraries/util
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/util/MultiType.cc
r9550 r11008 43 43 @param type The type 44 44 */ 45 bool MultiType::convert(Type ::Enumtype)45 bool MultiType::convert(Type type) 46 46 { 47 47 switch (type) … … 106 106 std::string MultiType::getTypename() const 107 107 { 108 Type ::Enumtype = (this->value_) ? this->value_->type_ : Type::Null;108 Type type = (this->value_) ? this->value_->type_ : Type::Null; 109 109 110 110 switch (type) -
code/branches/cpp11_v2/src/libraries/util/MultiType.h
r11002 r11008 132 132 template <typename T> friend class MT_Value; 133 133 134 struct Type 134 /** 135 @brief Enum of all possible types of a MultiType. 136 */ 137 enum class Type : uint8_t 135 138 { 136 /** 137 @brief Enum of all possible types of a MultiType. 138 */ 139 enum Enum 140 { 141 Null, 142 Char, 143 UnsignedChar, 144 Short, 145 UnsignedShort, 146 Int, 147 UnsignedInt, 148 Long, 149 UnsignedLong, 150 LongLong, 151 UnsignedLongLong, 152 Float, 153 Double, 154 LongDouble, 155 Bool, 156 VoidPointer, 157 String, 158 Vector2, 159 Vector3, 160 Vector4, 161 ColourValue, 162 Quaternion, 163 Radian, 164 Degree 165 }; 139 Null, 140 Char, 141 UnsignedChar, 142 Short, 143 UnsignedShort, 144 Int, 145 UnsignedInt, 146 Long, 147 UnsignedLong, 148 LongLong, 149 UnsignedLongLong, 150 Float, 151 Double, 152 LongDouble, 153 Bool, 154 VoidPointer, 155 String, 156 Vector2, 157 Vector3, 158 Vector4, 159 ColourValue, 160 Quaternion, 161 Radian, 162 Degree 166 163 }; 167 164 … … 174 171 { 175 172 public: 176 inline MT_ValueBase(void* data, Type ::Enumtype) : type_(type), bLastConversionSuccessful(true), data_(data) {}173 inline MT_ValueBase(void* data, Type type) : type_(type), bLastConversionSuccessful(true), data_(data) {} 177 174 virtual inline ~MT_ValueBase() {} 178 175 … … 182 179 183 180 /// Returns the type of the current value. 184 inline const Type ::Enum& getType() const { return this->type_; }181 inline const Type& getType() const { return this->type_; } 185 182 186 183 /// Returns true if the type of the stored value is T. Note: the actual implementations for all supported types are defined outside of the class. … … 298 295 virtual uint8_t getSize() const = 0; 299 296 300 Type ::Enum type_;///< The type of the current value297 Type type_; ///< The type of the current value 301 298 bool bLastConversionSuccessful; ///< True if the last conversion was successful 302 299 void* data_; ///< For direct access to the value if the type is known … … 409 406 inline void exportData(uint8_t*& mem) const 410 407 { 411 assert(sizeof(Type ::Enum) <= 8);412 *static_cast<uint8_t*>(mem) = this->getType();408 assert(sizeof(Type) <= 8); 409 *static_cast<uint8_t*>(mem) = static_cast<uint8_t>(this->getType()); 413 410 mem += sizeof(uint8_t); 414 411 this->value_->exportData(mem); … … 417 414 inline void importData(uint8_t*& mem) 418 415 { 419 assert(sizeof(Type ::Enum) <= 8);420 this->setType(static_cast<Type ::Enum>(*static_cast<uint8_t*>(mem)));416 assert(sizeof(Type) <= 8); 417 this->setType(static_cast<Type>(*static_cast<uint8_t*>(mem))); 421 418 mem += sizeof(uint8_t); 422 419 this->value_->importData(mem); … … 458 455 459 456 /// Resets the value and changes the internal type to the given type. 460 inline void setType(Type ::Enumtype) { this->reset(); this->convert(type); this->resetValue(); }457 inline void setType(Type type) { this->reset(); this->convert(type); this->resetValue(); } 461 458 /// Returns the current type. 462 inline Type ::EnumgetType() const { return (this->value_) ? this->value_->type_ : Type::Null; }459 inline Type getType() const { return (this->value_) ? this->value_->type_ : Type::Null; } 463 460 /// Converts the current value to the given type. 464 bool convert(Type ::Enumtype);461 bool convert(Type type); 465 462 466 463 /// Changes the value container. -
code/branches/cpp11_v2/src/libraries/util/MultiTypeValue.h
r10845 r11008 55 55 public: 56 56 /// Constructor: Assigns the value and the type identifier. 57 MT_Value(const T& value, MultiType::Type ::Enumtype) : MT_ValueBase(&this->value_, type), value_(value) {}57 MT_Value(const T& value, MultiType::Type type) : MT_ValueBase(&this->value_, type), value_(value) {} 58 58 59 59 /// Creates a copy of itself. -
code/branches/cpp11_v2/src/libraries/util/SubString.cc
r10918 r11008 265 265 bool inSafemode = false; 266 266 267 if(start_state != S L_NORMAL && tokens.size() > 0)267 if(start_state != SPLIT_LINE_STATE::NORMAL && tokens.size() > 0) 268 268 { 269 269 token = tokens[tokens.size()-1]; 270 270 tokens.pop_back(); 271 271 } 272 if(start_state != S L_NORMAL && bTokenInSafemode.size() > 0)272 if(start_state != SPLIT_LINE_STATE::NORMAL && bTokenInSafemode.size() > 0) 273 273 { 274 274 inSafemode = bTokenInSafemode[bTokenInSafemode.size()-1]; … … 280 280 switch(state) 281 281 { 282 case S L_NORMAL:282 case SPLIT_LINE_STATE::NORMAL: 283 283 if(line[i] == escapeChar) 284 284 { 285 state = S L_ESCAPE;285 state = SPLIT_LINE_STATE::ESCAPE; 286 286 if (!bRemoveEscapeChar) 287 287 token += line[i]; … … 290 290 else if(line[i] == safemodeChar) 291 291 { 292 state = S L_SAFEMODE;292 state = SPLIT_LINE_STATE::SAFEMODE; 293 293 inSafemode = true; 294 294 if (!bRemoveSafemodeChar) … … 298 298 else if(line[i] == openparenthesisChar) 299 299 { 300 state = S L_PARENTHESES;300 state = SPLIT_LINE_STATE::PARENTHESES; 301 301 inSafemode = true; 302 302 if (!bRemoveParenthesisChars) … … 318 318 } 319 319 token += line[i]; // EAT 320 state = S L_COMMENT;320 state = SPLIT_LINE_STATE::COMMENT; 321 321 } 322 322 else if(delimiters.find(line[i]) != std::string::npos) … … 334 334 inSafemode = false; 335 335 } 336 state = S L_NORMAL;336 state = SPLIT_LINE_STATE::NORMAL; 337 337 } 338 338 else … … 353 353 } 354 354 break; 355 case S L_ESCAPE:355 case SPLIT_LINE_STATE::ESCAPE: 356 356 if (!bRemoveSafemodeChar) 357 357 token += line[i]; … … 368 368 else token += line[i]; // EAT 369 369 } 370 state = S L_NORMAL;371 break; 372 case S L_SAFEMODE:370 state = SPLIT_LINE_STATE::NORMAL; 371 break; 372 case SPLIT_LINE_STATE::SAFEMODE: 373 373 if(line[i] == safemodeChar) 374 374 { 375 state = S L_NORMAL;375 state = SPLIT_LINE_STATE::NORMAL; 376 376 if (!bRemoveSafemodeChar) 377 377 token += line[i]; … … 379 379 else if(line[i] == escapeChar) 380 380 { 381 state = S L_SAFEESCAPE;381 state = SPLIT_LINE_STATE::SAFEESCAPE; 382 382 } 383 383 else … … 387 387 break; 388 388 389 case S L_SAFEESCAPE:389 case SPLIT_LINE_STATE::SAFEESCAPE: 390 390 if(line[i] == 'n') token += '\n'; 391 391 else if(line[i] == 't') token += '\t'; … … 397 397 else if(line[i] == '?') token += '\?'; 398 398 else token += line[i]; // EAT 399 state = S L_SAFEMODE;400 break; 401 402 case S L_PARENTHESES:399 state = SPLIT_LINE_STATE::SAFEMODE; 400 break; 401 402 case SPLIT_LINE_STATE::PARENTHESES: 403 403 if(line[i] == closeparenthesisChar) 404 404 { 405 state = S L_NORMAL;405 state = SPLIT_LINE_STATE::NORMAL; 406 406 if (!bRemoveParenthesisChars) 407 407 token += line[i]; … … 409 409 else if(line[i] == escapeChar) 410 410 { 411 state = S L_PARENTHESESESCAPE;411 state = SPLIT_LINE_STATE::PARENTHESESESCAPE; 412 412 } 413 413 else … … 417 417 break; 418 418 419 case S L_PARENTHESESESCAPE:419 case SPLIT_LINE_STATE::PARENTHESESESCAPE: 420 420 if(line[i] == 'n') token += '\n'; 421 421 else if(line[i] == 't') token += '\t'; … … 427 427 else if(line[i] == '?') token += '\?'; 428 428 else token += line[i]; // EAT 429 state = S L_PARENTHESES;430 break; 431 432 case S L_COMMENT:429 state = SPLIT_LINE_STATE::PARENTHESES; 430 break; 431 432 case SPLIT_LINE_STATE::COMMENT: 433 433 if(line[i] == '\n') 434 434 { … … 441 441 inSafemode = false; 442 442 } 443 state = S L_NORMAL;443 state = SPLIT_LINE_STATE::NORMAL; 444 444 } 445 445 else -
code/branches/cpp11_v2/src/libraries/util/SubString.h
r9550 r11008 102 102 { 103 103 /// An enumerator for the internal state of the parser 104 enum SPLIT_LINE_STATE104 enum class SPLIT_LINE_STATE 105 105 { 106 SL_NORMAL, //!< Normal state107 SL_ESCAPE, //!< After an escape character108 S L_SAFEMODE, //!< In safe mode (usually between quotation marks).109 S L_SAFEESCAPE, //!< In safe mode with the internal escape character, that escapes even the savemode character.110 SL_COMMENT, //!< In Comment mode.111 SL_PARENTHESES, //!< Between parentheses (usually '{' and '}')112 SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing parenthesis character.106 NORMAL, //!< Normal state 107 ESCAPE, //!< After an escape character 108 SAFEMODE, //!< In safe mode (usually between quotation marks). 109 SAFEESCAPE, //!< In safe mode with the internal escape character, that escapes even the savemode character. 110 COMMENT, //!< In Comment mode. 111 PARENTHESES, //!< Between parentheses (usually '{' and '}') 112 PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing parenthesis character. 113 113 }; 114 114 … … 204 204 bool bRemoveParenthesisChars = true, 205 205 char commentChar = '\0', 206 SPLIT_LINE_STATE start_state = S L_NORMAL);206 SPLIT_LINE_STATE start_state = SPLIT_LINE_STATE::NORMAL); 207 207 208 208 std::vector<std::string> tokens_; ///< The tokens after splitting the input line
Note: See TracChangeset
for help on using the changeset viewer.