It has been a while since I last worked on Aesalon proper.
[aesalon.git] / monitor / src / misc / ConfigurationItem.cpp
blobfbc578edbce4cdf094cb9601d34bb78de96a8d9a
1 #include <sstream>
2 #include <iostream>
4 #include "ConfigurationItem.h"
5 #include "misc/StreamAsString.h"
7 namespace Misc {
9 ConfigurationItem::ConfigurationItem(std::string name) : m_name(name) {
12 ConfigurationItem::~ConfigurationItem() {
15 int ConfigurationItem::asInt() const {
16 std::stringstream stream;
17 stream << m_data;
18 int value = 0;
19 stream >> value;
20 return value;
23 bool ConfigurationItem::asBool() const {
24 if(m_data == "false" || m_data == "") return false;
25 else if(m_data == "true") return true;
26 else {
27 throw ConfigurationItemException(Misc::StreamAsString() << "Configuration item \"" << m_name << "\" expects a boolean value.");
31 ConfigurationItemException::ConfigurationItemException(std::string message) : m_message(message) {
35 ConfigurationItemException::~ConfigurationItemException() {
39 } // namespace Misc