Print a warning in case a fallback value wasn't found

0.6.3
Capostrophic 7 years ago committed by Capostrophic
parent e4531a6910
commit 002ad9ae1b

@ -1,5 +1,7 @@
#include "fallback.hpp" #include "fallback.hpp"
#include <iostream>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
@ -17,6 +19,7 @@ namespace Fallback
std::map<std::string,std::string>::const_iterator it; std::map<std::string,std::string>::const_iterator it;
if((it = mFallbackMap.find(fall)) == mFallbackMap.end()) if((it = mFallbackMap.find(fall)) == mFallbackMap.end())
{ {
std::cerr << "Warning: fallback value " << fall << " not found." << std::endl;
return ""; return "";
} }
return it->second; return it->second;
@ -25,7 +28,7 @@ namespace Fallback
float Map::getFallbackFloat(const std::string& fall) const float Map::getFallbackFloat(const std::string& fall) const
{ {
std::string fallback=getFallbackString(fall); std::string fallback=getFallbackString(fall);
if(fallback.empty()) if (fallback.empty())
return 0; return 0;
else else
return boost::lexical_cast<float>(fallback); return boost::lexical_cast<float>(fallback);
@ -34,7 +37,7 @@ namespace Fallback
int Map::getFallbackInt(const std::string& fall) const int Map::getFallbackInt(const std::string& fall) const
{ {
std::string fallback=getFallbackString(fall); std::string fallback=getFallbackString(fall);
if(fallback.empty()) if (fallback.empty())
return 0; return 0;
else else
return std::stoi(fallback); return std::stoi(fallback);
@ -43,7 +46,7 @@ namespace Fallback
bool Map::getFallbackBool(const std::string& fall) const bool Map::getFallbackBool(const std::string& fall) const
{ {
std::string fallback=getFallbackString(fall); std::string fallback=getFallbackString(fall);
if(fallback.empty()) if (fallback.empty())
return false; return false;
else else
return stob(fallback); return stob(fallback);
@ -52,7 +55,7 @@ namespace Fallback
osg::Vec4f Map::getFallbackColour(const std::string& fall) const osg::Vec4f Map::getFallbackColour(const std::string& fall) const
{ {
std::string sum=getFallbackString(fall); std::string sum=getFallbackString(fall);
if(sum.empty()) if (sum.empty())
return osg::Vec4f(0.5f,0.5f,0.5f,1.f); return osg::Vec4f(0.5f,0.5f,0.5f,1.f);
else else
{ {

Loading…
Cancel
Save