|
|
@ -8,7 +8,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include <cstdint> |
|
|
|
#include <cstdint> |
|
|
|
#include <sstream> |
|
|
|
#include <sstream> |
|
|
|
#include <string> |
|
|
|
|
|
|
|
#include <variant> |
|
|
|
#include <variant> |
|
|
|
|
|
|
|
|
|
|
|
#include "collation.hpp" |
|
|
|
#include "collation.hpp" |
|
|
@ -56,7 +55,7 @@ static auto missing_component_text(const Track& track, Tag tag) |
|
|
|
case Tag::kTitle: |
|
|
|
case Tag::kTitle: |
|
|
|
return track.TitleOrFilename(); |
|
|
|
return track.TitleOrFilename(); |
|
|
|
case Tag::kAlbumTrack: |
|
|
|
case Tag::kAlbumTrack: |
|
|
|
return "0"; |
|
|
|
return "0000"; |
|
|
|
case Tag::kDuration: |
|
|
|
case Tag::kDuration: |
|
|
|
default: |
|
|
|
default: |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
@ -77,29 +76,17 @@ auto Index(locale::ICollator& collator, const IndexInfo& info, const Track& t) |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
for (std::uint8_t i = 0; i < info.components.size(); i++) { |
|
|
|
for (std::uint8_t i = 0; i < info.components.size(); i++) { |
|
|
|
Tag component = info.components.at(i); |
|
|
|
|
|
|
|
// Fill in the text for this depth.
|
|
|
|
// Fill in the text for this depth.
|
|
|
|
|
|
|
|
auto text = t.tags().at(info.components.at(i)); |
|
|
|
std::pmr::string value; |
|
|
|
std::pmr::string value; |
|
|
|
|
|
|
|
if (text) { |
|
|
|
if (component == Tag::kAlbumTrack) { |
|
|
|
std::pmr::string orig = *text; |
|
|
|
// Track numbers are a special case, since they're numbers rather than
|
|
|
|
auto xfrm = collator.Transform({orig.data(), orig.size()}); |
|
|
|
// text.
|
|
|
|
key.item = {xfrm.data(), xfrm.size()}; |
|
|
|
auto pmr_num = t.tags().at(component).value_or("0"); |
|
|
|
value = *text; |
|
|
|
// std::pmr continues to be a true disappointment.
|
|
|
|
|
|
|
|
std::string raw_num{pmr_num.data(), pmr_num.size()}; |
|
|
|
|
|
|
|
uint32_t num = std::stoi(raw_num); |
|
|
|
|
|
|
|
key.item = std::pmr::string{reinterpret_cast<char*>(&num), 4}; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
auto text = t.tags().at(component); |
|
|
|
key.item = {}; |
|
|
|
if (text) { |
|
|
|
value = missing_component_text(t, info.components.at(i)).value_or(""); |
|
|
|
std::pmr::string orig = *text; |
|
|
|
|
|
|
|
auto xfrm = collator.Transform({orig.data(), orig.size()}); |
|
|
|
|
|
|
|
key.item = {xfrm.data(), xfrm.size()}; |
|
|
|
|
|
|
|
value = *text; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
key.item = {}; |
|
|
|
|
|
|
|
value = missing_component_text(t, info.components.at(i)).value_or(""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// If this is the last component, then we should also fill in the track id
|
|
|
|
// If this is the last component, then we should also fill in the track id
|
|
|
|