Merge the latest cpp template from flutter-embedded-linux repo (#131)

Signed-off-by: Hidenori Matsubayashi <[email protected]>
This commit is contained in:
Hidenori Matsubayashi
2022-09-02 21:46:30 +09:00
committed by GitHub
parent 392c64b34a
commit b2e75e4be3
3 changed files with 33 additions and 5 deletions
+14 -3
View File
@@ -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,