xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
country.h
Go to the documentation of this file.
1 #pragma once
5 #include "../forms_export.h"
6 #include <xtd/object.h>
7 #include <xtd/ustring.h>
8 #include <xtd/convert_string.h>
9 #include <xtd/static.h>
10 #include <xtd/drawing/bitmap.h>
11 
13 namespace xtd {
15  namespace forms {
17  class countries;
19 
29  class forms_export_ country : public object {
30  public:
32  country() = default;
33  bool operator==(const country& value) const {return name_ == value.name_ && alpha_2_code_ == value.alpha_2_code_ && alpha_3_code_ == value.alpha_3_code_ && numeric_code_ == value.numeric_code_;}
34  bool operator!=(const country& value) const {return !operator==(value);}
36 
39  static const country empty();
40 
43  virtual const xtd::ustring alpha_2_code() const {return alpha_2_code_;}
44 
47  virtual const xtd::ustring alpha_3_code() const {return alpha_3_code_;}
48 
51  virtual const xtd::ustring emoticon() const {return emoticon_;}
52 
55  virtual const xtd::drawing::image flag() const;
56 
59  virtual const xtd::drawing::image flag_squared() const;
60 
63  virtual const xtd::ustring name() const {return name_;}
64 
67  virtual int numeric_code() const {return numeric_code_;}
68 
71  static country from_alpha_2_code(const xtd::ustring& alpha_2_code);
74  static country from_alpha_3_code(const xtd::ustring& alpha_3_code);
77  static country from_name(const xtd::ustring& name);
80  static country from_numeric_code(int numeric_code);
81 
84  virtual xtd::ustring to_string() const noexcept override;
85 
87  friend std::ostream& operator<<(std::ostream& os, const xtd::forms::country& country) noexcept {
88  return os << country.to_string();
89  }
91 
92  private:
93  friend class countries;
94 
95  static const std::vector<xtd::ustring> enclosed_letters;
96  country(const xtd::ustring& name, const xtd::ustring& alpha_2_code, const xtd::ustring& alpha_3_code, int numeric_code) : name_(name), alpha_2_code_(alpha_2_code), alpha_3_code_(alpha_3_code), numeric_code_(numeric_code), emoticon_(enclosed_letters[alpha_2_code[0] - 'A'] + enclosed_letters[alpha_2_code[1] - 'A']) {}
97 
98  xtd::ustring name_;
99  xtd::ustring alpha_2_code_;
100  xtd::ustring alpha_3_code_;
101  int numeric_code_;
102  xtd::ustring emoticon_;
103  };
104  }
105 }
Contains xtd::static_object class.
virtual int numeric_code() const
Gets the country numeric code.
Definition: country.h:67
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
virtual const xtd::ustring name() const
Gets the country name.
Definition: country.h:63
virtual const xtd::ustring emoticon() const
Gets the country emoticon.
Definition: country.h:51
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
virtual xtd::ustring to_string() const noexcept override
Returns a string containing the name, alpha codes and numeric code of the country.
Provides a collection of xtd::forms::country for all countries in the world. This class cannot be inh...
Definition: countries.h:20
virtual const xtd::ustring alpha_3_code() const
Gets the country alpha 3 code.
Definition: country.h:47
Contains xtd::ustring class.
Contains xtd::convert_string class.
An abstract base class that provides functionality for the bitmap and metafile descended classes...
Definition: image.h:34
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:26
Contains xtd::drawing::bitmap class.
Represent a country with name, alpha codes, numeric code, emoticon and flag.
Definition: country.h:29
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
virtual const xtd::ustring alpha_2_code() const
Gets the country alpha 2 code.
Definition: country.h:43
std::string to_string(const value_t &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: to_string.h:37