return json_object_new_int(val);
}
+template<> json_object* ConfigurationBase::getJsonObjFromValue(const std::int64_t& val)
+{
+ return json_object_new_int64(val);
+}
+
template<> json_object* ConfigurationBase::getJsonObjFromValue(const bool& val)
{
return json_object_new_boolean(val);
return json_object_get_int(obj);
}
+template<> std::int64_t ConfigurationBase::getValueFromJsonObj(json_object* obj)
+{
+ return json_object_get_int64(obj);
+}
+
template<> bool ConfigurationBase::getValueFromJsonObj(json_object* obj)
{
return json_object_get_boolean(obj);
throw ConfigException();
}
int len = json_object_array_length(array);
- val.resize(len);
+ val.resize(static_cast<size_t>(len));
for (int i = 0; i < len; ++i) {
- val[i] = getValueFromJsonObj<T>(json_object_array_get_idx(array, i));
+ val[static_cast<size_t>(i)] = getValueFromJsonObj<T>(json_object_array_get_idx(array, i));
}
}
}
int len = json_object_array_length(obj);
- val.resize(len);
+ val.resize(static_cast<size_t>(len));
for (int i = 0; i < len; ++i) {
json_object* arrayObj = json_object_array_get_idx(obj, i);
- val[i].process(arrayObj, ConfigProcessMode::Read);
+ val[static_cast<size_t>(i)].process(arrayObj, ConfigProcessMode::Read);
}
}
/**
* Container's CFS quota in us when it's in the foreground
*/
- double cpuQuotaForeground;
+ std::int64_t cpuQuotaForeground;
/**
* Container's CFS quota in us when it's in the background
*/
- double cpuQuotaBackground;
+ std::int64_t cpuQuotaBackground;
/**
* Path to containers dbus unix socket
};
int intVal;
+ std::int64_t int64Val;
std::string stringVal;
double floatVal;
bool boolVal;
CONFIG_REGISTER {
CONFIG_VALUE(intVal)
+ CONFIG_VALUE(int64Val)
CONFIG_VALUE(stringVal)
CONFIG_VALUE(floatVal)
CONFIG_VALUE(boolVal)
bool operator== (const TestConfig& rhs) const
{
return (rhs.intVal == intVal &&
+ rhs.int64Val == int64Val &&
rhs.stringVal == stringVal &&
rhs.floatVal == floatVal &&
rhs.boolVal == boolVal &&
*/
const std::string json_test_string =
"{ \"intVal\": 12345, "
+ "\"int64Val\": -1234567890123456789, "
"\"stringVal\": \"blah\", "
"\"floatVal\": -1.234, "
"\"boolVal\": true, "
BOOST_REQUIRE_NO_THROW(testConfig.parseStr(json_test_string));
BOOST_CHECK_EQUAL(12345, testConfig.intVal);
+ BOOST_CHECK_EQUAL(-1234567890123456789ll, testConfig.int64Val);
BOOST_CHECK_CLOSE(-1.234, testConfig.floatVal, max_float_error);
BOOST_CHECK_EQUAL("blah", testConfig.stringVal);
BOOST_CHECK_EQUAL(true, testConfig.boolVal);