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