xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
compiler.h
Go to the documentation of this file.
1 #pragma once
5 #include <vector>
6 #include "build_type.h"
7 #include "compiler_id.h"
8 #include "object.h"
9 #include "ustring.h"
10 #include "version.h"
11 
13 namespace xtd {
23  class compiler final : public object {
24  public:
26 
28  compiler() = default;
29  compiler(const compiler&) = default;
30  compiler& operator=(const compiler&) = default;
31  friend std::ostream& operator <<(std::ostream& os, const compiler& compiler) noexcept {return os << compiler.to_string();}
33 
34  xtd::build_type build_type() const noexcept {return build_type_;}
35 
36  xtd::compiler_id compiler_id() const noexcept {return compiler_id_;}
37 
38  bool is_build_type_debug() const noexcept {return build_type_ == xtd::build_type::debug; }
39 
40  static bool is_64_bit() noexcept {return sizeof(size_t) == 8;}
41 
42  xtd::ustring name() const noexcept {
43  static std::map<xtd::compiler_id, xtd::ustring> names {{compiler_id::unknown, "<unknown>"}, {compiler_id::microsoft_visual_studio, "Microsoft Visual Studio"}, {compiler_id::clang, "clang"}, {compiler_id::gcc, "gcc"}};
44  return names[compiler_id()];
45  }
46 
47  xtd::ustring version_string() const noexcept {
48  return ustring::format("{} {}", name(), version());
49  }
50 
51  const xtd::version& version() const noexcept {return version_;}
52 
55  xtd::ustring to_string() const noexcept {return version_string();}
56 
57  private:
58 #if defined(_MSC_VER)
60 #elif defined(__clang__)
62 #elif defined(__GNUC__)
64 #else
66 #endif
67 #if defined(_MSC_VER)
68  xtd::version version_ {_MSC_VER/100, _MSC_VER%100, 0};
69 #elif defined(__clang__)
70  xtd::version version_ {__clang_major__ , __clang_minor__, __clang_patchlevel__};
71 #elif defined(__GNUC__)
72  xtd::version version_ {__GNUC__ , __GNUC_MINOR__, __GNUC_PATCHLEVEL__};
73 #else
74  xtd::version version_;
75 #endif
76 #if defined(NDEBUG)
78 #else
80 #endif
81  };
82 }
Contains xtd::build_type enum class.
Represents information about c++ libraries, such as the version and standard identifier....
Definition: compiler.h:23
xtd::ustring to_string() const noexcept
Converts the value of this operating_system object to its equivalent string representation.
Definition: compiler.h:55
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition: object.h:26
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition: version.h:93
Contains xtd::compiler_id enum class.
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: ustring.h:689
build_type
Identifies the build type.
Definition: build_type.h:16
compiler_id
Identifies the compiler, supported by an assembly.
Definition: compiler_id.h:16
@ release
Build type release.
@ debug
Build type debug.
@ clang
The compiler is clang.
@ unknown
The compiler is unknown.
@ gcc
The compiler is gcc.
@ microsoft_visual_studio
The compiler is Microsoft Visual Studio.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::object class.
Contains xtd::ustring class.
Contains xtd::version class.