-
Notifications
You must be signed in to change notification settings - Fork 1
/
tag-implementation.cpp
90 lines (75 loc) · 1.87 KB
/
tag-implementation.cpp
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* Copyright (c) 2013-2019 amded workers, All rights reserved.
* Terms for redistribution and use can be found in LICENCE.
*/
/**
* @file tag-implemenation.cpp
* @brief Transparent tag-implementation-type id vs. label handling
*/
#include <map>
#include <string>
#include "tag-implementation.h"
using stdstring = std::string;
static std::map< enum tag_impl, std::string > tagimpl_map {
{ TAG_T_APETAG, "apetag" },
{ TAG_T_ID3V1, "id3v1" },
{ TAG_T_ID3V2, "id3v2" },
{ TAG_T_NONE, "none" },
{ TAG_T_INVALID, "invalid" },
};
namespace Amded {
TagImplementation::TagImplementation()
{
label = "invalid";
id = TAG_T_INVALID;
}
TagImplementation::~TagImplementation() = default;
TagImplementation::TagImplementation(const std::string &l)
{
for (auto &iter : tagimpl_map) {
if (iter.second == l) {
label = l;
id = iter.first;
return;
}
}
id = TAG_T_INVALID;
label = "invalid";
}
TagImplementation::TagImplementation(enum tag_impl t)
{
label = tagimpl_map[t];
id = t;
}
TagImplementation&
TagImplementation::operator=(const std::string &l)
{
for (auto &iter : tagimpl_map) {
if (iter.second == l) {
label = l;
id = iter.first;
return *this;
}
}
id = TAG_T_INVALID;
label = "invalid";
return *this;
}
TagImplementation&
TagImplementation::operator=(enum tag_impl t)
{
label = tagimpl_map[t];
id = t;
return *this;
}
std::string
TagImplementation::get_label(void) const
{
return label;
}
enum tag_impl
TagImplementation::get_id(void) const
{
return id;
}
} /* namespace Amded */