Add OptionParser::parse_integer helper function.
GitOrigin-RevId: d202848b64c27bb260e189783722508684b633c5
This commit is contained in:
parent
b8e0201694
commit
91942f29d3
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/misc.h"
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
#include "td/utils/StringBuilder.h"
|
#include "td/utils/StringBuilder.h"
|
||||||
|
@ -30,6 +31,14 @@ class OptionParser {
|
||||||
std::function<Status(Slice)> callback);
|
std::function<Status(Slice)> callback);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
template <class T>
|
||||||
|
static std::function<Status(Slice)> parse_integer(T &value) {
|
||||||
|
return [&value](Slice value_str) {
|
||||||
|
TRY_RESULT_ASSIGN(value, to_integer_safe<T>(value_str));
|
||||||
|
return Status::OK();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void set_description(string description);
|
void set_description(string description);
|
||||||
|
|
||||||
void add_checked_option(char short_key, Slice long_key, Slice description, std::function<Status(Slice)> callback);
|
void add_checked_option(char short_key, Slice long_key, Slice description, std::function<Status(Slice)> callback);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user