forked from LostPointer/KeyValueTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharg.hpp
More file actions
41 lines (31 loc) · 693 Bytes
/
Copy patharg.hpp
File metadata and controls
41 lines (31 loc) · 693 Bytes
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
37
38
39
40
41
#pragma once
#include <map>
#include <string>
#include <vector>
#include "value.hpp"
class ValueError : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
class BadConvert : public ValueError {
using ValueError::ValueError;
};
class Arg {
public:
Arg(const std::string& arg);
Value Get(std::map<std::string, Value>& storage) const;
int ToInt() const;
double ToDouble() const;
private:
std::string arg_;
bool IsCommand() const;
};
template <class Iterator>
std::vector<Arg> MakeArgs(Iterator begin, Iterator end) {
std::vector<Arg> result;
while (begin != end) {
result.emplace_back(*begin);
++begin;
}
return result;
}