1 | // |
2 | // Environment.h |
3 | // |
4 | // Library: Foundation |
5 | // Package: Core |
6 | // Module: Environment |
7 | // |
8 | // Definition of the Environment class. |
9 | // |
10 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #ifndef Foundation_Environment_INCLUDED |
18 | #define Foundation_Environment_INCLUDED |
19 | |
20 | |
21 | #include "Poco/Foundation.h" |
22 | |
23 | |
24 | namespace Poco { |
25 | |
26 | |
27 | class Foundation_API Environment |
28 | /// This class provides access to environment variables |
29 | /// and some general system information. |
30 | { |
31 | public: |
32 | typedef UInt8 NodeId[6]; /// Ethernet address. |
33 | |
34 | static std::string get(const std::string& name); |
35 | /// Returns the value of the environment variable |
36 | /// with the given name. Throws a NotFoundException |
37 | /// if the variable does not exist. |
38 | |
39 | static std::string get(const std::string& name, const std::string& defaultValue); |
40 | /// Returns the value of the environment variable |
41 | /// with the given name. If the environment variable |
42 | /// is undefined, returns defaultValue instead. |
43 | |
44 | static bool has(const std::string& name); |
45 | /// Returns true iff an environment variable |
46 | /// with the given name is defined. |
47 | |
48 | static void set(const std::string& name, const std::string& value); |
49 | /// Sets the environment variable with the given name |
50 | /// to the given value. |
51 | |
52 | static std::string osName(); |
53 | /// Returns the operating system name. |
54 | |
55 | static std::string osDisplayName(); |
56 | /// Returns the operating system name in a |
57 | /// "user-friendly" way. |
58 | /// |
59 | /// Currently this is only implemented for |
60 | /// Windows. There it will return names like |
61 | /// "Windows XP" or "Windows 7/Server 2008 SP2". |
62 | /// On other platforms, returns the same as |
63 | /// osName(). |
64 | |
65 | static std::string osVersion(); |
66 | /// Returns the operating system version. |
67 | |
68 | static std::string osArchitecture(); |
69 | /// Returns the operating system architecture. |
70 | |
71 | static std::string nodeName(); |
72 | /// Returns the node (or host) name. |
73 | |
74 | static void nodeId(NodeId& id); |
75 | /// Returns the Ethernet address of the first Ethernet |
76 | /// adapter found on the system. |
77 | /// |
78 | /// Throws a SystemException if no Ethernet adapter is available. |
79 | |
80 | static std::string nodeId(); |
81 | /// Returns the Ethernet address (format "xx:xx:xx:xx:xx:xx") |
82 | /// of the first Ethernet adapter found on the system. |
83 | /// |
84 | /// Throws a SystemException if no Ethernet adapter is available. |
85 | |
86 | static unsigned processorCount(); |
87 | /// Returns the number of processors installed in the system. |
88 | /// |
89 | /// If the number of processors cannot be determined, returns 1. |
90 | |
91 | static Poco::UInt32 libraryVersion(); |
92 | /// Returns the POCO C++ Libraries version as a hexadecimal |
93 | /// number in format 0xAABBCCDD, where |
94 | /// - AA is the major version number, |
95 | /// - BB is the minor version number, |
96 | /// - CC is the revision number, and |
97 | /// - DD is the patch level number. |
98 | /// |
99 | /// Some patch level ranges have special meanings: |
100 | /// - Dx mark development releases, |
101 | /// - Ax mark alpha releases, and |
102 | /// - Bx mark beta releases. |
103 | |
104 | static Poco::Int32 os(); |
105 | /// Return the operating system as defined |
106 | /// in the include Foundation/Platform.h (POCO_OS) |
107 | |
108 | static Poco::Int32 cpu(); |
109 | /// Return the underlying cpu that runs this operating system |
110 | /// as defined in Foundation/Platform (POCO_ARCH) |
111 | |
112 | static bool osFamilyUnix(); |
113 | /// Return true if the operating system belongs to the Linux family |
114 | |
115 | static bool osFamilyWindows(); |
116 | /// Return true if the operating system belongs to the Windows family |
117 | |
118 | static bool osFamilyVms(); |
119 | /// Return true if the operating system belongs to the VMS family |
120 | |
121 | }; |
122 | |
123 | |
124 | } // namespace Poco |
125 | |
126 | |
127 | #endif // Foundation_Environment_INCLUDED |
128 | |