-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommandline.hpp
36 lines (29 loc) · 1.22 KB
/
commandline.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// Created by nbollom on 30/05/16.
//
#pragma once
#include <string>
#include <list>
#include <memory>
#include "commandlineoptions.hpp"
using namespace std;
class CommandLineProcessor {
private:
const string name;
const string description;
const string version;
list<shared_ptr<Option>> options;
list<shared_ptr<ValueOption>> values;
shared_ptr<Option> GetOptionByShortName(char shortName);
shared_ptr<Option> GetOptionByLongName(const string& longName);
public:
CommandLineProcessor(string program_name, string program_description, string program_version);
void AddOption(char shortName, const string& longName, const string& description, bool hasValue, const string& valueDescription = "", const string& defaultValue = "");
void AddValueOnlyOption(const string& name, const string& description, const string& defaultValue = "");
[[nodiscard]] bool Parse(int argc, const char * const *argv);
[[nodiscard]] bool IsSet(char shortName);
[[nodiscard]] bool IsSet(const string &longName);
[[nodiscard]] string GetOptionValue(char shortName);
[[nodiscard]] string GetOptionValue(const string &longName);
[[nodiscard]] string GetValueOnlyOptionValue(const string& name) const;
};