Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
falbrechtskirchinger committed Aug 7, 2022
1 parent c0f161e commit c550d5b
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 24 deletions.
1 change: 1 addition & 0 deletions docs/docset/docSet.sql
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_NON_INTR
INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE', 'Macro', 'api/macros/nlohmann_json_namespace/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE_BEGIN', 'Macro', 'api/macros/nlohmann_json_namespace_begin/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE_END', 'Macro', 'api/macros/nlohmann_json_namespace_begin/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE_EXCLUDE_VERSION', 'Macro', 'api/macros/nlohmann_json_namespace_exclude_version/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_SERIALIZE_ENUM', 'Macro', 'api/macros/nlohmann_json_serialize_enum/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_VERSION_MAJOR', 'Macro', 'api/macros/nlohmann_json_version_major/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_VERSION_MINOR', 'Macro', 'api/macros/nlohmann_json_version_major/index.html');
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/nlohmann_json_namespace.output
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nlohmann::json_v3_11_1
nlohmann::nlohmann_json::v3_11_1
13 changes: 13 additions & 0 deletions docs/examples/nlohmann_json_namespace_exclude_version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>

#define NLOHMANN_JSON_NAMESPACE_EXCLUDE_VERSION 1
#include <nlohmann/json.hpp>

// macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal
#define Q(x) #x
#define QUOTE(x) Q(x)

