date and boolean data types added
This commit is contained in:
30
settings.cpp
Normal file
30
settings.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include "ml_date.h"
|
||||
|
||||
namespace usql {
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> Settings::m_settings =
|
||||
{ std::make_pair("DATE_FORMAT", "%Y-%m-%d"),
|
||||
std::make_pair("BOOL_TRUE_LITERAL", "Y"),
|
||||
std::make_pair("BOOL_FALSE_LITERAL", "N") };
|
||||
|
||||
|
||||
long Settings::string_to_date(const std::string &datestr) {
|
||||
return ::string_to_date(datestr, get_setting("DATE_FORMAT"));
|
||||
}
|
||||
|
||||
|
||||
std::string Settings::date_to_string(long date) {
|
||||
return ::date_to_string(date, get_setting("DATE_FORMAT"));
|
||||
}
|
||||
|
||||
std::basic_string<char> Settings::get_setting(const std::string &name) {
|
||||
for(const auto& pair : m_settings) {
|
||||
if (pair.first == name) return pair.second;
|
||||
}
|
||||
// TODO exception
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user