📝 added example and documentation for the meta function
This commit is contained in:
parent
cdde1a9436
commit
38e4935db0
5 changed files with 69 additions and 2 deletions
9
doc/examples/meta.cpp
Normal file
9
doc/examples/meta.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// call meta()
|
||||
std::cout << std::setw(4) << json::meta() << '\n';
|
||||
}
|
1
doc/examples/meta.link
Normal file
1
doc/examples/meta.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/3hERJociqLo3vdod"><b>online</b></a>
|
17
doc/examples/meta.output
Normal file
17
doc/examples/meta.output
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"compiler": {
|
||||
"c++": "201103",
|
||||
"family": "clang",
|
||||
"version": "8.0.0 (clang-800.0.42.1)"
|
||||
},
|
||||
"copyright": "(C) 2013-2017 Niels Lohmann",
|
||||
"name": "JSON for Modern C++",
|
||||
"platform": "apple",
|
||||
"url": "https://github.com/nlohmann/json",
|
||||
"version": {
|
||||
"major": 2,
|
||||
"minor": 1,
|
||||
"patch": 0,
|
||||
"string": "2.1.0"
|
||||
}
|
||||
}
|
22
src/json.hpp
22
src/json.hpp
|
@ -1105,6 +1105,26 @@ class basic_json
|
|||
|
||||
/*!
|
||||
@brief returns version information on the library
|
||||
|
||||
This function returns a JSON object with infiormation about the library,
|
||||
including the version number and information on the platform and compiler.
|
||||
|
||||
@return JSON object holding version information
|
||||
key | description
|
||||
----------- | ---------------
|
||||
`compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version).
|
||||
`copyright` | The copyright line for the library as string.
|
||||
`name` | The name of the library as string.
|
||||
`platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`.
|
||||
`url` | The URL of the project as string.
|
||||
`version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string).
|
||||
|
||||
@liveexample{The following code shows an example output of the `meta()`
|
||||
function.,meta}
|
||||
|
||||
@complexity Constant.
|
||||
|
||||
@since 2.1.0
|
||||
*/
|
||||
static basic_json meta()
|
||||
{
|
||||
|
@ -8059,7 +8079,7 @@ class basic_json
|
|||
@liveexample{The following code exemplifies `type_name()` for all JSON
|
||||
types.,type_name}
|
||||
|
||||
@since version 1.0.0
|
||||
@since version 1.0.0, public since 2.1.0
|
||||
*/
|
||||
std::string type_name() const
|
||||
{
|
||||
|
|
|
@ -1105,6 +1105,26 @@ class basic_json
|
|||
|
||||
/*!
|
||||
@brief returns version information on the library
|
||||
|
||||
This function returns a JSON object with infiormation about the library,
|
||||
including the version number and information on the platform and compiler.
|
||||
|
||||
@return JSON object holding version information
|
||||
key | description
|
||||
----------- | ---------------
|
||||
`compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version).
|
||||
`copyright` | The copyright line for the library as string.
|
||||
`name` | The name of the library as string.
|
||||
`platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`.
|
||||
`url` | The URL of the project as string.
|
||||
`version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string).
|
||||
|
||||
@liveexample{The following code shows an example output of the `meta()`
|
||||
function.,meta}
|
||||
|
||||
@complexity Constant.
|
||||
|
||||
@since 2.1.0
|
||||
*/
|
||||
static basic_json meta()
|
||||
{
|
||||
|
@ -8059,7 +8079,7 @@ class basic_json
|
|||
@liveexample{The following code exemplifies `type_name()` for all JSON
|
||||
types.,type_name}
|
||||
|
||||
@since version 1.0.0
|
||||
@since version 1.0.0, public since 2.1.0
|
||||
*/
|
||||
std::string type_name() const
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue