|
|
@ -6,29 +6,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace Fallback
|
|
|
|
namespace Fallback
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::map<std::string,std::string> Map::mFallbackMap;
|
|
|
|
std::map<std::string, std::string, std::less<>> Map::mFallbackMap;
|
|
|
|
|
|
|
|
|
|
|
|
void Map::init(const std::map<std::string,std::string>& fallback)
|
|
|
|
void Map::init(const std::map<std::string,std::string>& fallback)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mFallbackMap = fallback;
|
|
|
|
for(const auto& entry : fallback)
|
|
|
|
|
|
|
|
mFallbackMap.insert(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string Map::getString(const std::string& fall)
|
|
|
|
std::string_view Map::getString(std::string_view fall)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::map<std::string,std::string>::const_iterator it;
|
|
|
|
auto it = mFallbackMap.find(fall);
|
|
|
|
if ((it = mFallbackMap.find(fall)) == mFallbackMap.end())
|
|
|
|
if (it == mFallbackMap.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return it->second;
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float Map::getFloat(const std::string& fall)
|
|
|
|
float Map::getFloat(std::string_view fall)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const std::string& fallback = getString(fall);
|
|
|
|
std::string_view fallback = getString(fall);
|
|
|
|
if (!fallback.empty())
|
|
|
|
if (!fallback.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::stringstream stream(fallback);
|
|
|
|
std::stringstream stream;
|
|
|
|
|
|
|
|
stream << fallback;
|
|
|
|
float number = 0.f;
|
|
|
|
float number = 0.f;
|
|
|
|
stream >> number;
|
|
|
|
stream >> number;
|
|
|
|
return number;
|
|
|
|
return number;
|
|
|
@ -37,12 +39,13 @@ namespace Fallback
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Map::getInt(const std::string& fall)
|
|
|
|
int Map::getInt(std::string_view fall)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const std::string& fallback = getString(fall);
|
|
|
|
std::string_view fallback = getString(fall);
|
|
|
|
if (!fallback.empty())
|
|
|
|
if (!fallback.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::stringstream stream(fallback);
|
|
|
|
std::stringstream stream;
|
|
|
|
|
|
|
|
stream << fallback;
|
|
|
|
int number = 0;
|
|
|
|
int number = 0;
|
|
|
|
stream >> number;
|
|
|
|
stream >> number;
|
|
|
|
return number;
|
|
|
|
return number;
|
|
|
@ -51,15 +54,15 @@ namespace Fallback
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Map::getBool(const std::string& fall)
|
|
|
|
bool Map::getBool(std::string_view fall)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const std::string& fallback = getString(fall);
|
|
|
|
std::string_view fallback = getString(fall);
|
|
|
|
return !fallback.empty() && fallback != "0";
|
|
|
|
return !fallback.empty() && fallback != "0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
osg::Vec4f Map::getColour(const std::string& fall)
|
|
|
|
osg::Vec4f Map::getColour(std::string_view fall)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const std::string& sum = getString(fall);
|
|
|
|
std::string_view sum = getString(fall);
|
|
|
|
if (!sum.empty())
|
|
|
|
if (!sum.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|