mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:40:05 +00:00
Add mapbox_api_key to settings
This commit is contained in:
parent
ba64627f5d
commit
a96e017917
7 changed files with 47 additions and 11 deletions
|
|
@ -92,7 +92,8 @@ bool FromJsonInt64(const boost::json::object& json,
|
|||
bool FromJsonString(const boost::json::object& json,
|
||||
const std::string& key,
|
||||
std::string& value,
|
||||
const std::string& defaultValue)
|
||||
const std::string& defaultValue,
|
||||
size_t minLength)
|
||||
{
|
||||
const boost::json::value* jv = json.if_contains(key);
|
||||
bool dirty = true;
|
||||
|
|
@ -102,7 +103,20 @@ bool FromJsonString(const boost::json::object& json,
|
|||
if (jv->is_string())
|
||||
{
|
||||
value = boost::json::value_to<std::string>(*jv);
|
||||
dirty = false;
|
||||
|
||||
if (value.length() >= minLength)
|
||||
{
|
||||
dirty = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger_->warn(
|
||||
"{} is shorter than {} characters, setting to default: {}",
|
||||
key,
|
||||
minLength,
|
||||
defaultValue);
|
||||
value = defaultValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ bool FromJsonInt64(const boost::json::object& json,
|
|||
bool FromJsonString(const boost::json::object& json,
|
||||
const std::string& key,
|
||||
std::string& value,
|
||||
const std::string& defaultValue);
|
||||
const std::string& defaultValue,
|
||||
size_t minLength = 0);
|
||||
|
||||
boost::json::value ReadJsonFile(const std::string& path);
|
||||
void WriteJsonFile(const std::string& path,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue