MCPcopy Create free account
hub / github.com/ceph/ceph / parse_value

Method parse_value

src/common/options.cc:140–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140int Option::parse_value(
141 const std::string& raw_val,
142 value_t *out,
143 std::string *error_message,
144 std::string *normalized_value) const
145{
146 std::string val = raw_val;
147
148 int r = pre_validate(&val, error_message);
149 if (r != 0) {
150 return r;
151 }
152
153 if (type == Option::TYPE_INT) {
154 int64_t f = strict_si_cast<int64_t>(val, error_message);
155 if (!error_message->empty()) {
156 return -EINVAL;
157 }
158 *out = f;
159 } else if (type == Option::TYPE_UINT) {
160 uint64_t f = strict_si_cast<uint64_t>(val, error_message);
161 if (!error_message->empty()) {
162 return -EINVAL;
163 }
164 *out = f;
165 } else if (type == Option::TYPE_STR) {
166 *out = val;
167 } else if (type == Option::TYPE_FLOAT) {
168 double f = strict_strtod(val.c_str(), error_message);
169 if (!error_message->empty()) {
170 return -EINVAL;
171 } else {
172 *out = f;
173 }
174 } else if (type == Option::TYPE_BOOL) {
175 bool b = strict_strtob(val.c_str(), error_message);
176 if (!error_message->empty()) {
177 return -EINVAL;
178 } else {
179 *out = b;
180 }
181 } else if (type == Option::TYPE_ADDR) {
182 entity_addr_t addr;
183 if (!addr.parse(val)){
184 return -EINVAL;
185 }
186 *out = addr;
187 } else if (type == Option::TYPE_ADDRVEC) {
188 entity_addrvec_t addr;
189 if (!addr.parse(val.c_str())){
190 return -EINVAL;
191 }
192 *out = addr;
193 } else if (type == Option::TYPE_UUID) {
194 uuid_d uuid;
195 if (!uuid.parse(val.c_str())) {
196 return -EINVAL;
197 }

Callers 3

_set_valMethod · 0.45
update_from_paxosMethod · 0.45
prepare_commandMethod · 0.45

Calls 10

strict_strtodFunction · 0.85
strict_strtobFunction · 0.85
strict_iecstrtollFunction · 0.85
parse_timespanFunction · 0.85
to_strFunction · 0.85
validateFunction · 0.50
emptyMethod · 0.45
c_strMethod · 0.45
parseMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected