-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use nlohmann::position_t instead of lexer for detailed position infor…
…mation when using a sax parser
- Loading branch information
barcode
committed
Dec 23, 2022
1 parent
e90d005
commit db06dab
Showing
15 changed files
with
330 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
docs/mkdocs/docs/api/position_t/chars_read_current_line.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# <small>nlohmann::position_t::</small>chars_read_current_line | ||
|
||
```cpp | ||
std::size_t chars_read_current_line; | ||
``` | ||
|
||
The number of characters read in the current line. | ||
|
||
## Examples | ||
|
||
??? example | ||
|
||
The example below shows a SAX receiving the element bounds as `nlohmann::position_t` and | ||
storing this location information in each json node using a [base class](../basic_json/json_base_class_t.md) for `nlohmann::json` as customization point. | ||
|
||
```cpp | ||
--8<-- "examples/sax_parse_with_src_location_in_json.cpp" | ||
``` | ||
|
||
Output: | ||
|
||
```json | ||
--8<-- "examples/sax_parse_with_src_location_in_json.output" | ||
``` | ||
|
||
## Version history | ||
|
||
- Moved from namespace `nlohmann::detail` to `nlohmann` in version ???.???.???. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# <small>nlohmann::position_t::</small>chars_read_total | ||
|
||
```cpp | ||
std::size_t chars_read_total; | ||
``` | ||
|
||
The total number of characters read. | ||
|
||
## Examples | ||
|
||
??? example | ||
|
||
The example below shows a SAX receiving the element bounds as `nlohmann::position_t` and | ||
storing this location information in each json node using a [base class](../basic_json/json_base_class_t.md) for `nlohmann::json` as customization point. | ||
|
||
```cpp | ||
--8<-- "examples/sax_parse_with_src_location_in_json.cpp" | ||
``` | ||
|
||
Output: | ||
|
||
```json | ||
--8<-- "examples/sax_parse_with_src_location_in_json.output" | ||
``` | ||
|
||
## Version history | ||
|
||
- Moved from namespace `nlohmann::detail` to `nlohmann` in version ???.???.???. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# <small>nlohmann::</small>position_t | ||
|
||
```cpp | ||
struct position_t; | ||
``` | ||
|
||
This type represents the parsers position when parsing a json string using. | ||
This position can be retrieved when using a [sax parser](../json_sax/index.md) with the format `nlohmann::json::input_format_t::json` | ||
and implementing [next_token_start](../json_sax/next_token_start.md) or [next_token_end](../json_sax/next_token_end.md). | ||
|
||
## Member functions | ||
|
||
- [**operator size_t**](operator_size_t.md) - return the value of [chars_read_total](chars_read_total.md). | ||
|
||
## Member variables | ||
|
||
- [**chars_read_total**](chars_read_total.md) - The total number of characters read. | ||
- [**lines_read**](lines_read.md) - The number of lines read. | ||
- [**chars_read_current_line**](chars_read_current_line.md) - The number of characters read in the current line. | ||
|
||
## Version history | ||
|
||
- Moved from namespace `nlohmann::detail` to `nlohmann` in version ???.???.???. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# <small>nlohmann::position_t::</small>lines_read | ||
|
||
```cpp | ||
std::size_t lines_read; | ||
``` | ||
|
||
The number of lines read. | ||
|
||
## Examples | ||
|
||
??? example | ||
|
||
The example below shows a SAX receiving the element bounds as `nlohmann::position_t` and | ||
storing this location information in each json node using a [base class](../basic_json/json_base_class_t.md) for `nlohmann::json` as customization point. | ||
|
||
```cpp | ||
--8<-- "examples/sax_parse_with_src_location_in_json.cpp" | ||
``` | ||
|
||
Output: | ||
|
||
```json | ||
--8<-- "examples/sax_parse_with_src_location_in_json.output" | ||
``` | ||
|
||
## Version history | ||
|
||
- Moved from namespace `nlohmann::detail` to `nlohmann` in version ???.???.???. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# <small>nlohmann::position_t::</small> | ||
|
||
```cpp | ||
constexpr operator size_t() const; | ||
``` | ||
|
||
return the value of [chars_read_total](chars_read_total.md). | ||
|
||
## Examples | ||
|
||
??? example | ||
|
||
The example below shows a SAX receiving the element bounds as `nlohmann::position_t` and | ||
storing this location information in each json node using a [base class](../basic_json/json_base_class_t.md) for `nlohmann::json` as customization point. | ||
|
||
```cpp | ||
--8<-- "examples/sax_parse_with_src_location_in_json.cpp" | ||
``` | ||
|
||
Output: | ||
|
||
```json | ||
--8<-- "examples/sax_parse_with_src_location_in_json.output" | ||
``` | ||
|
||
## Version history | ||
|
||
- Moved from namespace `nlohmann::detail` to `nlohmann` in version ???.???.???. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.