Tag Parser: caseinsensitivecomparer.h Source File

Tag Parser 12.5.2 C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags

Loading...
Searching...
No Matches
caseinsensitivecomparer.h
Go to the documentation of this file.
1#ifndef TAG_PARSER_CASEINSENSITIVECOMPARER
2#define TAG_PARSER_CASEINSENSITIVECOMPARER
3
4#include "./global.h"
5
6#include <string>
7
8#include <iostream>
9
10namespace TagParser {
11
15 struct TAG_PARSER_EXPORT CaseInsensitiveCharComparer {
16 static constexpr unsigned char toLower(const unsigned char c)
17 {
18 return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c;
19 }
20
21 bool operator()(const unsigned char lhs, const unsigned char rhs) const
22 {
23 return toLower(lhs) < toLower(rhs);
24 }
25};
26
30 struct TAG_PARSER_EXPORT CaseInsensitiveStringComparer {
31 bool operator()(const std::string &lhs, const std::string &rhs) const
32 {
33 return std::lexicographical_compare(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend(), CaseInsensitiveCharComparer());
34 }
35 bool operator()(std::string_view lhs, std::string_view rhs) const
36 {
37 return std::lexicographical_compare(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend(), CaseInsensitiveCharComparer());
38 }
39};
40
41} // namespace TagParser
42
43#endif // TAG_PARSER_CASEINSENSITIVECOMPARER
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
TagParser::CaseInsensitiveCharComparer
The CaseInsensitiveCharComparer struct defines a method for case-insensivive character comparison (le...
Definition caseinsensitivecomparer.h:15
TagParser::CaseInsensitiveCharComparer::toLower
static constexpr unsigned char toLower(const unsigned char c)
Definition caseinsensitivecomparer.h:16
TagParser::CaseInsensitiveCharComparer::operator()
bool operator()(const unsigned char lhs, const unsigned char rhs) const
Definition caseinsensitivecomparer.h:21
TagParser::CaseInsensitiveStringComparer
The CaseInsensitiveStringComparer struct defines a method for case-insensivive string comparison (les...
Definition caseinsensitivecomparer.h:30
TagParser::CaseInsensitiveStringComparer::operator()
bool operator()(const std::string &lhs, const std::string &rhs) const
Definition caseinsensitivecomparer.h:31
TagParser::CaseInsensitiveStringComparer::operator()
bool operator()(std::string_view lhs, std::string_view rhs) const
Definition caseinsensitivecomparer.h:35