Merge the latest cpp template from flutter-embedded-linux repo (#131)
Signed-off-by: Hidenori Matsubayashi <[email protected]>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Sony Corporation. All rights reserved.
|
||||
// Copyright 2022 Sony Corporation. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
// todo: Supports other types besides int, string.
|
||||
|
||||
namespace commandline {
|
||||
|
||||
namespace {
|
||||
@@ -56,6 +54,15 @@ class CommandOptions {
|
||||
ReaderInt(), required, true);
|
||||
}
|
||||
|
||||
void AddDouble(const std::string& name,
|
||||
const std::string& short_name,
|
||||
const std::string& description,
|
||||
const double& default_value,
|
||||
bool required) {
|
||||
Add<double, ReaderDouble>(name, short_name, description, default_value,
|
||||
ReaderDouble(), required, true);
|
||||
}
|
||||
|
||||
void AddString(const std::string& name,
|
||||
const std::string& short_name,
|
||||
const std::string& description,
|
||||
@@ -250,6 +257,10 @@ class CommandOptions {
|
||||
std::string operator()(const std::string& value) { return value; }
|
||||
};
|
||||
|
||||
struct ReaderDouble {
|
||||
double operator()(const std::string& value) { return std::stod(value); }
|
||||
};
|
||||
|
||||
class Option {
|
||||
public:
|
||||
Option(const std::string& name,
|
||||
|
||||
Reference in New Issue
Block a user