fixup Fix to build with libxml 2.12.x (fixes #505)
[platform/upstream/libzypp.git] / zypp / LanguageCode.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/LanguageCode.h
10  *
11 */
12 #ifndef ZYPP_LANGUAGECODE_H
13 #define ZYPP_LANGUAGECODE_H
14
15 #include <iosfwd>
16 #include <string>
17
18 #include "zypp/IdStringType.h"
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 {
23   ///////////////////////////////////////////////////////////////////
24   /// \class LanguageCode
25   /// \brief Language codes (iso639_2/iso639_1).
26   ///
27   /// In fact the class will not prevent to use a non iso language code.
28   /// Just a warning will appear in the log.
29   ///////////////////////////////////////////////////////////////////
30   class LanguageCode : public IdStringType<LanguageCode>
31   {
32   public:
33     /** Default Ctor: \ref noCode */
34     LanguageCode();
35
36     /** Ctor from string. */
37     explicit LanguageCode( IdString str_r );
38
39     /** Ctor from string. */
40     explicit LanguageCode( const std::string & str_r );
41
42     /** Ctor from string. */
43     explicit LanguageCode( const char * str_r );
44
45      /** Dtor */
46     ~LanguageCode();
47
48   public:
49     /** \name LanguageCode constants. */
50     //@{
51     /** Empty code. */
52     static const LanguageCode noCode;
53     /** Last resort "en". */
54     static const LanguageCode enCode;
55     //@}
56
57   public:
58     /** Return the language code asString. */
59     std::string code() const
60     { return std::string(_str); }
61
62     /** Return the translated language name; if unknown the language code. */
63     std::string name() const;
64
65   private:
66     friend class IdStringType<LanguageCode>;
67     IdString _str;
68   };
69 } // namespace zypp
70 ///////////////////////////////////////////////////////////////////
71
72 ZYPP_DEFINE_ID_HASHABLE( ::zypp::LanguageCode );
73
74 #endif // ZYPP_LANGUAGECODE_H