#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <boost/algorithm/string/replace.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
#include <set>
#include <iterator>
BOOST_FOREACH(const Dictionary::Pair& kv, val) {
m_FP << "\n";
EmitIndent(indentLevel);
- EmitIdentifier(kv.first, true);
+
+ std::vector<String> tokens;
+ boost::algorithm::split(tokens, kv.first, boost::is_any_of("."));
+
+ EmitIdentifier(tokens[0], true);
+
+ for (std::vector<String>::size_type i = 1; i < tokens.size(); i++) {
+ m_FP << "[";
+ EmitString(tokens[i]);
+ m_FP << "]";
+ }
+
m_FP << " = ";
EmitValue(indentLevel + 1, kv.second);
}
#include "config/configwriter.hpp"
#include "base/exception.hpp"
#include "base/serializer.hpp"
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/case_conv.hpp>
using namespace icinga;
if (attrs) {
ObjectLock olock(attrs);
BOOST_FOREACH(const Dictionary::Pair& kv, attrs) {
- SetExpression *expr = new SetExpression(MakeIndexer(ScopeThis, kv.first), OpSetLiteral, MakeLiteral(kv.second));
- builder->AddExpression(expr);
+ std::vector<String> tokens;
+ boost::algorithm::split(tokens, kv.first, boost::is_any_of("."));
+
+ Expression *expr = new GetScopeExpression(ScopeThis);
+
+ BOOST_FOREACH(const String& val, tokens) {
+ expr = new IndexerExpression(expr, MakeLiteral(val));
+ }
+
+ SetExpression *aexpr = new SetExpression(expr, OpSetLiteral, MakeLiteral(kv.second));
+ builder->AddExpression(aexpr);
}
}