jsoncpp/include/json
evalon32 60ccc1f5de
feat: support std::string_view in Value API (#1584)
This adds direct support for `std::string_view` when available (C++17
and above). The current API can be used with `std::string_view` via the
low-level two-pointer methods, but is not ergonomic. E.g., compare:

```
Json::Value node;
std::string foo, bar, baz;
std::string_view foo_sv, bar_sv, baz_sv;

// Efficient & readable:
node[foo][bar][baz];
// Less efficient, less readable:
node[std::string(foo_sv)][std::string(bar_sv)][std::string(baz_sv)];
// Efficient, but a lot less readable:
*node.demand(foo_sv.data(), foo_sv.data() + foo_sv.size())
    ->demand(bar_sv.data(), bar_sv.data() + bar_sv.size())
    ->demand(baz_sv.data(), baz_sv.data() + baz_sv.size())
// After this change, efficient & readable:
node[foo_sv][bar_sv][baz_sv];
```

*   The constructor can take a `std::string_view` parameter. The existing
    overloads taking `const std::string&` and `const char*` are still necessary
    to support assignment from those types.
*   `operator[]`, `get()`, `isMember()` and `removeMember()` take a
    `std::string_view` parameter. This supersedes the overloads taking
    `const std::string&` and `const char*`. The overloads taking a pair of
    pointers (begin, end) are preserved for source compatibility.
*   `getString()` has an overload with a `std::string_view` output parameter.
    The one with a pair of pointers is preserved for source compatibility.

Signed-off-by: Lev Kandel <lmakhlis@google.com>
Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
2025-01-10 15:25:25 -08:00
..
allocator.h Fix deallocate for working on old compiers (#1478) 2024-09-11 17:43:25 -07:00
assertions.h clang-tidy fixes again (#1155) 2020-04-12 01:26:04 -04:00
config.h Fix typo in JSONCPP_USE_SECURE_MEMORY vs JSONCPP_USING_SECURE_MEMORY (#1567) 2024-09-12 10:58:39 -07:00
forwards.h Run Clang-tidy with modernize-use-auto (#1077) 2019-12-04 09:08:45 +08:00
json_features.h Use default rather than hard-coded 8 for maximum aggregate member alignment (#1378) 2022-01-12 16:27:16 -05:00
json.h Readd some overzealously removed code 2019-11-14 10:21:15 -08:00
reader.h Introduce CharReaderBuilder::ecma404Mode (#1333) 2024-09-09 20:11:44 -07:00
value.h feat: support std::string_view in Value API (#1584) 2025-01-10 15:25:25 -08:00
version.h Fix typo in JSONCPP_USE_SECURE_MEMORY vs JSONCPP_USING_SECURE_MEMORY (#1567) 2024-09-12 10:58:39 -07:00
writer.h add a valueToQuotedString overload (#1397) 2024-09-09 17:38:22 -07:00