XML: complete merge from 1.4.2

This commit is contained in:
Marian Krivos
2011-09-14 14:55:17 +00:00
parent 16ff8caf6b
commit 7e5c3a13d6
80 changed files with 9847 additions and 2282 deletions

View File

@@ -41,8 +41,11 @@
#include "Poco/DateTimeFormatter.h"
#include "Poco/DateTimeFormat.h"
#include "Poco/NumberFormatter.h"
#if !defined(POCO_VXWORKS)
#include "Poco/Process.h"
#endif
#include "Poco/Exception.h"
#include <cstdio>
using Poco::Environment;
@@ -57,11 +60,14 @@ const std::string SystemConfiguration::OSNAME = "system.osName";
const std::string SystemConfiguration::OSVERSION = "system.osVersion";
const std::string SystemConfiguration::OSARCHITECTURE = "system.osArchitecture";
const std::string SystemConfiguration::NODENAME = "system.nodeName";
const std::string SystemConfiguration::NODEID = "system.nodeId";
const std::string SystemConfiguration::CURRENTDIR = "system.currentDir";
const std::string SystemConfiguration::HOMEDIR = "system.homeDir";
const std::string SystemConfiguration::TEMPDIR = "system.tempDir";
const std::string SystemConfiguration::DATETIME = "system.dateTime";
#if !defined(POCO_VXWORKS)
const std::string SystemConfiguration::PID = "system.pid";
#endif
const std::string SystemConfiguration::ENV = "system.env.";
@@ -78,27 +84,70 @@ SystemConfiguration::~SystemConfiguration()
bool SystemConfiguration::getRaw(const std::string& key, std::string& value) const
{
if (key == OSNAME)
{
value = Environment::osName();
}
else if (key == OSVERSION)
{
value = Environment::osVersion();
}
else if (key == OSARCHITECTURE)
{
value = Environment::osArchitecture();
}
else if (key == NODENAME)
{
value = Environment::nodeName();
}
else if (key == NODEID)
{
try
{
Poco::Environment::NodeId id;
Poco::Environment::nodeId(id);
char result[13];
std::sprintf(result, "%02x%02x%02x%02x%02x%02x",
id[0],
id[1],
id[2],
id[3],
id[4],
id[5]);
value = result;
}
catch (...)
{
value = "000000000000";
}
}
else if (key == CURRENTDIR)
{
value = Path::current();
}
else if (key == HOMEDIR)
{
value = Path::home();
}
else if (key == TEMPDIR)
{
value = Path::temp();
}
else if (key == DATETIME)
{
value = Poco::DateTimeFormatter::format(Poco::DateTime(), Poco::DateTimeFormat::ISO8601_FORMAT);
}
#if !defined(POCO_VXWORKS)
else if (key == PID)
{
value = "0";
value = Poco::NumberFormatter::format(Poco::Process::id());
}
#endif
else if (key.compare(0, ENV.size(), ENV) == 0)
{
return getEnv(key.substr(ENV.size()), value);
else
return false;
}
else return false;
return true;
}
@@ -121,16 +170,25 @@ void SystemConfiguration::enumerate(const std::string& key, Keys& range) const
range.push_back("osVersion");
range.push_back("osArchitecture");
range.push_back("nodeName");
range.push_back("nodeId");
range.push_back("currentDir");
range.push_back("homeDir");
range.push_back("tempDir");
range.push_back("dateTime");
#if !defined(POCO_VXWORKS)
range.push_back("pid");
#endif
range.push_back("env");
}
}
void SystemConfiguration::removeRaw(const std::string& key)
{
throw Poco::NotImplementedException("Removing a key in a SystemConfiguration");
}
bool SystemConfiguration::getEnv(const std::string& name, std::string& value)
{
if (Environment::has(name))