1 /*
2    mkvmerge -- utility for splicing together matroska files
3    from component media subtypes
4 
5    Distributed under the GPL v2
6    see the file COPYING for details
7    or visit https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
8 
9    locale string splitting and creation
10 
11    Written by Moritz Bunkus <moritz@bunkus.org>.
12 */
13 
14 #pragma once
15 
16 #include "common/common_pch.h"
17 
18 #include "common/error.h"
19 
20 namespace mtx {
21   class locale_string_format_x: public exception {
22   protected:
23     std::string m_format;
24   public:
locale_string_format_x(const std::string & format)25     locale_string_format_x(const std::string &format) : m_format{format} { }
~locale_string_format_x()26     virtual ~locale_string_format_x() throw() { }
27 
what()28     virtual const char *what() const throw() {
29       return m_format.c_str();
30     }
31   };
32 }
33 
34 class locale_string_c {
35 protected:
36   std::string m_language, m_territory, m_codeset, m_modifier;
37 
38 public:
39   enum eval_type_e {
40     language  = 0,
41     territory = 1,
42     codeset   = 2,
43     modifier  = 4,
44 
45     half      = 1,
46     full      = 7,
47   };
48 
49 public:
50   locale_string_c(std::string locale);
51 
52   locale_string_c &set_codeset_and_modifier(const locale_string_c &src);
53   std::string str(eval_type_e type = full);
54 };
55