File: Option.cpp

package info (click to toggle)
ausaxs 1.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 72,592 kB
  • sloc: cpp: 49,853; ansic: 6,901; python: 730; makefile: 18
file content (23 lines) | stat: -rw-r--r-- 867 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// SPDX-License-Identifier: LGPL-3.0-or-later
// Author: Kristian Lytje

#include <shell/Option.h>

using namespace ausaxs::shell;

Option::Option() noexcept = default;
Option::Option(const std::string& name, const std::string& value) : name(name), value(value) {}
Option::~Option() = default;

std::string Option::get() const {
    if (value.empty()) {
        return name;
    }
    return name + " " + value;
}
Argument::Argument(const std::string& name, const std::string& value) : Option(name, value) {}
Argument::Argument(const std::string& name, double value) : Option(name, std::to_string(value)) {}
Argument::Argument(const std::string& name, int value) : Option(name, std::to_string(value)) {}
Argument::Argument(const std::string& name, unsigned int value) : Option(name, std::to_string(value)) {}

Flag::Flag(const std::string& name) : Option(name, "") {}