-
Notifications
You must be signed in to change notification settings - Fork 1
/
value.h
71 lines (54 loc) · 1.41 KB
/
value.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Copyright (c) 2013-2019 amded workers, All rights reserved.
* Terms for redistribution and use can be found in LICENCE.
*/
/**
* @file value.h
* @brief API of a container that holds multiple data-types
*/
#ifndef INC_VALUE_H
#define INC_VALUE_H
#include <string>
#include <tstring.h>
#include "amded.h"
class Value {
private:
enum tag_type type;
union {
bool b;
int i;
TagLib::String s;
};
public:
/* exception class */
class bad_accessor {};
/* (de)construction */
Value() : type(TAG_INVALID) {};
~Value();
/* Construction from boolean */
Value(bool);
Value& operator=(const bool&);
/* Construction from integers */
Value(int);
Value& operator=(const int&);
/* Construction from strings */
Value(const TagLib::String&);
Value& operator=(const TagLib::String&);
Value(const std::string&);
Value& operator=(const std::string&);
/* copy construction and assignment */
Value(const Value&);
Value& operator=(const Value&);
/* move construction and assignment */
Value(Value&&) noexcept;
Value& operator=(Value&&) noexcept;
enum tag_type get_type() const;
bool get_bool() const;
int get_int() const;
TagLib::String get_str() const;
void set_bool(bool);
void set_int(int);
void set_str(const TagLib::String &);
void set_invalid(void);
};
#endif /* INC_VALUE_H */