🚨 fix linter warnings

This commit is contained in:
Niels Lohmann 2021-11-05 14:48:28 +01:00
parent d54fd35355
commit 09da90eb76
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
16 changed files with 39 additions and 25 deletions

View File

@ -1,38 +1,38 @@
# basic_json::basic_json
```cpp
// 1
// (1)
basic_json(const value_t v);
// 2
// (2)
basic_json(std::nullptr_t = nullptr) noexcept;
// 3
// (3)
template<typename CompatibleType>
basic_json(CompatibleType&& val) noexcept(noexcept(
JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
std::forward<CompatibleType>(val))));
// 4
// (4)
template<typename BasicJsonType>
basic_json(const BasicJsonType& val);
// 5
// (5)
basic_json(initializer_list_t init,
bool type_deduction = true,
value_t manual_type = value_t::array);
// 6
// (6)
basic_json(size_type cnt, const basic_json& val);
// 7
// (7)
basic_json(iterator first, iterator last);
basic_json(const_iterator first, const_iterator last);
// 8
// (8)
basic_json(const basic_json& other);
// 9
// (9)
basic_json(basic_json&& other) noexcept;
```

View File

@ -6,7 +6,7 @@ template<typename KeyT>
bool contains(KeyT && key) const;
// (2)
bool contains(const json_pointer& ptr) const
bool contains(const json_pointer& ptr) const;
```
1. Check whether an element exists in a JSON object with key equivalent to `key`. If the element is not found or the

View File

@ -5,7 +5,7 @@ template<typename KeyT>
iterator find(KeyT&& key);
template<typename KeyT>
const_iterator find(KeyT&& key) const
const_iterator find(KeyT&& key) const;
```
Finds an element in a JSON object with key equivalent to `key`. If the element is not found or the JSON value is not an

View File

@ -4,7 +4,7 @@
template<typename ValueType>
ValueType& get_to(ValueType& v) const noexcept(
noexcept(JSONSerializer<ValueType>::from_json(
std::declval<const basic_json_t&>(), v)))
std::declval<const basic_json_t&>(), v)));
```
Explicit type conversion between the JSON value and a compatible value. The value is filled into the input parameter by

View File

@ -1,11 +1,9 @@
# basic_json::object_comparator_t
```cpp
// until C++14
using object_comparator_t = std::less<StringType>;
using object_comparator_t = std::less<StringType>; // until C++14
// since C++14
using object_comparator_t = std::less<>;
using object_comparator_t = std::less<>; // since C++14
```
The comparator used in [`object_t`](object_t.md).

View File

@ -1,7 +1,7 @@
# operator>>(basic_json)
```cpp
std::istream& operator>>(std::istream& i, basic_json& j)
std::istream& operator>>(std::istream& i, basic_json& j);
```
Deserializes an input stream to a JSON value.

View File

@ -1,7 +1,7 @@
# basic_json::operator""_json
```cpp
json operator "" _json(const char* s, std::size_t n)
json operator "" _json(const char* s, std::size_t n);
```
This operator implements a user-defined string literal for JSON objects. It can be used by adding `#!cpp _json` to a

View File

@ -1,7 +1,7 @@
# basic_json::operator""_json_pointer
```cpp
json_pointer operator "" _json_pointer(const char* s, std::size_t n)
json_pointer operator "" _json_pointer(const char* s, std::size_t n);
```
This operator implements a user-defined string literal for JSON Pointers. It can be used by adding `#!cpp _json_pointer`

View File

@ -1,7 +1,7 @@
# basic_json::operator<
```cpp
bool operator<(const_reference lhs, const_reference rhs) noexcept,
bool operator<(const_reference lhs, const_reference rhs) noexcept;
template<typename ScalarType>
bool operator<(const_reference lhs, const ScalarType rhs) noexcept;

View File

@ -1,7 +1,7 @@
# operator<<(basic_json)
```cpp
std::ostream& operator<<(std::ostream& o, const basic_json& j)
std::ostream& operator<<(std::ostream& o, const basic_json& j);
```
Serialize the given JSON value `j` to the output stream `o`. The JSON value will be serialized using the

View File

@ -2,7 +2,7 @@
```cpp
template <typename BasicJsonType>
std::string to_string(const BasicJsonType& j)
std::string to_string(const BasicJsonType& j);
```
This function implements a user-defined to_string for JSON objects.

View File

@ -1,7 +1,7 @@
# basic_json::~basic_json
```cpp
~basic_json() noexcept
~basic_json() noexcept;
```
Destroys the JSON value and frees all allocated memory.

View File

@ -2,7 +2,7 @@
```cpp
template<typename BinaryType>
class byte_container_with_subtype : public BinaryType
class byte_container_with_subtype : public BinaryType;
```
This type extends the template parameter `BinaryType` provided to [`basic_json`](../basic_json/index.md) with a subtype

View File

@ -1,7 +1,7 @@
# byte_container_with_subtype::set_subtype
```cpp
void set_subtype(subtype_type subtype) noexcept
void set_subtype(subtype_type subtype) noexcept;
```
Sets the binary subtype of the value, also flags a binary JSON value as having a subtype, which has implications for

View File

@ -11,6 +11,9 @@ A floating-point number was read.
`val` (in)
: floating-point value
`s` (in)
: string representation of the original input
## Return value
Whether parsing should proceed.

View File

@ -36,10 +36,12 @@ def check_structure():
with open(file) as file_content:
header_idx = -1
existing_headers = []
in_initial_code_example = False
for lineno, line in enumerate(file_content.readlines()):
line = line.strip()
# check if headers are correct
if line.startswith('## '):
header = line.strip('## ')
existing_headers.append(header)
@ -52,6 +54,17 @@ def check_structure():
else:
print(f'{file}:{lineno+1}: Error: header "{header}" is not part of the expected headers!')
# code example
if line == '```cpp' and header_idx == -1:
in_initial_code_example = True
if in_initial_code_example and line.startswith('//'):
if any(map(str.isdigit, line)) and '(' not in line:
print(f'{file}:{lineno+1}: Number should be in parentheses: {line}')
if line == '```' and in_initial_code_example:
in_initial_code_example = False
for required_header in required_headers:
if required_header not in existing_headers:
print(f'{file}:{lineno+1}: Error: required header "{required_header}" was not found!')