24 int64_t relative_reference) {
25 if (mem_spec_str.empty())
return 0;
28 int64_t multiplier = -1;
29 int32_t number_str_len = mem_spec_str.size();
32 string::const_reverse_iterator suffix_char = mem_spec_str.rbegin();
33 if (*suffix_char ==
'b' || *suffix_char ==
'B') {
35 if (suffix_char == mem_spec_str.rend())
return -1;
39 switch (*suffix_char) {
44 multiplier = 1024L * 1024L * 1024L;
50 multiplier = 1024L * 1024L;
54 if (suffix_char != mem_spec_str.rbegin())
return -1;
63 if (multiplier != -1) {
65 double limit_val = StringParser::StringToFloat<double>(mem_spec_str.data(),
66 number_str_len, &result);
68 bytes = multiplier * limit_val;
71 int64_t limit_val = StringParser::StringToInt<int64_t>(mem_spec_str.data(),
72 number_str_len, &result);
76 bytes = (
static_cast<double>(limit_val) / 100.0) * relative_reference;
static int64_t ParseMemSpec(const std::string &mem_spec_str, bool *is_percent, int64_t relative_reference)