POCO C++库学习和分析 -- 平台与环境

本文介绍了POCO C++库中的Environment类,用于获取系统信息,如网卡、环境变量、操作系统详情和处理器数量。通过EnvironmentImpl类针对不同操作系统实现统一接口。
摘要由CSDN通过智能技术生成

POCO C++库学习和分析 -- 平台与环境


          在写程序的时候,有时候需要收集一些系统信息,用作软硬件的绑定或生成唯一的注册码信息等。Poco中提供了一个很简单的类Environment来实现这个功能。这个类的定义如下:

class Foundation_API Environment
	/// This class provides access to environment variables
	/// and some general system information.
{
public:
	typedef UInt8 NodeId[6]; /// Ethernet address.
	
	static std::string get(const std::string& name);
		/// Returns the value of the environment variable
		/// with the given name. Throws a NotFoundException
		/// if the variable does not exist.
		
	static std::string get(const std::string& name, const std::string& defaultValue);
		/// Returns the value of the environment variable
		/// with the given name. If the environment variable
		/// is undefined, returns defaultValue instead.
		
	static bool has(const std::string& name);
		/// Returns true iff an environment variable
		/// with the given name is defined.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值