aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/value-to-json.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-17 19:24:28 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-17 20:13:56 +0200
commit6bd2c7bb386de16310fa5534275e6e638be60862 (patch)
tree0a12144dfb4e8d1b069bc09d583b522b5c158b28 /src/libexpr/value-to-json.cc
parent1511aa9f488ba0762c2da0bf8ab61b5fde47305d (diff)
OCD: foreach -> C++11 ranged for
Diffstat (limited to 'src/libexpr/value-to-json.cc')
-rw-r--r--src/libexpr/value-to-json.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/libexpr/value-to-json.cc b/src/libexpr/value-to-json.cc
index cdb713418..b08d82497 100644
--- a/src/libexpr/value-to-json.cc
+++ b/src/libexpr/value-to-json.cc
@@ -12,14 +12,14 @@ namespace nix {
void escapeJSON(std::ostream & str, const string & s)
{
str << "\"";
- foreach (string::const_iterator, i, s)
- if (*i == '\"' || *i == '\\') str << "\\" << *i;
- else if (*i == '\n') str << "\\n";
- else if (*i == '\r') str << "\\r";
- else if (*i == '\t') str << "\\t";
- else if (*i >= 0 && *i < 32)
- str << "\\u" << std::setfill('0') << std::setw(4) << std::hex << (uint16_t) *i << std::dec;
- else str << *i;
+ for (auto & i : s)
+ if (i == '\"' || i == '\\') str << "\\" << i;
+ else if (i == '\n') str << "\\n";
+ else if (i == '\r') str << "\\r";
+ else if (i == '\t') str << "\\t";
+ else if (i >= 0 && i < 32)
+ str << "\\u" << std::setfill('0') << std::setw(4) << std::hex << (uint16_t) i << std::dec;
+ else str << i;
str << "\"";
}
@@ -59,11 +59,11 @@ void printValueAsJSON(EvalState & state, bool strict,
if (i == v.attrs->end()) {
JSONObject json(str);
StringSet names;
- foreach (Bindings::iterator, i, *v.attrs)
- names.insert(i->name);
- foreach (StringSet::iterator, i, names) {
- Attr & a(*v.attrs->find(state.symbols.create(*i)));
- json.attr(*i);
+ for (auto & j : *v.attrs)
+ names.insert(j.name);
+ for (auto & j : names) {
+ Attr & a(*v.attrs->find(state.symbols.create(j)));
+ json.attr(j);
printValueAsJSON(state, strict, *a.value, str, context);
}
} else
@@ -80,7 +80,7 @@ void printValueAsJSON(EvalState & state, bool strict,
break;
}
- case tExternal:
+ case tExternal:
v.external->printValueAsJSON(state, strict, str, context);
break;