Tag Parser  9.1.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
language.cpp
Go to the documentation of this file.
1 #include "./language.h"
2 
3 #include <unordered_map>
4 
5 namespace TagParser {
6 
8 static const auto &languageMapping()
9 {
10 #include "resources/languages.h"
11  return languages;
12 }
14 
19 const std::string &languageNameFromIso(const std::string &isoCode)
20 {
21  const auto &mapping = languageMapping();
22  const auto i = mapping.find(isoCode);
23  if (i == mapping.cend()) {
24  static const std::string empty;
25  return empty;
26  }
27  return i->second;
28 }
29 
34 const std::string &languageNameFromIsoWithFallback(const std::string &isoCode)
35 {
36  const auto &mapping = languageMapping();
37  const auto i = mapping.find(isoCode);
38  if (i == mapping.cend()) {
39  return isoCode;
40  }
41  return i->second;
42 }
43 
44 } // namespace TagParser
TagParser
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagParser::languageNameFromIsoWithFallback
const TAG_PARSER_EXPORT std::string & languageNameFromIsoWithFallback(const std::string &isoCode)
Returns the language name for the specified ISO-639-2 code (bibliographic, 639-2/B).
Definition: language.cpp:34
TagParser::languageNameFromIso
const TAG_PARSER_EXPORT std::string & languageNameFromIso(const std::string &isoCode)
Returns the language name for the specified ISO-639-2 code (bibliographic, 639-2/B).
Definition: language.cpp:19
language.h