Some strings will be parameterized to allow for some variety depending on the situation.
For example, the string {TEMPERATURE} C degrees today, it will be a {TEMPERATURE_QUALIFIER} {SEASON}! is a parameterized string which takes three parameters: [TEMPERATURE, TEMPERATURE_QUALIFIER, SEASON]
You must write an algorithm std::string formatString(const std::string &, Parameters &&) that given a string and a map-like object, will generate a proper string.
For example, formatString("{CITY_NAME} will rise!", std::map{{"CITY_NAME", "Cytopia"}}) == "Cytopia will rise!"
A map-like object is any object which has a ::at(std::string) -> std::string member. This could include std::map, std::unordered_map, and custom object types
If a parameter in the string has no mapping in Parameters, then formatString should log a warning and continue. So for example, formatString("{CITY_NAME} will rise!", std::map{ }) == "{CITY_NAME} will rise!" but a warning will be issued that CITY_NAME was not provided as a parameter
Requirements
{TEMPERATURE} C degrees today, it will be a {TEMPERATURE_QUALIFIER} {SEASON}!
is a parameterized string which takes three parameters:[TEMPERATURE, TEMPERATURE_QUALIFIER, SEASON]
std::string formatString(const std::string &, Parameters &&)
that given a string and a map-like object, will generate a proper string.formatString("{CITY_NAME} will rise!", std::map{{"CITY_NAME", "Cytopia"}}) == "Cytopia will rise!"
::at(std::string) -> std::string
member. This could includestd::map
,std::unordered_map
, and custom object typesParameters
, thenformatString
should log a warning and continue. So for example,formatString("{CITY_NAME} will rise!", std::map{ }) == "{CITY_NAME} will rise!"
but a warning will be issued thatCITY_NAME
was not provided as a parameter