Changed the signature of findDefine()
This commit is contained in:
parent
2fd68e00b6
commit
3c9f84adb3
2 changed files with 10 additions and 8 deletions
|
|
@ -117,7 +117,7 @@ bool sfz::Parser::loadSfzFile(const fs::path& file)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sfz::Parser::findDefine(absl::string_view line)
|
bool findDefine(absl::string_view line, absl::string_view& variable, absl::string_view& value)
|
||||||
{
|
{
|
||||||
const auto defPosition = line.find("#define");
|
const auto defPosition = line.find("#define");
|
||||||
if (defPosition == absl::string_view::npos)
|
if (defPosition == absl::string_view::npos)
|
||||||
|
|
@ -136,12 +136,10 @@ bool sfz::Parser::findDefine(absl::string_view line)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto valueEnd = line.find_first_of(" \r\t\n\f\v", valueStart);
|
const auto valueEnd = line.find_first_of(" \r\t\n\f\v", valueStart);
|
||||||
const auto variable = line.substr(variableStart, variableEnd - variableStart);
|
variable = line.substr(variableStart, variableEnd - variableStart);
|
||||||
const auto value = valueEnd != absl::string_view::npos
|
value = valueEnd != absl::string_view::npos
|
||||||
? line.substr(valueStart, valueEnd - valueStart)
|
? line.substr(valueStart, valueEnd - valueStart)
|
||||||
: line.substr(valueStart);
|
: line.substr(valueStart);
|
||||||
|
|
||||||
defines[std::string(variable)] = std::string(value);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,6 +168,9 @@ void sfz::Parser::readSfzFile(const fs::path& fileName, std::vector<std::string>
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string tmpString;
|
std::string tmpString;
|
||||||
|
std::string includePath;
|
||||||
|
absl::string_view variable;
|
||||||
|
absl::string_view value;
|
||||||
while (std::getline(fileStream, tmpString)) {
|
while (std::getline(fileStream, tmpString)) {
|
||||||
absl::string_view tmpView { tmpString };
|
absl::string_view tmpView { tmpString };
|
||||||
|
|
||||||
|
|
@ -179,7 +180,6 @@ void sfz::Parser::readSfzFile(const fs::path& fileName, std::vector<std::string>
|
||||||
if (tmpView.empty())
|
if (tmpView.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string includePath;
|
|
||||||
// New #include
|
// New #include
|
||||||
if (findInclude(tmpView, includePath)) {
|
if (findInclude(tmpView, includePath)) {
|
||||||
std::replace(includePath.begin(), includePath.end(), '\\', '/');
|
std::replace(includePath.begin(), includePath.end(), '\\', '/');
|
||||||
|
|
@ -197,8 +197,11 @@ void sfz::Parser::readSfzFile(const fs::path& fileName, std::vector<std::string>
|
||||||
}
|
}
|
||||||
|
|
||||||
// New #define
|
// New #define
|
||||||
if (findDefine(tmpView))
|
if (findDefine(tmpView, variable, value)) {
|
||||||
|
|
||||||
|
defines[std::string(variable)] = std::string(value);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Replace defined variables starting with $
|
// Replace defined variables starting with $
|
||||||
std::string newString;
|
std::string newString;
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,6 @@ private:
|
||||||
std::vector<fs::path> includedFiles;
|
std::vector<fs::path> includedFiles;
|
||||||
std::string aggregatedContent {};
|
std::string aggregatedContent {};
|
||||||
void readSfzFile(const fs::path& fileName, std::vector<std::string>& lines) noexcept;
|
void readSfzFile(const fs::path& fileName, std::vector<std::string>& lines) noexcept;
|
||||||
bool findDefine(absl::string_view line);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sfz
|
} // namespace sfz
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue