diff --git a/doc/examples/meta.cpp b/doc/examples/meta.cpp new file mode 100644 index 000000000..3a31ca24b --- /dev/null +++ b/doc/examples/meta.cpp @@ -0,0 +1,9 @@ +#include + +using json = nlohmann::json; + +int main() +{ + // call meta() + std::cout << std::setw(4) << json::meta() << '\n'; +} diff --git a/doc/examples/meta.link b/doc/examples/meta.link new file mode 100644 index 000000000..6a5ad0c19 --- /dev/null +++ b/doc/examples/meta.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/meta.output b/doc/examples/meta.output new file mode 100644 index 000000000..f361bb60e --- /dev/null +++ b/doc/examples/meta.output @@ -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" + } +} diff --git a/src/json.hpp b/src/json.hpp index da700f644..5fdd83d6e 100644 --- a/src/json.hpp +++ b/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 { diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 3f9c04f3a..068b87630 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -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 {