1 #ifndef TAG_PARSER_POSITIONINSET_H
2 #define TAG_PARSER_POSITIONINSET_H
6 #include <c++utilities/conversion/stringconversion.h>
7 #include <c++utilities/misc/traits.h>
23 constexpr
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>
28 constexpr std::int32_t position()
const;
29 constexpr std::int32_t total()
const;
30 constexpr
bool isNull()
const;
33 template <
typename StringType = std::string,
34 CppUtilities::Traits::EnableIfAny<CppUtilities::Traits::IsSpecializationOf<StringType, std::basic_string>> * =
nullptr>
35 StringType toString()
const;
38 std::int32_t m_position;
48 template <
typename StringType, CppUtilities::Traits::EnableIfAny<CppUtilities::Traits::IsSpecializationOf<StringType, std::basic_
string>> *>
53 const auto separator = numericString.find(
'/');
54 if (separator == StringType::npos || separator == numericString.length() - 1) {
55 m_position = CppUtilities::stringToNumber<std::int32_t, StringType>(numericString);
56 }
else if (separator == 0) {
57 m_total = CppUtilities::stringToNumber<std::int32_t, StringType>(numericString.substr(1));
59 m_position = CppUtilities::stringToNumber<std::int32_t, StringType>(numericString.substr(0, separator));
60 m_total = CppUtilities::stringToNumber<std::int32_t, StringType>(numericString.substr(separator + 1));
70 : m_position(position)
96 return m_position == 0 && m_total == 0;
104 return m_position == other.m_position && m_total == other.m_total;
110 template <
typename StringType, CppUtilities::Traits::EnableIfAny<CppUtilities::Traits::IsSpecializationOf<StringType, std::basic_
string>> *>
113 std::basic_stringstream<typename StringType::value_type> ss;
118 ss <<
'/' << m_total;
125 #endif // TAG_PARSER_POSITIONINSET_H