Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string_view support for object access #2685

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e3c2d55
:alembic: at() for std::string_view #1529
nlohmann Mar 24, 2021
edd2462
:bug: add missing negation
nlohmann Mar 24, 2021
d770517
:bug: add missing negation
nlohmann Mar 24, 2021
7742859
:alembic: add more std::string_view support
nlohmann Mar 24, 2021
6019b5d
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Mar 25, 2021
5ea15c4
:recycle: unify types for object keys
nlohmann Mar 25, 2021
ba97e9f
:memo: update documentation
nlohmann Mar 25, 2021
360f21e
:white_check_mark: add tests for count() and contains()
nlohmann Mar 25, 2021
2f2c759
:green_heart: fix build
nlohmann Mar 25, 2021
16fb0cb
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Mar 26, 2021
d01a6a4
:construction: add overload for erase(std::string_view)
nlohmann Mar 26, 2021
4a78689
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Mar 28, 2021
d42f37a
:construction: implement operator[] for string_view
nlohmann Mar 28, 2021
47c7e2c
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Mar 29, 2021
268600e
:ok_hand: apply review comments
nlohmann Mar 29, 2021
203b53d
:bulb: update documentation
nlohmann Mar 29, 2021
5c1c79b
:green_heart: fix build
nlohmann Mar 29, 2021
0ff33d0
:ok_hand: apply review comments
nlohmann Mar 29, 2021
f359d74
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Mar 30, 2021
69d74d4
:recycle: clean up
nlohmann Mar 30, 2021
418fdba
:alembic: exclude iterators from KeyType
nlohmann Mar 30, 2021
02b36e9
:alembic: add forgotten forward
nlohmann Mar 30, 2021
ea4891f
:ok_hand: implement some review comments
nlohmann Mar 31, 2021
4a16e55
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann May 3, 2021
0818554
:twisted_rightwards_arrows: merge develop
nlohmann May 3, 2021
12c0bc4
:memo: document less-than comparability
nlohmann May 3, 2021
eb0f8d7
:ok_hand: apply review comments
nlohmann May 3, 2021
aaef7cd
:ok_hand: apply review comments
nlohmann May 4, 2021
b27938a
:ok_hand: apply review comments
nlohmann May 4, 2021
80cb607
:construction: fix return type
nlohmann Jul 16, 2021
8ba8c43
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Jul 16, 2021
575c28c
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Jul 22, 2021
1bd8a10
:ok_hand: fix code according to review comments
nlohmann Jul 22, 2021
3212700
:ok_hand: fix code according to review comments
nlohmann Jul 22, 2021
86dd665
:alembic: add fix for Clang 3.5
nlohmann Jul 22, 2021
5f39b09
:rewind: undo experimental fix for Clang 3.5
nlohmann Jul 23, 2021
d15ad85
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Aug 30, 2021
8b9e297
:twisted_rightwards_arrows: merge develop
nlohmann Aug 30, 2021
11eab8a
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Oct 17, 2021
9b838a0
:twisted_rightwards_arrows: update from develop
nlohmann Oct 17, 2021
76109db
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Nov 20, 2021
e86d8b9
:green_heart: add fix from https://github.com/Minipeps/json/commit/dd…
nlohmann Nov 20, 2021
cf06ba8
:green_heart: add fix from https://github.com/Minipeps/json/commit/dd…
nlohmann Nov 20, 2021
25ca594
:memo: overwork documentation
nlohmann Nov 20, 2021
5379b5d
:white_check_mark: improve coverage
nlohmann Nov 20, 2021
15e4598
:ok_hand: address review comments
nlohmann Nov 23, 2021
0eac6b3
:ok_hand: address review comments
nlohmann Nov 23, 2021
47b9b7e
:ok_hand: address review comments
nlohmann Nov 23, 2021
253f39c
:alembic: experiment from https://github.com/nlohmann/json/pull/2685#…
nlohmann Dec 23, 2021
6115454
Merge branch 'develop' of https://github.com/nlohmann/json into strin…
nlohmann Dec 31, 2021
72d8615
:twisted_rightwards_arrows: merge develop branch
nlohmann Dec 31, 2021
d8db435
:alembic: try different type alias
nlohmann Jan 1, 2022
2cdf3dd
:rewind: undo commit 15e45981ead5ca64a963d79c5dd5b6d18b2c7a3f
nlohmann Jan 2, 2022
b01293f
Merge remote-tracking branch 'origin/string_view' into string_view
nlohmann Jan 2, 2022
b18d97d
:rewind: undo commit d8db435c1e1e60ebd93f9e5036437f9b8cc478e4
nlohmann Jan 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions doc/mkdocs/docs/api/basic_json/at.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ reference at(size_type idx);
const_reference at(size_type idx) const;

