diff options
Diffstat (limited to 'Source/cmVisualStudioSlnParser.cxx')
-rw-r--r-- | Source/cmVisualStudioSlnParser.cxx | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 1a32abacf..4533e9b69 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -2,13 +2,15 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmVisualStudioSlnParser.h" -#include "cmSystemTools.h" -#include "cmVisualStudioSlnData.h" -#include "cmsys/FStream.hxx" - #include <cassert> #include <stack> +#include "cmsys/FStream.hxx" + +#include "cmStringAlgorithms.h" +#include "cmSystemTools.h" +#include "cmVisualStudioSlnData.h" + namespace { enum LineFormat { @@ -50,7 +52,7 @@ public: void CopyVerbatim(const std::string& line) { this->Tag = line; } private: - typedef std::pair<std::string, bool> StringData; + using StringData = std::pair<std::string, bool>; std::string Tag; StringData Arg; std::vector<StringData> Values; @@ -192,8 +194,8 @@ bool cmVisualStudioSlnParser::State::Process( assert(!line.IsComment()); switch (this->Stack.top()) { case FileStateStart: - if (!cmSystemTools::StringStartsWith( - line.GetTag().c_str(), "Microsoft Visual Studio Solution File")) { + if (!cmHasLiteralPrefix(line.GetTag(), + "Microsoft Visual Studio Solution File")) { result.SetError(ResultErrorInputStructure, this->GetCurrentLine()); return false; } @@ -329,7 +331,7 @@ bool cmVisualStudioSlnParser::State::Process( case FileStateIgnore: if (line.GetTag() == this->EndIgnoreTag) { this->Stack.pop(); - this->EndIgnoreTag = ""; + this->EndIgnoreTag.clear(); } break; default: @@ -462,7 +464,7 @@ bool cmVisualStudioSlnParser::ParseImpl(std::istream& input, cmSlnData& output, if (!this->ParseBOM(input, line, state)) return false; do { - line = cmSystemTools::TrimWhitespace(line); + line = cmTrimWhitespace(line); if (line.empty()) continue; ParsedLine parsedLine; @@ -578,9 +580,9 @@ bool cmVisualStudioSlnParser::ParseKeyValuePair(const std::string& line, return true; } const std::string& key = line.substr(0, idxEqualSign); - parsedLine.SetTag(cmSystemTools::TrimWhitespace(key)); + parsedLine.SetTag(cmTrimWhitespace(key)); const std::string& value = line.substr(idxEqualSign + 1); - parsedLine.AddValue(cmSystemTools::TrimWhitespace(value)); + parsedLine.AddValue(cmTrimWhitespace(value)); return true; } @@ -589,21 +591,20 @@ bool cmVisualStudioSlnParser::ParseTag(const std::string& fullTag, { size_t idxLeftParen = fullTag.find('('); if (idxLeftParen == fullTag.npos) { - parsedLine.SetTag(cmSystemTools::TrimWhitespace(fullTag)); + parsedLine.SetTag(cmTrimWhitespace(fullTag)); return true; } - parsedLine.SetTag( - cmSystemTools::TrimWhitespace(fullTag.substr(0, idxLeftParen))); + parsedLine.SetTag(cmTrimWhitespace(fullTag.substr(0, idxLeftParen))); size_t idxRightParen = fullTag.rfind(')'); if (idxRightParen == fullTag.npos) { this->LastResult.SetError(ResultErrorInputStructure, state.GetCurrentLine()); return false; } - const std::string& arg = cmSystemTools::TrimWhitespace( + const std::string& arg = cmTrimWhitespace( fullTag.substr(idxLeftParen + 1, idxRightParen - idxLeftParen - 1)); - if (arg[0] == '"') { - if (arg[arg.size() - 1] != '"') { + if (arg.front() == '"') { + if (arg.back() != '"') { this->LastResult.SetError(ResultErrorInputStructure, state.GetCurrentLine()); return false; @@ -617,10 +618,10 @@ bool cmVisualStudioSlnParser::ParseTag(const std::string& fullTag, bool cmVisualStudioSlnParser::ParseValue(const std::string& value, ParsedLine& parsedLine) { - const std::string& trimmed = cmSystemTools::TrimWhitespace(value); + const std::string& trimmed = cmTrimWhitespace(value); if (trimmed.empty()) parsedLine.AddValue(trimmed); - else if (trimmed[0] == '"' && trimmed[trimmed.size() - 1] == '"') + else if (trimmed.front() == '"' && trimmed.back() == '"') parsedLine.AddQuotedValue(trimmed.substr(1, trimmed.size() - 2)); else parsedLine.AddValue(trimmed); |