Skip to content

Commit 0ff1517

Browse files
author
Dmitry Lyssenko
committed
updating a correct source files (prior update was not entirely correct)
1 parent 7589ea3 commit 0ff1517

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

jtc.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class Jtc {
272272
void jsonized_output_obj_(Json::iterator &, Json &jref, Grouping);
273273
void jsonized_output_ary_(Json::iterator &, Json &jref, Grouping);
274274
void merge_ns_(Json::map_jn &to, const Json::map_jn &from)
275-
{ for(auto & ns: from) to[ns.KEY] = ns.VALUE; }
275+
{ for(const auto & ns: from) to[ns.KEY] = ns.VALUE; }
276276
bool shell_callback_(const std::string &lxm, Json::iterator jit) {
277277
// reminder:
278278
//typedef std::function<bool(const std::string &, const Jnode &)> uws_callback;
@@ -1054,8 +1054,8 @@ void Jtc::output_by_iterator(Json::iterator &wi, Grouping grp) {
10541054
tmp.type(Jnode::Neither);
10551055
DBG().increment(+2, tmp, -2);
10561056

1057-
wns_[&wi][WLK_HPFX] = move(hwlk_); // merge prior hist. into namespace
1058-
hwlk_.type(Jnode::Neither);
1057+
wns_[&wi][WLK_HPFX] = move(hwlk_[0]); // merge prior hist. into namespace
1058+
hwlk_[0].type(Jnode::Neither);
10591059
if(opt_[CHR(OPT_TMP)].hits() >= 1) { // -T given, interpolate
10601060
merge_ns_(cr_.global_ns(), wns_[&wi]);
10611061
// if multiple interleaved walks and multiple templates, then relate each template per walk-path
@@ -1074,7 +1074,7 @@ void Jtc::output_by_iterator(Json::iterator &wi, Grouping grp) {
10741074
if(++key_ >= opt_[CHR(OPT_TMP)].size() - 1) key_ = 0; // -1: adjust b/c of opt_'s default
10751075
}
10761076
}
1077-
if(hwlk_.is_neither()) { // templating failed or was none
1077+
if(hwlk_[0].is_neither()) { // templating failed or was none
10781078
if(wi->has_label()) hwlk_ = move(OBJ{LBL{wi->label(), *wi}}); // preserve also the label if exist
10791079
else hwlk_ = move(ARY{*wi});
10801080
}
@@ -1537,8 +1537,7 @@ void Jtc::update_wlk_history_(Json::iterator & jit) {
15371537
// now stores result of interpolation
15381538

15391539
wns_[&jit] = jinp_.ns(); // preserve walked namespace
1540-
wns_[&jit][WLK_HPFX] = move(hwlk_); // add historical namespace
1541-
hwlk_ = *jit; // preserve current walk
1540+
wns_[&jit][WLK_HPFX] = move(hwlk_[0]); // add historical namespace
15421541
if(jit->has_label()) hwlk_ = move(OBJ{LBL{jit->label(), *jit}});
15431542
else hwlk_ = move(ARY{*jit});
15441543
}

lib/Json.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,18 +772,24 @@ class Jnode {
772772
return *this;
773773
}
774774

775-
virtual Jnode & operator[](signed_size_t i) {
775+
virtual Jnode & operator[](long i) {
776776
// signed_size_t type is used instead of size_t b/c super node's overload
777777
// supports negative offsets
778778
if(is_atomic()) throw EXP(type_non_indexable);
779779
return iterator_by_idx_(i)->VALUE;
780780
}
781781

782-
virtual const Jnode & operator[](signed_size_t i) const {
782+
virtual Jnode & operator[](int i)
783+
{ return operator[](static_cast<signed_size_t>(i)); }
784+
785+
virtual const Jnode & operator[](long i) const {
783786
if(is_atomic()) throw EXP(type_non_indexable);
784787
return iterator_by_idx_(i)->VALUE;
785788
}
786789

790+
virtual const Jnode & operator[](int i) const
791+
{ return operator[](static_cast<signed_size_t>(i)); }
792+
787793
Jnode & operator[](const std::string & l) {
788794
if(not is_object()) throw EXP(type_non_subscriptable);
789795
return children_()[l];
@@ -1475,8 +1481,10 @@ class Json {
14751481
bool has_children(void) const { return root().has_children(); }
14761482
size_t children(void) const { return root().children(); }
14771483
Json & clear(void) { root().clear(); return *this; }
1478-
Jnode & operator[](signed_size_t i) { return root()[i]; }
1479-
const Jnode & operator[](signed_size_t i) const { return root()[i]; }
1484+
Jnode & operator[](long i) { return root()[i]; }
1485+
Jnode & operator[](int i) { return root()[i]; }
1486+
const Jnode & operator[](long i) const { return root()[i]; }
1487+
const Jnode & operator[](int i) const { return root()[i]; }
14801488
Jnode & operator[](const std::string & l) { return root()[l]; }
14811489
const Jnode & operator[](const std::string & l) const { return root()[l]; }
14821490
Jnode & front(void) { return root().front(); }

0 commit comments

Comments
 (0)