2 * Copyright (C) 2008 Patrick Ohly
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 #include "PrefixConfigNode.h"
20 #include "EvolutionSyncClient.h"
22 #include <boost/foreach.hpp>
23 #include <boost/algorithm/string/predicate.hpp>
25 PrefixConfigNode::PrefixConfigNode(const string prefix,
26 const boost::shared_ptr<ConfigNode> &node) :
33 PrefixConfigNode::PrefixConfigNode(const string prefix,
34 const boost::shared_ptr<const ConfigNode> &node) :
40 string PrefixConfigNode::readProperty(const string &property) const
42 return m_readOnlyNode->readProperty(m_prefix + property);
45 void PrefixConfigNode::setProperty(const string &property,
47 const string &comment,
48 const string *defValue)
50 m_node->setProperty(m_prefix + property,
56 void PrefixConfigNode::readProperties(map<string, string> &props) const
58 map<string, string> original;
59 m_readOnlyNode->readProperties(original);
61 for(map<string, string>::iterator it = original.begin();
64 string key = it->first;
65 string value = it->second;
67 if (boost::starts_with(key, m_prefix)) {
68 props.insert(make_pair(key.substr(m_prefix.size()), value));
73 void PrefixConfigNode::removeProperty(const string &property)
75 m_node->removeProperty(m_prefix + property);
78 void PrefixConfigNode::flush()
81 EvolutionSyncClient::throwError(getName() + ": read-only, flushing not allowed");