Environment.h 3.1 KB

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