Environment.cpp
Go to the documentation of this file.
00001 //
00002 // Environment.cpp
00003 //
00004 // $Id: //poco/1.3/Foundation/src/Environment.cpp#3 $
00005 //
00006 // Library: Foundation
00007 // Package: Core
00008 // Module:  Environment
00009 //
00010 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
00011 // and Contributors.
00012 //
00013 // Permission is hereby granted, free of charge, to any person or organization
00014 // obtaining a copy of the software and accompanying documentation covered by
00015 // this license (the "Software") to use, reproduce, display, distribute,
00016 // execute, and transmit the Software, and to prepare derivative works of the
00017 // Software, and to permit third-parties to whom the Software is furnished to
00018 // do so, all subject to the following:
00019 // 
00020 // The copyright notices in the Software and this entire statement, including
00021 // the above license grant, this restriction and the following disclaimer,
00022 // must be included in all copies of the Software, in whole or in part, and
00023 // all derivative works of the Software, unless such copies or derivative
00024 // works are solely in the form of machine-executable object code generated by
00025 // a source language processor.
00026 // 
00027 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00028 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00029 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00030 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00031 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00032 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00033 // DEALINGS IN THE SOFTWARE.
00034 //
00035 
00036 
00037 #include "Poco/Environment.h"
00038 #include <cstdlib>
00039 #include <cstdio> // sprintf()
00040 
00041 
00042 #if defined(POCO_OS_FAMILY_VMS)
00043 #include "Environment_VMS.cpp"
00044 #elif defined(POCO_OS_FAMILY_UNIX)
00045 #include "Environment_UNIX.cpp"
00046 #elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
00047 #include "Environment_WIN32U.cpp"
00048 #elif defined(POCO_OS_FAMILY_WINDOWS)
00049 #include "Environment_WIN32.cpp"
00050 #endif
00051 
00052 
00053 namespace Poco {
00054 
00055 
00056 std::string Environment::get(const std::string& name)
00057 {
00058         return EnvironmentImpl::getImpl(name);
00059 }
00060 
00061 
00062 std::string Environment::get(const std::string& name, const std::string& defaultValue)
00063 {
00064         if (has(name))
00065                 return get(name);
00066         else
00067                 return defaultValue;
00068 }
00069 
00070         
00071 bool Environment::has(const std::string& name)
00072 {
00073         return EnvironmentImpl::hasImpl(name);
00074 }
00075 
00076         
00077 void Environment::set(const std::string& name, const std::string& value)
00078 {
00079         EnvironmentImpl::setImpl(name, value);
00080 }
00081 
00082 
00083 std::string Environment::osName()
00084 {
00085         return EnvironmentImpl::osNameImpl();
00086 }
00087 
00088         
00089 std::string Environment::osVersion()
00090 {
00091         return EnvironmentImpl::osVersionImpl();
00092 }
00093 
00094         
00095 std::string Environment::osArchitecture()
00096 {
00097         return EnvironmentImpl::osArchitectureImpl();
00098 }
00099         
00100 
00101 std::string Environment::nodeName()
00102 {
00103         return EnvironmentImpl::nodeNameImpl();
00104 }
00105 
00106 
00107 std::string Environment::nodeId()
00108 {
00109         NodeId id;
00110         nodeId(id);
00111         char result[18];
00112         std::sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
00113                 id[0],
00114                 id[1],
00115                 id[2],
00116                 id[3],
00117                 id[4],
00118                 id[5]);
00119         return std::string(result);
00120 }
00121 
00122 
00123 void Environment::nodeId(NodeId& id)
00124 {
00125         return EnvironmentImpl::nodeIdImpl(id);
00126 }
00127 
00128 
00129 } // namespace Poco


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:19