Tag Parser
12.5.3
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Toggle main menu visibility
Loading...
Searching...
No Matches
positioninset.h
Go to the documentation of this file.
1
#ifndef TAG_PARSER_POSITIONINSET_H
2
#define TAG_PARSER_POSITIONINSET_H
3
4
#include "
./global.h
"
5
6
#include <c++utilities/conversion/stringconversion.h>
7
#include <c++utilities/misc/traits.h>
8
9
#include <string>
10
11
namespace
TagParser
{
12
21
class
TAG_PARSER_EXPORT
PositionInSet
{
22
public
:
23
constexpr
explicit
PositionInSet
(std::int32_t
position
= 0, std::int32_t
total
= 0);
24
template
<
typename
StringType = std::string,
25
CppUtilities::Traits::EnableIfAny<CppUtilities::Traits::IsSpecializationOf<StringType, std::basic_string>> * =
nullptr
>
26
PositionInSet
(
const
StringType &numericString);
27
28
constexpr
std::int32_t
position
()
const
;
29
void
setPosition
(std::int32_t
position
);
30
constexpr
std::int32_t
total
()
const
;
31
void
setTotal
(std::int32_t
total
);
32
constexpr
bool
isNull
()
const
;
33
constexpr
bool
operator==
(
const
PositionInSet
&other)
const
;
34
35
template
<
typename
StringType = std::string,
36
CppUtilities::Traits::EnableIfAny<CppUtilities::Traits::IsSpecializationOf<StringType, std::basic_string>> * =
nullptr
>
37
StringType
toString
()
const
;
38
39
private
:
40
std::int32_t m_position;
41
std::int32_t m_total;
42
};
43
50
template
<
typename
StringType, CppUtilities::Traits::EnableIfAny<CppUtilities::Traits::IsSpecializationOf<StringType, std::basic_
string
>> *>
51
PositionInSet::PositionInSet
(
const
StringType &numericString)
52
: m_position(0)
53
, m_total(0)
54
{
55
const
auto
separator = numericString.find(
'/'
);
56
if
(separator == StringType::npos || separator == numericString.length() - 1) {
57
m_position = CppUtilities::stringToNumber<std::int32_t, StringType>(numericString);
58
}
else
if (separator == 0) {
59
m_total = CppUtilities::stringToNumber<std::int32_t, StringType>(numericString.substr(1));
60
}
else
{
61
m_position = CppUtilities::stringToNumber<std::int32_t, StringType>(numericString.substr(0, separator));
62
m_total = CppUtilities::stringToNumber<std::int32_t, StringType>(numericString.substr(separator + 1));
63
}
64
}
65
71
constexpr
inline
PositionInSet::PositionInSet
(std::int32_t
position
, std::int32_t
total
)
72
: m_position(
position
)
73
, m_total(
total
)
74
{
75
}
76
80
constexpr
inline
std::int32_t
PositionInSet::position
()
const
81
{
82
return
m_position;
83
}
84
88
inline
void
PositionInSet::setPosition
(int32_t
position
)
89
{
90
m_position =
position
;
91
}
92
96
constexpr
inline
std::int32_t
PositionInSet::total
()
const
97
{
98
return
m_total;
99
}
100
104
inline
void
PositionInSet::setTotal
(int32_t
total
)
105
{
106
m_total =
total
;
107
}
108
112
constexpr
inline
bool
PositionInSet::isNull
()
const
113
{
114
return
m_position == 0 && m_total == 0;
115
}
116
120
constexpr
inline
bool
PositionInSet::operator==
(
const
PositionInSet
&other)
const
121
{
122
return
m_position == other.m_position && m_total == other.m_total;
123
}
124
128
template
<
typename
StringType, CppUtilities::Traits::EnableIfAny<CppUtilities::Traits::IsSpecializationOf<StringType, std::basic_
string
>> *>
129
StringType
PositionInSet::toString
()
const
130
{
131
std::basic_stringstream<typename StringType::value_type> ss;
132
if
(m_position) {
133
ss << m_position;
134
}
135
if
(m_total) {
136
ss <<
'/'
<< m_total;
137
}
138
return
ss.str();
139
}
140
141
}
// namespace TagParser
142
143
#endif
// TAG_PARSER_POSITIONINSET_H
TagParser::PositionInSet::operator==
constexpr bool operator==(const PositionInSet &other) const
Returns whether this instance equals other.
Definition
positioninset.h:120
TagParser::PositionInSet::setTotal
void setTotal(std::int32_t total)
Sets the total element count of the current instance.
Definition
positioninset.h:104
TagParser::PositionInSet::position
constexpr std::int32_t position() const
Returns the element position of the current instance.
Definition
positioninset.h:80
TagParser::PositionInSet::setPosition
void setPosition(std::int32_t position)
Sets the element position of the current instance.
Definition
positioninset.h:88
TagParser::PositionInSet::total
constexpr std::int32_t total() const
Returns the total element count of the current instance.
Definition
positioninset.h:96
TagParser::PositionInSet::PositionInSet
constexpr PositionInSet(std::int32_t position=0, std::int32_t total=0)
Constructs a new Position in set of the specified element position and total element count.
Definition
positioninset.h:71
TagParser::PositionInSet::toString
StringType toString() const
Returns the string representation of the current PositionInSet.
Definition
positioninset.h:129
TagParser::PositionInSet::isNull
constexpr bool isNull() const
Returns an indication whether both the element position and total element count is 0.
Definition
positioninset.h:112
global.h
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition
global.h:14
TagParser
Contains all classes and functions of the TagInfo library.
Definition
aaccodebook.h:10
Generated on
for Tag Parser by
1.18.0