-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace getters for reference to node values (#481)
* implemented as_xxx() in basic_node template class to replace get_value_ref() * replaced internal get_value_ref() calls with as_xxx() * added test cases for as_xxx() functions * added api references & examples for the new as_xxx() functions * improved migration guide from get_value_ref
- Loading branch information
Showing
49 changed files
with
1,385 additions
and
628 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<small>Defined in header [`<fkYAML/node.hpp>`](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/node.hpp)</small> | ||
|
||
# <small>fkyaml::basic_node::</small>as_bool | ||
|
||
```cpp | ||
boolean_type& as_bool(); | ||
const boolean_type& as_bool() const; | ||
``` | ||
|
||
Returns (const) reference to the boolean node value. | ||
If the current node value is not a boolean, a [`fkyaml::type_error`](../exception/type_error.md) will be thrown. | ||
|
||
## **Return Value** | ||
|
||
(const) reference to the boolean node value. | ||
|
||
## **Examples** | ||
|
||
??? Example | ||
|
||
```cpp | ||
--8<-- "apis/basic_node/as_bool.cpp:9" | ||
``` | ||
|
||
output: | ||
```bash | ||
--8<-- "apis/basic_node/as_bool.output" | ||
``` | ||
|
||
## **See Also** | ||
|
||
* [node_type](../node_type.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,32 @@ | ||
<small>Defined in header [`<fkYAML/node.hpp>`](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/node.hpp)</small> | ||
|
||
# <small>fkyaml::basic_node::</small>as_float | ||
|
||
```cpp | ||
float_number_type& as_float(); | ||
const float_number_type& as_float() const; | ||
``` | ||
|
||
Returns (const) reference to the float node value. | ||
If the current node value is not a floating point value, a [`fkyaml::type_error`](../exception/type_error.md) will be thrown. | ||
|
||
## **Return Value** | ||
|
||
(const) reference to the float node value. | ||
|
||
## **Examples** | ||
|
||
??? Example | ||
|
||
```cpp | ||
--8<-- "apis/basic_node/as_float.cpp:9" | ||
``` | ||
|
||
output: | ||
```bash | ||
--8<-- "apis/basic_node/as_float.output" | ||
``` | ||
|
||
## **See Also** | ||
|
||
* [node_type](../node_type.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,32 @@ | ||
<small>Defined in header [`<fkYAML/node.hpp>`](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/node.hpp)</small> | ||
|
||
# <small>fkyaml::basic_node::</small>as_int | ||
|
||
```cpp | ||
integer_type& as_int(); | ||
const integer_type& as_int() const; | ||
``` | ||
|
||
Returns (const) reference to the integer node value. | ||
If the current node value is not an integer, a [`fkyaml::type_error`](../exception/type_error.md) will be thrown. | ||
|
||
## **Return Value** | ||
|
||
(const) reference to the integer node value. | ||
|
||
## **Examples** | ||
|
||
??? Example | ||
|
||
```cpp | ||
--8<-- "apis/basic_node/as_int.cpp:9" | ||
``` | ||
|
||
output: | ||
```bash | ||
--8<-- "apis/basic_node/as_int.output" | ||
``` | ||
|
||
## **See Also** | ||
|
||
* [node_type](../node_type.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,32 @@ | ||
<small>Defined in header [`<fkYAML/node.hpp>`](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/node.hpp)</small> | ||
|
||
# <small>fkyaml::basic_node::</small>as_map | ||
|
||
```cpp | ||
mapping_type& as_map(); | ||
const mapping_type& as_map() const; | ||
``` | ||
|
||
Returns (const) reference to the mapping node value. | ||
If the current node value is not a mapping, a [`fkyaml::type_error`](../exception/type_error.md) will be thrown. | ||
|
||
## **Return Value** | ||
|
||
(const) reference to the mapping node value. | ||
|
||
## **Examples** | ||
|
||
??? Example | ||
|
||
```cpp | ||
--8<-- "apis/basic_node/as_map.cpp:9" | ||
``` | ||
|
||
output: | ||
```bash | ||
--8<-- "apis/basic_node/as_map.output" | ||
``` | ||
|
||
## **See Also** | ||
|
||
* [node_type](../node_type.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,32 @@ | ||
<small>Defined in header [`<fkYAML/node.hpp>`](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/node.hpp)</small> | ||
|
||
# <small>fkyaml::basic_node::</small>as_seq | ||
|
||
```cpp | ||
sequence_type& as_seq(); | ||
const sequence_type& as_seq() const; | ||
``` | ||
|
||
Returns (const) reference to the sequence node value. | ||
If the current node value is not an sequence, a [`fkyaml::type_error`](../exception/type_error.md) will be thrown. | ||
|
||
## **Return Value** | ||
|
||
(const) reference to the sequence node value. | ||
|
||
## **Examples** | ||
|
||
??? Example | ||
|
||
```cpp | ||
--8<-- "apis/basic_node/as_seq.cpp:9" | ||
``` | ||
|
||
output: | ||
```bash | ||
--8<-- "apis/basic_node/as_seq.output" | ||
``` | ||
|
||
## **See Also** | ||
|
||
* [node_type](../node_type.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,32 @@ | ||
<small>Defined in header [`<fkYAML/node.hpp>`](https://github.com/fktn-k/fkYAML/blob/develop/include/fkYAML/node.hpp)</small> | ||
|
||
# <small>fkyaml::basic_node::</small>as_str | ||
|
||
```cpp | ||
string_type& as_str(); | ||
const string_type& as_str() const; | ||
``` | ||
|
||
Returns (const) reference to the string node value. | ||
If the current node value is not an string, a [`fkyaml::type_error`](../exception/type_error.md) will be thrown. | ||
|
||
## **Return Value** | ||
|
||
(const) reference to the string node value. | ||
|
||
## **Examples** | ||
|
||
??? Example | ||
|
||
```cpp | ||
--8<-- "apis/basic_node/as_str.cpp:9" | ||
``` | ||
|
||
output: | ||
```bash | ||
--8<-- "apis/basic_node/as_str.output" | ||
``` | ||
|
||
## **See Also** | ||
|
||
* [node_type](../node_type.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
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
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.