int main()
{
std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nlohmann::nlohmann_json
5 changes: 4 additions & 1 deletion docs/mkdocs/docs/api/macros/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ header. See also the [macro overview page](../../features/macros.md).
## Library namespace

- [**NLOHMANN_JSON_NAMESPACE**](nlohmann_json_namespace.md) - full name of the `nlohmann` namespace
- [**NLOHMANN_JSON_NAMESPACE_BEGIN**<br>**NLOHMANN_JSON_NAMESPACE_END**](nlohmann_json_namespace_begin.md) - open and close the library namespace
- [**NLOHMANN_JSON_NAMESPACE_BEGIN**<br>**NLOHMANN_JSON_NAMESPACE_END**](nlohmann_json_namespace_begin.md) - open and
close the library namespace
- [**NLOHMANN_JSON_NAMESPACE_EXCLUDE_VERSION**](nlohmann_json_namespace_exclude_version.md) - disable the version
namespace

## Type conversions

Expand Down
23 changes: 14 additions & 9 deletions docs/mkdocs/docs/api/macros/nlohmann_json_namespace.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# NLOHMANN_JSON_NAMESPACE

```cpp
#define NLOHMANN_JSON_NAMESPACE
#define NLOHMANN_JSON_NAMESPACE /* value */
```
This macro evaluates to the full name of the `nlohmann` namespace, including the name of a versioned and ABI-tagged
inline namespace. Use this macro to unambiguously refer to the `nlohmann` namespace.
This macro evaluates to the full name of the `nlohmann` namespace.
## Default definition
The default value consists of a prefix, a version string, and optional ABI tags depending on whether ABI-affecting
macros are defined (e.g., [`JSON_DIAGNOSTICS`](json_diagnostics.md), and
[`JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON`](json_use_legacy_discarded_value_comparison.md)).
The default value consists of the root namespace, the tag namespace, and the version namespace.
When the macro is not defined, the library will define it to its default value.
- The root namespace is always `nlohmann`.
- The tag namespace starts with `nlohmann_json` and is optionally followed by a number of ABI tags according to the
value of these ABI-affecting macros in order:
- [`JSON_DIAGNOSTICS`](json_diagnostics.md) defined non-zero appends `_diag`.
- [`JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON`](json_use_legacy_discarded_value_comparison.md) defined non-zero
appends `_ldvcmp`.
When the macro is not defined, the library will define it to its default value. Overriding this value has no effect.
## Examples
??? example
The example shows how to use `NLOHMANN_JSON_NAMESPACE` instead of just `nlohmann`, as well as how to output the value
of `NLOHMANN_JSON_NAMESPACE`.

```cpp
--8<-- "examples/nlohmann_json_namespace.cpp"
```
Expand All @@ -35,7 +39,8 @@ When the macro is not defined, the library will define it to its default value.
## See also

- [`NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END`](nlohmann_json_namespace_begin.md)
- [`NLOHMANN_JSON_NAMESPACE_EXCLUDE_VERSION`](nlohmann_json_namespace_exclude_version.md)

## Version history

- Added in version 3.11.0.
- Added in version 3.11.0. Updated namespace layout in version 3.11.2.
38 changes: 25 additions & 13 deletions docs/mkdocs/docs/api/macros/nlohmann_json_namespace_begin.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
# NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END

```cpp
#define NLOHMANN_JSON_NAMESPACE_BEGIN // (1)
#define NLOHMANN_JSON_NAMESPACE_END // (2)
#define NLOHMANN_JSON_NAMESPACE_BEGIN /* value */ // (1)
#define NLOHMANN_JSON_NAMESPACE_END /* value */ // (2)
```
These macros can be used to open and close the `nlohmann` namespace. They include an inline namespace used to
differentiate symbols when linking multiple versions (including different ABI-affecting macros) of this library.
These macros can be used to open and close the `nlohmann` namespace. They include two inline namespaces used to
differentiate symbols when linking multiple versions (including different ABI-affecting macros) of this library. See
['NLOHMANN_JSON_NAMESPACE`](nlohmann_json_namespace.md) for a detailed explanation of the namespace layout.
1. Opens the namespace.
2. Closes the namespace.
## Default definition
The default definitions open and close the `nlohmann` as well as two inline namespaces. The tag namespace encodes the
state of ABI-affecting options ([`JSON_DIAGNOSTICS](json_diagnostics.md) and
[`JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON`](json_use_legacy_discarded_value_comparison.md)), and the version
namespace encodes the library version number. The version namespace can be disabled (see
[`NLOHMANN_JSON_NAMESPACE_EXCLUDE_VERSION`](nlohmann_json_namespace_exclude_version.md)).
1. Default definition of `NLOHMANN_JSON_NAMESPACE_BEGIN`:
```cpp
namespace nlohmann
{
inline namespace json_v3_11_0
inline namespace nlohmann_json
{
inline namespace v3_11_2
{
```

2. Closes the namespace.
2. Default definition of `NLOHMANN_JSON_NAMESPACE_END`:
```cpp
} // namespace v3_11_2
} // namespace nlohmann_json
} // namespace nlohmann
} // json_v3_11_0
```

## Default definition

The default definitions open and close the `nlohmann` as well as an inline namespace.

When these macros are not defined, the library will define them to their default definitions.

## Examples

??? example

The example shows an example how to use `NLOHMANN_JSON_NAMESPACE_BEGIN`/`NLOHMANN_JSON_NAMESPACE_END` from the
The example shows how to use `NLOHMANN_JSON_NAMESPACE_BEGIN`/`NLOHMANN_JSON_NAMESPACE_END` from the
[How do I convert third-party types?](../../features/arbitrary_types.md#how-do-i-convert-third-party-types) page.

```cpp
Expand All @@ -51,4 +63,4 @@ When these macros are not defined, the library will define them to their default

## Version history

- Added in version 3.11.0.
- Added in version 3.11.0. Updated namespace layout in version 3.11.2.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# NLOHMANN_JSON_NAMESPACE

```cpp
#define NLOHMANN_JSON_NAMESPACE_EXCLUDE_VERSION /* value */
```
If defined to `1`, the version namespace is omitted. See [`NLOHMANN_JSON_NAMESPACE`](nlohmann_json_namespace.md) for
an explanation of the namespace layout.
## Default definition
The default value is `0`.
```cpp
#define NLOHMANN_JSON_NAMESPACE_EXCLUDE_VERSION 0
```

When the macro is not defined, the library will define it to its default value.

## Examples

??? example

The example shows how to use `NLOHMANN_JSON_NAMESPACE_EXCLUDE_VERSION` to disable the version namespace.

```cpp
--8<-- "examples/nlohmann_json_namespace_exclude_version.cpp"
```

Output:

```json
--8<-- "examples/nlohmann_json_namespace_exclude_version.output"
```

## See also

- [`NLOHMANN_JSON_NAMESPACE`](nlohmann_json_namespace.md)
- [`NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END`](nlohmann_json_namespace_begin.md)

## Version history

- Added in version 3.11.2.
1 change: 1 addition & 0 deletions docs/mkdocs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ nav:
- 'NLOHMANN_JSON_NAMESPACE': api/macros/nlohmann_json_namespace.md
- 'NLOHMANN_JSON_NAMESPACE_BEGIN': api/macros/nlohmann_json_namespace_begin.md
- 'NLOHMANN_JSON_NAMESPACE_END': api/macros/nlohmann_json_namespace_begin.md
- 'NLOHMANN_JSON_NAMESPACE_EXCLUDE_VERSION': api/macros/nlohmann_json_namespace_exclude_version.md
- 'NLOHMANN_JSON_SERIALIZE_ENUM': api/macros/nlohmann_json_serialize_enum.md
- 'NLOHMANN_JSON_VERSION_MAJOR': api/macros/nlohmann_json_version_major.md
- 'NLOHMANN_JSON_VERSION_MINOR': api/macros/nlohmann_json_version_major.md
Expand Down

0 comments on commit c550d5b

Please sign in to comment.