Skip to content

Commit

Permalink
Add in text_database interpolation handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
MunWolf committed Nov 18, 2023
1 parent 0129cd4 commit 1308d3b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions projects/Randomizer/text_processors/legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,21 @@ namespace randomizer::text_processors {

return text;
}

std::optional<std::string> text_database(std::string_view content) {
int id = 0;
if (std::from_chars(content.data(), content.data() + content.size(), id).ec != std::errc()) {
return std::nullopt;
}

return core::text::get_concatenated_text(id, "\n");
}
} // namespace

void LegacyProcessor::process(std::string& text) const {
search_and_replace("$(", value, text, "(", ")"); // Interpolate seed.text(location)
search_and_replace("$[(", seed_text, text, "[(", ")]"); // Interpolate seed.text(location)
search_and_replace("$[", action, text, "[", "]"); // Interpolate seed action.
search_and_replace("${", text_database, text, "{", "}"); // Interpolate seed action.
}
} // namespace randomizer::text_processors

0 comments on commit 1308d3b

Please sign in to comment.