| 12 | using namespace boost::json; |
| 13 | |
| 14 | class proxy |
| 15 | { |
| 16 | value& jv_; |
| 17 | |
| 18 | public: |
| 19 | explicit |
| 20 | proxy(value& jv) noexcept |
| 21 | : jv_(jv) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | proxy |
| 26 | operator[](string_view key) |
| 27 | { |
| 28 | object* obj; |
| 29 | if(jv_.is_null()) |
| 30 | obj = &jv_.emplace_object(); |
| 31 | else |
| 32 | obj = &jv_.as_object(); |
| 33 | return proxy((*obj)[key]); |
| 34 | } |
| 35 | |
| 36 | proxy |
| 37 | operator[](std::size_t index) |
| 38 | { |
| 39 | array *arr; |
| 40 | if(jv_.is_null()) |
| 41 | arr = &jv_.emplace_array(); |
| 42 | else |
| 43 | arr = &jv_.as_array(); |
| 44 | if(arr->size() <= index) |
| 45 | arr->resize(index + 1); |
| 46 | return proxy((*arr)[index]); |
| 47 | } |
| 48 | |
| 49 | value& |
| 50 | operator*() noexcept |
| 51 | { |
| 52 | return jv_; |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | |
| 57 | int |
no outgoing calls
no test coverage detected