}
*out = uuid;
} else if (type == Option::TYPE_SIZE) {
- Option::size_t sz{strict_iecstrtoll(val.c_str(), error_message)};
+ Option::size_t sz{strict_iecstrtoll(val, error_message)};
if (!error_message->empty()) {
return -EINVAL;
}
return strict_iec_cast<uint64_t>(str, err);
}
-uint64_t strict_iecstrtoll(const char *str, std::string *err)
-{
- return strict_iec_cast<uint64_t>(str, err);
-}
-
template<typename T>
T strict_si_cast(std::string_view str, std::string *err)
{
float strict_strtof(std::string_view str, std::string *err);
-uint64_t strict_iecstrtoll(const char *str, std::string *err);
+uint64_t strict_iecstrtoll(std::string_view str, std::string *err);
template<typename T>
T strict_iec_cast(std::string_view str, std::string *err);
{
if (key == "compaction_threads") {
std::string err;
- int f = strict_iecstrtoll(val.c_str(), &err);
+ int f = strict_iecstrtoll(val, &err);
if (!err.empty())
return -EINVAL;
//Low priority threadpool is used for compaction
opt.env->SetBackgroundThreads(f, rocksdb::Env::Priority::LOW);
} else if (key == "flusher_threads") {
std::string err;
- int f = strict_iecstrtoll(val.c_str(), &err);
+ int f = strict_iecstrtoll(val, &err);
if (!err.empty())
return -EINVAL;
//High priority threadpool is used for flusher
size_t cache_size = cct->_conf->rocksdb_cache_size;
if (auto it = cache_options_map.find("size"); it !=cache_options_map.end()) {
std::string error;
- cache_size = strict_iecstrtoll(it->second.c_str(), &error);
+ cache_size = strict_iecstrtoll(it->second, &error);
if (!error.empty()) {
derr << __func__ << " invalid size: '" << it->second << "'" << dendl;
}
auto it = profile.find("stripe_unit");
if (it != profile.end()) {
string err_str;
- uint32_t stripe_unit = strict_iecstrtoll(it->second.c_str(), &err_str);
+ uint32_t stripe_unit = strict_iecstrtoll(it->second, &err_str);
if (!err_str.empty()) {
*ss << "could not parse stripe_unit '" << it->second
<< "': " << err_str << std::endl;
auto it = profile.find("stripe_unit");
if (it != profile.end()) {
string err_str;
- stripe_unit = strict_iecstrtoll(it->second.c_str(), &err_str);
+ stripe_unit = strict_iecstrtoll(it->second, &err_str);
ceph_assert(err_str.empty());
}
*stripe_width = data_chunks *
if (field == "max_objects") {
value = strict_si_cast<uint64_t>(val, &tss);
} else if (field == "max_bytes") {
- value = strict_iecstrtoll(val.c_str(), &tss);
+ value = strict_iecstrtoll(val, &tss);
} else {
ceph_abort_msg("unrecognized option");
}
string val;
int r = cfg_reader(keys[i], &val);
if (r == 0) {
- *(vals[i]) = strict_iecstrtoll(val.c_str(), &err);
+ *(vals[i]) = strict_iecstrtoll(val, &err);
if (!err.empty()) {
derr << __func__ << " Failed to parse - "
<< keys[i] << ":" << val
bool byte_units::parse(const std::string &val, std::string *err)
{
- v = strict_iecstrtoll(val.c_str(), err);
+ v = strict_iecstrtoll(val, err);
return err->empty();
}
template <typename I, typename T>
static int rados_sistrtoll(I &i, T *val) {
std::string err;
- *val = strict_iecstrtoll(i->second.c_str(), &err);
+ *val = strict_iecstrtoll(i->second, &err);
if (err != "") {
cerr << "Invalid value for " << i->first << ": " << err << std::endl;
return -EINVAL;
const std::string &s = po::validators::get_single_string(values);
std::string parse_error;
- uint64_t size = strict_iecstrtoll(s.c_str(), &parse_error);
+ uint64_t size = strict_iecstrtoll(s, &parse_error);
if (!parse_error.empty()) {
throw po::validation_error(po::validation_error::invalid_option_value);
}
const std::string &s = po::validators::get_single_string(values);
std::string parse_error;
- uint64_t objectsize = strict_iecstrtoll(s.c_str(), &parse_error);
+ uint64_t objectsize = strict_iecstrtoll(s, &parse_error);
if (!parse_error.empty()) {
throw po::validation_error(po::validation_error::invalid_option_value);
}
const std::string &s = po::validators::get_single_string(values);
std::string parse_error;
- uint64_t size = strict_iecstrtoll(s.c_str(), &parse_error);
+ uint64_t size = strict_iecstrtoll(s, &parse_error);
if (parse_error.empty() && (size >= (1 << 12)) && (size <= (1 << 26))) {
v = boost::any(size);
return;
const std::string &s = po::validators::get_single_string(values);
std::string parse_error;
- uint64_t format = strict_iecstrtoll(s.c_str(), &parse_error);
+ uint64_t format = strict_iecstrtoll(s, &parse_error);
if (!parse_error.empty() || (format != 1 && format != 2)) {
throw po::validation_error(po::validation_error::invalid_option_value);
}
const std::string &s = po::validators::get_single_string(values);
std::string parse_error;
- uint64_t size = strict_iecstrtoll(s.c_str(), &parse_error);
+ uint64_t size = strict_iecstrtoll(s, &parse_error);
if (!parse_error.empty()) {
throw po::validation_error(po::validation_error::invalid_option_value);
}