mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 06:46:53 +08:00
Moved helper functions out of class
This commit is contained in:
@@ -24,6 +24,13 @@ using namespace std;
|
|||||||
namespace alpr
|
namespace alpr
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
int getInt(CSimpleIniA* ini, std::string section, std::string key, int defaultValue);
|
||||||
|
float getFloat(CSimpleIniA* ini, std::string section, std::string key, float defaultValue);
|
||||||
|
std::string getString(CSimpleIniA* ini, std::string section, std::string key, std::string defaultValue);
|
||||||
|
bool getBoolean(CSimpleIniA* ini, std::string section, std::string key, bool defaultValue);
|
||||||
|
|
||||||
|
|
||||||
Config::Config(const std::string country, const std::string config_file, const std::string runtime_dir)
|
Config::Config(const std::string country, const std::string config_file, const std::string runtime_dir)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -277,52 +284,44 @@ namespace alpr
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
float Config::getFloat(CSimpleIniA* ini, string section, string key, float defaultValue)
|
float getFloat(CSimpleIniA* ini, string section, string key, float defaultValue)
|
||||||
{
|
{
|
||||||
const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/);
|
const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/);
|
||||||
if (pszValue == NULL)
|
if (pszValue == NULL)
|
||||||
{
|
{
|
||||||
if (this->debugGeneral)
|
|
||||||
std::cout << "Warning: missing configuration entry for: " << section << "->" << key << endl;
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
float val = atof(pszValue);
|
float val = atof(pszValue);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
int Config::getInt(CSimpleIniA* ini, string section, string key, int defaultValue)
|
int getInt(CSimpleIniA* ini, string section, string key, int defaultValue)
|
||||||
{
|
{
|
||||||
const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/);
|
const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/);
|
||||||
if (pszValue == NULL)
|
if (pszValue == NULL)
|
||||||
{
|
{
|
||||||
if (this->debugGeneral)
|
|
||||||
std::cout << "Warning: missing configuration entry for: " << section << "->" << key << endl;
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int val = atoi(pszValue);
|
int val = atoi(pszValue);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
bool Config::getBoolean(CSimpleIniA* ini, string section, string key, bool defaultValue)
|
bool getBoolean(CSimpleIniA* ini, string section, string key, bool defaultValue)
|
||||||
{
|
{
|
||||||
const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/);
|
const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/);
|
||||||
if (pszValue == NULL)
|
if (pszValue == NULL)
|
||||||
{
|
{
|
||||||
if (this->debugGeneral)
|
|
||||||
std::cout << "Warning: missing configuration entry for: " << section << "->" << key << endl;
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int val = atoi(pszValue);
|
int val = atoi(pszValue);
|
||||||
return val != 0;
|
return val != 0;
|
||||||
}
|
}
|
||||||
string Config::getString(CSimpleIniA* ini, string section, string key, string defaultValue)
|
string getString(CSimpleIniA* ini, string section, string key, string defaultValue)
|
||||||
{
|
{
|
||||||
const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/);
|
const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/);
|
||||||
if (pszValue == NULL)
|
if (pszValue == NULL)
|
||||||
{
|
{
|
||||||
if (this->debugGeneral)
|
|
||||||
std::cout << "Warning: missing configuration entry for: " << section << "->" << key << endl;
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -136,10 +136,6 @@ namespace alpr
|
|||||||
void loadCommonValues(std::string configFile);
|
void loadCommonValues(std::string configFile);
|
||||||
void loadCountryValues(std::string configFile, std::string country);
|
void loadCountryValues(std::string configFile, std::string country);
|
||||||
|
|
||||||
int getInt(CSimpleIniA* ini, std::string section, std::string key, int defaultValue);
|
|
||||||
float getFloat(CSimpleIniA* ini, std::string section, std::string key, float defaultValue);
|
|
||||||
std::string getString(CSimpleIniA* ini, std::string section, std::string key, std::string defaultValue);
|
|
||||||
bool getBoolean(CSimpleIniA* ini, std::string section, std::string key, bool defaultValue);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user