NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
| 365 | |
| 366 | // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) |
| 367 | void TokenList::createTokens(simplecpp::TokenList&& tokenList) |
| 368 | { |
| 369 | // TODO: what to do if the list has been filled already? clear mTokensFrontBack? |
| 370 | |
| 371 | // tokenList.cfront() might be NULL if the file contained nothing to tokenize so we need to check the files instead |
| 372 | if (!tokenList.getFiles().empty()) { |
| 373 | // this is a copy |
| 374 | // TODO: this points to mFiles when called from createTokens(std::istream &, const std::string&) |
| 375 | mOrigFiles = mFiles = tokenList.getFiles(); |
| 376 | } |
| 377 | else { |
| 378 | // TODO: clear mOrigFiles? |
| 379 | mFiles.clear(); |
| 380 | } |
| 381 | |
| 382 | for (const simplecpp::Token *tok = tokenList.cfront(); tok;) { |
| 383 | |
| 384 | // TODO: move from TokenList |
| 385 | std::string str = tok->str(); |
| 386 | |
| 387 | // Float literal |
| 388 | if (str.size() > 1 && str[0] == '.' && std::isdigit(str[1])) |
| 389 | str = '0' + str; |
| 390 | |
| 391 | if (mTokensFrontBack->back) { |
| 392 | mTokensFrontBack->back->insertToken(str); |
| 393 | } else { |
| 394 | mTokensFrontBack->front = new Token(*this, mTokensFrontBack); |
| 395 | mTokensFrontBack->back = mTokensFrontBack->front; |
| 396 | mTokensFrontBack->back->str(str); |
| 397 | } |
| 398 | |
| 399 | mTokensFrontBack->back->fileIndex(tok->location.fileIndex); |
| 400 | mTokensFrontBack->back->linenr(tok->location.line); |
| 401 | mTokensFrontBack->back->column(tok->location.col); |
| 402 | if (!tok->macro.empty()) |
| 403 | mTokensFrontBack->back->setMacroName(tok->macro); |
| 404 | |
| 405 | tok = tok->next; |
| 406 | if (tok) |
| 407 | tokenList.deleteToken(tok->previous); |
| 408 | } |
| 409 | |
| 410 | if (mSettings.relativePaths) { |
| 411 | for (std::string & mFile : mFiles) |
| 412 | mFile = Path::getRelativePath(mFile, mSettings.basePaths); |
| 413 | } |
| 414 | |
| 415 | Token::assignProgressValues(mTokensFrontBack->front); |
| 416 | } |
| 417 | |
| 418 | //--------------------------------------------------------------------------- |
| 419 |