Porytiles
Loading...
Searching...
No Matches
text_formatter.cpp
Go to the documentation of this file.
2
3#include <string>
4#include <vector>
5
6#include "fmt/args.h"
7#include "fmt/format.h"
8
9namespace porytiles2 {
10
11std::string TextFormatter::format(const std::string &format_str, const std::vector<FormatParam> &params) const
12{
13 fmt::dynamic_format_arg_store<fmt::format_context> store;
14 for (const auto &param : params) {
15 store.push_back(style(param.text(), param.styles()));
16 }
17 return fmt::vformat(format_str, store);
18}
19
20} // namespace porytiles2
virtual std::string style(const std::string &text, Style styles) const =0
Applies styling to a text string.
virtual std::string format(const std::string &format_str, const std::vector< FormatParam > &params) const
Formats a string with styled parameters using fmtlib syntax.