// (2)
reference at(const typename object_t::key_type& key);
const_reference at(const typename object_t::key_type& key) const;
template<typename KeyT>
reference at(KeyT && key);
template<typename KeyT>
const_reference at(KeyT && key) const;

// (3)
reference at(const json_pointer& ptr);
Expand All @@ -18,6 +20,12 @@ const_reference at(const json_pointer& ptr) const;
2. Returns a reference to the element at with specified key `key`, with bounds checking.
3. Returns a reference to the element at with specified JSON pointer `ptr`, with bounds checking.

## Template parameters

`KeyT`
: A type for an object key other than `basic_json::json_pointer`. This can also be a string literal or a string view
nlohmann marked this conversation as resolved.
Show resolved Hide resolved
(C++17).

## Parameters

`idx` (in)
Expand Down
3 changes: 2 additions & 1 deletion doc/mkdocs/docs/api/basic_json/contains.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ value is not an object, `#!cpp false` is returned.
## Template parameters

`KeyT`
: A type for an object key other than `basic_json::json_pointer`.
: A type for an object key other than `basic_json::json_pointer`. This can also be a string literal or a string view
nlohmann marked this conversation as resolved.
Show resolved Hide resolved
(C++17).

## Parameters

Expand Down
4 changes: 2 additions & 2 deletions doc/mkdocs/docs/api/basic_json/count.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```cpp
template<typename KeyT>
size_type count(KeyT&& key) const;
size_type count(KeyT && key) const;
nlohmann marked this conversation as resolved.
Show resolved Hide resolved
```

Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will
Expand All @@ -11,7 +11,7 @@ always be `0` (`key` was not found) or `1` (`key` was found).
## Template parameters

`KeyT`
: A type for an object key.
: A type for an object key. This can also be a string literal or a string view (C++17).
nlohmann marked this conversation as resolved.
Show resolved Hide resolved

## Parameters

Expand Down
8 changes: 7 additions & 1 deletion doc/mkdocs/docs/api/basic_json/erase.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ iterator erase(iterator first, iterator last);
const_iterator erase(const_iterator first, const_iterator last);

// (3)
size_type erase(const typename object_t::key_type& key);
template<typename KeyT>
size_type erase(KeyT && key);
nlohmann marked this conversation as resolved.
Show resolved Hide resolved

// (4)
void erase(const size_type idx);
Expand All @@ -31,6 +32,11 @@ void erase(const size_type idx);

4. Removes an element from a JSON array by index.

## Template parameters

`KeyT`
: A type convertible to an object key. This can also be a string literal or a string view (C++17).
nlohmann marked this conversation as resolved.
Show resolved Hide resolved

## Parameters

`pos` (in)
Expand Down
6 changes: 3 additions & 3 deletions doc/mkdocs/docs/api/basic_json/find.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

```cpp
template<typename KeyT>
iterator find(KeyT&& key);
iterator find(KeyT && key);
nlohmann marked this conversation as resolved.
Show resolved Hide resolved

template<typename KeyT>
const_iterator find(KeyT&& key) const
const_iterator find(KeyT && key) const
```

Finds an element in a JSON object with key equivalent to `key`. If the element is not found or the JSON value is not an
Expand All @@ -14,7 +14,7 @@ object, `end()` is returned.
## Template parameters

`KeyT`
: A type for an object key.
: A type for an object key. This can also be a string literal or a string view (C++17).
nlohmann marked this conversation as resolved.
Show resolved Hide resolved

## Parameters

Expand Down
10 changes: 8 additions & 2 deletions doc/mkdocs/docs/api/basic_json/operator[].md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ reference operator[](size_type idx);
const_reference operator[](size_type idx) const;

// (2)
reference operator[](const typename object_t::key_type& key);
const_reference operator[](const typename object_t::key_type& key) const;
template<typename KeyT>
reference operator[](KeyT && key);
nlohmann marked this conversation as resolved.
Show resolved Hide resolved
template<typename KeyT>
const_reference operator[](KeyT && key) const;
nlohmann marked this conversation as resolved.
Show resolved Hide resolved
template<typename T>
reference operator[](T* key);
template<typename T>
Expand All @@ -24,6 +26,10 @@ const_reference operator[](const json_pointer& ptr) const;

## Template parameters

`KeyT`
: A type for an object key other than `basic_json::json_pointer`. This can also be a string literal or a string view
nlohmann marked this conversation as resolved.
Show resolved Hide resolved
(C++17).

`T`
: string literal convertible to `object_t::key_type`

Expand Down
Loading