[1505] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Christian Meyer |
---|
| 24 | * Co-authors: |
---|
| 25 | * Benjamin Grauer |
---|
| 26 | * |
---|
[1791] | 27 | |
---|
[1505] | 28 | // |
---|
| 29 | // splitLine |
---|
| 30 | // STL string tokenizer |
---|
| 31 | // |
---|
| 32 | // Created by Clemens Wacha. |
---|
| 33 | // Version 1.0 |
---|
| 34 | // Copyright (c) 2005 Clemens Wacha. All rights reserved. |
---|
| 35 | // |
---|
[1791] | 36 | |
---|
| 37 | * Extended by Fabian 'x3n' Landau by the SL_PARENTHESES mode. |
---|
[1505] | 38 | */ |
---|
[836] | 39 | |
---|
[7401] | 40 | /** |
---|
| 41 | @file |
---|
| 42 | @brief Implementation of the SubString class. |
---|
| 43 | */ |
---|
| 44 | |
---|
[836] | 45 | #include "SubString.h" |
---|
[3196] | 46 | #include <cstdio> |
---|
[8858] | 47 | #include "Output.h" |
---|
[836] | 48 | |
---|
[2171] | 49 | namespace orxonox |
---|
| 50 | { |
---|
[7401] | 51 | const std::string SubString::WhiteSpaces = " \n\t"; |
---|
| 52 | const std::string SubString::WhiteSpacesWithComma = " \n\t,"; |
---|
| 53 | const SubString SubString::NullSubString = SubString(); |
---|
| 54 | |
---|
[2171] | 55 | /** |
---|
[7401] | 56 | @brief Default constructor. |
---|
| 57 | */ |
---|
[2171] | 58 | SubString::SubString() |
---|
| 59 | { |
---|
| 60 | } |
---|
[836] | 61 | |
---|
[2171] | 62 | /** |
---|
[7401] | 63 | @brief Splits a string into multiple tokens. |
---|
| 64 | @param line The line to split |
---|
| 65 | @param delimiters Multiple characters at which to split the line |
---|
| 66 | @param delimiterNeighbours Neighbours of the delimiters that will be erased as well (for example white-spaces) |
---|
| 67 | @param bAllowEmptyEntries If true, empty tokens are also added to the SubString (if there are two delimiters without a char in between) |
---|
| 68 | @param escapeChar The escape character that is used to escape safemode chars (for example if you want to use a quotation mark between two other quotation marks). |
---|
| 69 | @param bRemoveEscapeChar If true, the escape char is removed from the tokens |
---|
| 70 | @param safemodeChar Within these characters splitting won't happen (usually the quotation marks) |
---|
| 71 | @param bRemoveSafemodeChar Removes the safemodeChar from the beginning and the ending of a token |
---|
| 72 | @param openparenthesisChar The beginning of a safemode is marked with this (usually an opening brace) |
---|
| 73 | @param closeparenthesisChar The ending of a safemode is marked with this (usually a closing brace) |
---|
| 74 | @param bRemoveParenthesisChars Removes the parenthesis chars from the beginning and the ending of a token |
---|
| 75 | @param commentChar The comment character (used to ignore the part of the line after the comment char). |
---|
| 76 | */ |
---|
| 77 | SubString::SubString(const std::string& line, |
---|
| 78 | const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries, |
---|
| 79 | char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar, |
---|
| 80 | char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar) |
---|
[2171] | 81 | { |
---|
[7401] | 82 | SubString::splitLine(this->tokens_, this->bTokenInSafemode_, line, delimiters, delimiterNeighbours, bAllowEmptyEntries, escapeChar, bRemoveEscapeChar, safemodeChar, bRemoveSafemodeChar, openparenthesisChar, closeparenthesisChar, bRemoveParenthesisChars, commentChar); |
---|
[2171] | 83 | } |
---|
[836] | 84 | |
---|
[2171] | 85 | /** |
---|
[7401] | 86 | @brief creates a new SubString based on a subset of an other SubString. |
---|
| 87 | @param other The other SubString |
---|
| 88 | @param begin The beginning of the subset |
---|
[9550] | 89 | @param length The length of the subset |
---|
[7401] | 90 | |
---|
[9550] | 91 | The subset ranges from the token with index @a begin and contains @a length elements. |
---|
[7401] | 92 | */ |
---|
[9550] | 93 | SubString::SubString(const SubString& other, size_t begin, size_t length) |
---|
[2171] | 94 | { |
---|
[9550] | 95 | for (size_t i = 0; i < length; ++i) |
---|
[2171] | 96 | { |
---|
[9550] | 97 | if (begin + i >= other.size()) |
---|
| 98 | break; |
---|
[836] | 99 | |
---|
[9550] | 100 | this->tokens_.push_back(other[begin + i]); |
---|
| 101 | this->bTokenInSafemode_.push_back(other.isInSafemode(begin + i)); |
---|
[2171] | 102 | } |
---|
| 103 | } |
---|
[836] | 104 | |
---|
[2171] | 105 | /** |
---|
[7401] | 106 | @brief Creates a SubString from a count and values set. |
---|
| 107 | @param argc The number of arguments |
---|
| 108 | @param argv An array of pointers to the arguments |
---|
| 109 | */ |
---|
[9550] | 110 | SubString::SubString(size_t argc, const char** argv) |
---|
[2171] | 111 | { |
---|
[9550] | 112 | for (size_t i = 0; i < argc; ++i) |
---|
[2171] | 113 | { |
---|
[10918] | 114 | this->tokens_.emplace_back(argv[i]); |
---|
[7401] | 115 | this->bTokenInSafemode_.push_back(false); |
---|
[2171] | 116 | } |
---|
| 117 | } |
---|
[836] | 118 | |
---|
[2171] | 119 | /** |
---|
[7401] | 120 | @brief Destructor |
---|
| 121 | */ |
---|
[2171] | 122 | SubString::~SubString() |
---|
| 123 | { } |
---|
[836] | 124 | |
---|
[2171] | 125 | /** |
---|
[7401] | 126 | @brief Stores the tokens of @a other in this SubString |
---|
| 127 | @return This SubString. |
---|
| 128 | */ |
---|
| 129 | SubString& SubString::operator=(const SubString& other) |
---|
[2171] | 130 | { |
---|
[7401] | 131 | this->tokens_ = other.tokens_; |
---|
| 132 | this->bTokenInSafemode_ = other.bTokenInSafemode_; |
---|
[2171] | 133 | return *this; |
---|
| 134 | } |
---|
[836] | 135 | |
---|
[2171] | 136 | /** |
---|
[7401] | 137 | @brief Compares this SubString to another SubString and returns true if they contain the same values. |
---|
| 138 | */ |
---|
| 139 | bool SubString::operator==(const SubString& other) const |
---|
[2171] | 140 | { |
---|
[7401] | 141 | return ((this->tokens_ == other.tokens_) && (this->bTokenInSafemode_ == other.bTokenInSafemode_)); |
---|
[2171] | 142 | } |
---|
[836] | 143 | |
---|
[2171] | 144 | /** |
---|
[7401] | 145 | @brief Compares this SubString to another SubString and returns true if the first @a length values match. |
---|
| 146 | @param other The other SubString |
---|
| 147 | @param length How many tokens to compare |
---|
| 148 | */ |
---|
[9550] | 149 | bool SubString::compare(const SubString& other, size_t length) const |
---|
[2171] | 150 | { |
---|
[9550] | 151 | if (std::min(length, this->size()) != std::min(length, other.size())) |
---|
[2171] | 152 | return false; |
---|
[836] | 153 | |
---|
[9550] | 154 | for (size_t i = 0; i < std::min(length, this->size()); ++i) |
---|
[7401] | 155 | if ((this->tokens_[i] != other.tokens_[i]) || (this->bTokenInSafemode_[i] != other.bTokenInSafemode_[i])) |
---|
[2171] | 156 | return false; |
---|
[9550] | 157 | |
---|
[2171] | 158 | return true; |
---|
| 159 | } |
---|
[836] | 160 | |
---|
[2171] | 161 | /** |
---|
[7401] | 162 | @brief Concatenates the tokens of two SubStrings and returns the resulting new SubString |
---|
| 163 | @return A new SubString that contains the tokens of this and the other SubString |
---|
| 164 | */ |
---|
| 165 | SubString SubString::operator+(const SubString& other) const |
---|
[2171] | 166 | { |
---|
[7401] | 167 | return SubString(*this) += other; |
---|
[2171] | 168 | } |
---|
[836] | 169 | |
---|
[2171] | 170 | /** |
---|
[7401] | 171 | @brief Appends the tokens of @a other to this SubString |
---|
| 172 | @return This SubString |
---|
| 173 | */ |
---|
| 174 | SubString& SubString::operator+=(const SubString& other) |
---|
[2171] | 175 | { |
---|
[9550] | 176 | for (size_t i = 0; i < other.size(); ++i) |
---|
[2171] | 177 | { |
---|
[7401] | 178 | this->tokens_.push_back(other[i]); |
---|
| 179 | this->bTokenInSafemode_.push_back(other.isInSafemode(i)); |
---|
[2171] | 180 | } |
---|
| 181 | return *this; |
---|
| 182 | } |
---|
[836] | 183 | |
---|
[2171] | 184 | /** |
---|
[7401] | 185 | @copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char) |
---|
| 186 | */ |
---|
[9550] | 187 | size_t SubString::split(const std::string& line, |
---|
| 188 | const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries, |
---|
| 189 | char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar, |
---|
| 190 | char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar) |
---|
[2171] | 191 | { |
---|
[7401] | 192 | this->tokens_.clear(); |
---|
| 193 | this->bTokenInSafemode_.clear(); |
---|
| 194 | SubString::splitLine(this->tokens_, this->bTokenInSafemode_, line, delimiters, delimiterNeighbours, bAllowEmptyEntries, escapeChar, bRemoveEscapeChar, safemodeChar, bRemoveSafemodeChar, openparenthesisChar, closeparenthesisChar, bRemoveParenthesisChars, commentChar); |
---|
| 195 | return this->tokens_.size(); |
---|
[2171] | 196 | } |
---|
[836] | 197 | |
---|
[2171] | 198 | /** |
---|
[7401] | 199 | @brief Joins the tokens of this SubString using the given delimiter and returns a string. |
---|
| 200 | @param delimiter This delimiter will be placed between each two tokens |
---|
| 201 | @return The joined string. |
---|
| 202 | */ |
---|
[2171] | 203 | std::string SubString::join(const std::string& delimiter) const |
---|
| 204 | { |
---|
[7401] | 205 | if (!this->tokens_.empty()) |
---|
[2171] | 206 | { |
---|
[7401] | 207 | std::string retVal = this->tokens_[0]; |
---|
[9550] | 208 | for (size_t i = 1; i < this->tokens_.size(); ++i) |
---|
[7401] | 209 | retVal += delimiter + this->tokens_[i]; |
---|
[2171] | 210 | return retVal; |
---|
| 211 | } |
---|
| 212 | else |
---|
[6417] | 213 | return ""; |
---|
[2171] | 214 | } |
---|
[836] | 215 | |
---|
[7401] | 216 | /** |
---|
| 217 | @brief Creates a subset of this SubString. |
---|
| 218 | @param begin The beginning of the subset |
---|
[9550] | 219 | @param length The length of the subset |
---|
[7401] | 220 | @return A new SubString containing the defined subset. |
---|
[836] | 221 | |
---|
[9550] | 222 | The subset ranges from the token with index @a begin and contains @a length elements. |
---|
[7401] | 223 | |
---|
| 224 | This function is added for your convenience, and does the same as |
---|
[9550] | 225 | SubString::SubString(const SubString& other, size_t begin, size_t length) |
---|
[7401] | 226 | */ |
---|
[9550] | 227 | SubString SubString::subSet(size_t begin, size_t length) const |
---|
[2171] | 228 | { |
---|
[9550] | 229 | return SubString(*this, begin, length); |
---|
[2171] | 230 | } |
---|
[836] | 231 | |
---|
[7401] | 232 | /** |
---|
| 233 | @copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char) |
---|
| 234 | @param tokens The array, where the splitted strings will be stored in |
---|
| 235 | @param bTokenInSafemode A vector wich stores for each character of the string if it is in safemode or not |
---|
| 236 | @param start_state The internal state of the parser |
---|
[836] | 237 | |
---|
[7401] | 238 | This is the actual splitting algorithm from Clemens Wacha. |
---|
| 239 | Supports delimiters, escape characters, ignores special characters between safemodeChar and between commentChar and line end "\n". |
---|
| 240 | |
---|
| 241 | Extended by Orxonox to support parenthesis as additional safe-mode. |
---|
| 242 | */ |
---|
[2171] | 243 | SubString::SPLIT_LINE_STATE |
---|
[7401] | 244 | SubString::splitLine(std::vector<std::string>& tokens, |
---|
| 245 | std::vector<bool>& bTokenInSafemode, |
---|
[2171] | 246 | const std::string& line, |
---|
| 247 | const std::string& delimiters, |
---|
| 248 | const std::string& delimiterNeighbours, |
---|
[7401] | 249 | bool bAllowEmptyEntries, |
---|
| 250 | char escapeChar, |
---|
| 251 | bool bRemoveEscapeChar, |
---|
| 252 | char safemodeChar, |
---|
| 253 | bool bRemoveSafemodeChar, |
---|
| 254 | char openparenthesisChar, |
---|
| 255 | char closeparenthesisChar, |
---|
| 256 | bool bRemoveParenthesisChars, |
---|
| 257 | char commentChar, |
---|
[2171] | 258 | SPLIT_LINE_STATE start_state) |
---|
| 259 | { |
---|
| 260 | SPLIT_LINE_STATE state = start_state; |
---|
[9550] | 261 | size_t i = 0; |
---|
| 262 | size_t fallBackNeighbours = 0; |
---|
[836] | 263 | |
---|
[2171] | 264 | std::string token; |
---|
| 265 | bool inSafemode = false; |
---|
[836] | 266 | |
---|
[7401] | 267 | if(start_state != SL_NORMAL && tokens.size() > 0) |
---|
[836] | 268 | { |
---|
[7401] | 269 | token = tokens[tokens.size()-1]; |
---|
| 270 | tokens.pop_back(); |
---|
[836] | 271 | } |
---|
[7401] | 272 | if(start_state != SL_NORMAL && bTokenInSafemode.size() > 0) |
---|
[836] | 273 | { |
---|
[7401] | 274 | inSafemode = bTokenInSafemode[bTokenInSafemode.size()-1]; |
---|
| 275 | bTokenInSafemode.pop_back(); |
---|
[836] | 276 | } |
---|
[2171] | 277 | |
---|
| 278 | while(i < line.size()) |
---|
[1505] | 279 | { |
---|
[2171] | 280 | switch(state) |
---|
[836] | 281 | { |
---|
[2171] | 282 | case SL_NORMAL: |
---|
[7401] | 283 | if(line[i] == escapeChar) |
---|
[2171] | 284 | { |
---|
| 285 | state = SL_ESCAPE; |
---|
[7401] | 286 | if (!bRemoveEscapeChar) |
---|
[2171] | 287 | token += line[i]; |
---|
[7401] | 288 | fallBackNeighbours = 0; |
---|
[2171] | 289 | } |
---|
[7401] | 290 | else if(line[i] == safemodeChar) |
---|
[2171] | 291 | { |
---|
| 292 | state = SL_SAFEMODE; |
---|
| 293 | inSafemode = true; |
---|
[7401] | 294 | if (!bRemoveSafemodeChar) |
---|
[2171] | 295 | token += line[i]; |
---|
[7401] | 296 | fallBackNeighbours = 0; |
---|
[2171] | 297 | } |
---|
[7401] | 298 | else if(line[i] == openparenthesisChar) |
---|
[2171] | 299 | { |
---|
| 300 | state = SL_PARENTHESES; |
---|
| 301 | inSafemode = true; |
---|
[7401] | 302 | if (!bRemoveParenthesisChars) |
---|
[2171] | 303 | token += line[i]; |
---|
[7401] | 304 | fallBackNeighbours = 0; |
---|
[2171] | 305 | } |
---|
[7401] | 306 | else if(line[i] == commentChar) |
---|
[2171] | 307 | { |
---|
| 308 | if (fallBackNeighbours > 0) |
---|
| 309 | token = token.substr(0, token.size() - fallBackNeighbours); |
---|
[7401] | 310 | fallBackNeighbours = 0; |
---|
| 311 | // FINISH |
---|
| 312 | if(bAllowEmptyEntries || token.size() > 0) |
---|
[2171] | 313 | { |
---|
[7401] | 314 | tokens.push_back(token); |
---|
[2171] | 315 | token.clear(); |
---|
[7401] | 316 | bTokenInSafemode.push_back(inSafemode); |
---|
[2171] | 317 | inSafemode = false; |
---|
| 318 | } |
---|
| 319 | token += line[i]; // EAT |
---|
| 320 | state = SL_COMMENT; |
---|
| 321 | } |
---|
| 322 | else if(delimiters.find(line[i]) != std::string::npos) |
---|
| 323 | { |
---|
| 324 | // line[i] is a delimiter |
---|
| 325 | if (fallBackNeighbours > 0) |
---|
| 326 | token = token.substr(0, token.size() - fallBackNeighbours); |
---|
[7401] | 327 | fallBackNeighbours = 0; |
---|
| 328 | // FINISH |
---|
| 329 | if(bAllowEmptyEntries || token.size() > 0) |
---|
[2171] | 330 | { |
---|
[7401] | 331 | tokens.push_back(token); |
---|
[2171] | 332 | token.clear(); |
---|
[7401] | 333 | bTokenInSafemode.push_back(inSafemode); |
---|
[2171] | 334 | inSafemode = false; |
---|
| 335 | } |
---|
| 336 | state = SL_NORMAL; |
---|
| 337 | } |
---|
| 338 | else |
---|
| 339 | { |
---|
| 340 | if (delimiterNeighbours.find(line[i]) != std::string::npos) |
---|
| 341 | { |
---|
| 342 | if (token.size() > 0) |
---|
| 343 | ++fallBackNeighbours; |
---|
| 344 | else |
---|
| 345 | { |
---|
[7401] | 346 | ++i; |
---|
[2171] | 347 | continue; |
---|
| 348 | } |
---|
| 349 | } |
---|
| 350 | else |
---|
| 351 | fallBackNeighbours = 0; |
---|
| 352 | token += line[i]; // EAT |
---|
| 353 | } |
---|
| 354 | break; |
---|
| 355 | case SL_ESCAPE: |
---|
[7401] | 356 | if (!bRemoveSafemodeChar) |
---|
[2171] | 357 | token += line[i]; |
---|
| 358 | else |
---|
| 359 | { |
---|
| 360 | if(line[i] == 'n') token += '\n'; |
---|
| 361 | else if(line[i] == 't') token += '\t'; |
---|
| 362 | else if(line[i] == 'v') token += '\v'; |
---|
| 363 | else if(line[i] == 'b') token += '\b'; |
---|
| 364 | else if(line[i] == 'r') token += '\r'; |
---|
| 365 | else if(line[i] == 'f') token += '\f'; |
---|
| 366 | else if(line[i] == 'a') token += '\a'; |
---|
| 367 | else if(line[i] == '?') token += '\?'; |
---|
| 368 | else token += line[i]; // EAT |
---|
| 369 | } |
---|
| 370 | state = SL_NORMAL; |
---|
| 371 | break; |
---|
| 372 | case SL_SAFEMODE: |
---|
[7401] | 373 | if(line[i] == safemodeChar) |
---|
[2171] | 374 | { |
---|
| 375 | state = SL_NORMAL; |
---|
[7401] | 376 | if (!bRemoveSafemodeChar) |
---|
[2171] | 377 | token += line[i]; |
---|
| 378 | } |
---|
[7401] | 379 | else if(line[i] == escapeChar) |
---|
[2171] | 380 | { |
---|
| 381 | state = SL_SAFEESCAPE; |
---|
| 382 | } |
---|
| 383 | else |
---|
| 384 | { |
---|
| 385 | token += line[i]; // EAT |
---|
| 386 | } |
---|
| 387 | break; |
---|
[1505] | 388 | |
---|
[2171] | 389 | case SL_SAFEESCAPE: |
---|
| 390 | if(line[i] == 'n') token += '\n'; |
---|
| 391 | else if(line[i] == 't') token += '\t'; |
---|
| 392 | else if(line[i] == 'v') token += '\v'; |
---|
| 393 | else if(line[i] == 'b') token += '\b'; |
---|
| 394 | else if(line[i] == 'r') token += '\r'; |
---|
| 395 | else if(line[i] == 'f') token += '\f'; |
---|
| 396 | else if(line[i] == 'a') token += '\a'; |
---|
| 397 | else if(line[i] == '?') token += '\?'; |
---|
| 398 | else token += line[i]; // EAT |
---|
| 399 | state = SL_SAFEMODE; |
---|
| 400 | break; |
---|
[836] | 401 | |
---|
[2171] | 402 | case SL_PARENTHESES: |
---|
[7401] | 403 | if(line[i] == closeparenthesisChar) |
---|
[2171] | 404 | { |
---|
| 405 | state = SL_NORMAL; |
---|
[7401] | 406 | if (!bRemoveParenthesisChars) |
---|
[2171] | 407 | token += line[i]; |
---|
| 408 | } |
---|
[7401] | 409 | else if(line[i] == escapeChar) |
---|
[2171] | 410 | { |
---|
| 411 | state = SL_PARENTHESESESCAPE; |
---|
| 412 | } |
---|
| 413 | else |
---|
| 414 | { |
---|
| 415 | token += line[i]; // EAT |
---|
| 416 | } |
---|
| 417 | break; |
---|
| 418 | |
---|
| 419 | case SL_PARENTHESESESCAPE: |
---|
| 420 | if(line[i] == 'n') token += '\n'; |
---|
| 421 | else if(line[i] == 't') token += '\t'; |
---|
| 422 | else if(line[i] == 'v') token += '\v'; |
---|
| 423 | else if(line[i] == 'b') token += '\b'; |
---|
| 424 | else if(line[i] == 'r') token += '\r'; |
---|
| 425 | else if(line[i] == 'f') token += '\f'; |
---|
| 426 | else if(line[i] == 'a') token += '\a'; |
---|
| 427 | else if(line[i] == '?') token += '\?'; |
---|
| 428 | else token += line[i]; // EAT |
---|
| 429 | state = SL_PARENTHESES; |
---|
| 430 | break; |
---|
| 431 | |
---|
| 432 | case SL_COMMENT: |
---|
| 433 | if(line[i] == '\n') |
---|
| 434 | { |
---|
[7401] | 435 | // FINISH |
---|
[2171] | 436 | if(token.size() > 0) |
---|
| 437 | { |
---|
[7401] | 438 | tokens.push_back(token); |
---|
[2171] | 439 | token.clear(); |
---|
[7401] | 440 | bTokenInSafemode.push_back(inSafemode); |
---|
[2171] | 441 | inSafemode = false; |
---|
| 442 | } |
---|
| 443 | state = SL_NORMAL; |
---|
| 444 | } |
---|
| 445 | else |
---|
| 446 | { |
---|
| 447 | token += line[i]; // EAT |
---|
| 448 | } |
---|
| 449 | break; |
---|
| 450 | |
---|
| 451 | default: |
---|
| 452 | // nothing |
---|
| 453 | break; |
---|
| 454 | } |
---|
[7401] | 455 | ++i; |
---|
[1505] | 456 | } |
---|
| 457 | |
---|
[7401] | 458 | // FINISH |
---|
[2171] | 459 | if (fallBackNeighbours > 0) |
---|
| 460 | token = token.substr(0, token.size() - fallBackNeighbours); |
---|
[7401] | 461 | if(bAllowEmptyEntries || token.size() > 0) |
---|
[836] | 462 | { |
---|
[7401] | 463 | tokens.push_back(token); |
---|
[836] | 464 | token.clear(); |
---|
[7401] | 465 | bTokenInSafemode.push_back(inSafemode); |
---|
[1505] | 466 | inSafemode = false; |
---|
[836] | 467 | } |
---|
[2171] | 468 | return(state); |
---|
[836] | 469 | } |
---|
| 470 | |
---|
[2171] | 471 | /** |
---|
[7401] | 472 | @brief Some nice debug information about this SubString. |
---|
| 473 | */ |
---|
[2171] | 474 | void SubString::debug() const |
---|
| 475 | { |
---|
[8858] | 476 | orxout(debug_output) << "Substring-information::count=" << this->tokens_.size() << " ::"; |
---|
[9550] | 477 | for (size_t i = 0; i < this->tokens_.size(); ++i) |
---|
[8858] | 478 | orxout(debug_output) << "s" << i << "='" << this->tokens_[i].c_str() << "'::"; |
---|
| 479 | orxout(debug_output) << endl; |
---|
[2171] | 480 | } |
---|
[836] | 481 | } |
---|