TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ clear()

template<template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer, class BinaryType = std::vector<std::uint8_t>>
void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::clear ( )
inlinenoexcept

clears the contents

Clears the content of a JSON value and resets it to the default value as if basic_json(value_t) would have been called with the current value type from type():

Value type initial value
null null
boolean false
string ""
number 0
binary An empty byte vector
object {}
array []
Postcondition
Has the same effect as calling
*this = basic_json(type());
basic_json(const value_t v)
create an empty value with a given type
Definition: json.hpp:19164
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.hpp:20171

@liveexample{The example below shows the effect of clear() to different JSON types.,clear}

@complexity Linear in the size of the JSON value.

@iterators All iterators, pointers and references related to this container are invalidated.

@exceptionsafety No-throw guarantee: this function never throws exceptions.

See also
see basic_json(value_t) – constructor that creates an object with the same value than calling clear()
Since
version 1.0.0

Definition at line 23069 of file json.hpp.

23070 {
23071 switch (m_type)
23072 {
23074 {
23075 m_value.number_integer = 0;
23076 break;
23077 }
23078
23080 {
23081 m_value.number_unsigned = 0;
23082 break;
23083 }
23084
23086 {
23087 m_value.number_float = 0.0;
23088 break;
23089 }
23090
23091 case value_t::boolean:
23092 {
23093 m_value.boolean = false;
23094 break;
23095 }
23096
23097 case value_t::string:
23098 {
23099 m_value.string->clear();
23100 break;
23101 }
23102
23103 case value_t::binary:
23104 {
23105 m_value.binary->clear();
23106 break;
23107 }
23108
23109 case value_t::array:
23110 {
23111 m_value.array->clear();
23112 break;
23113 }
23114
23115 case value_t::object:
23116 {
23117 m_value.object->clear();
23118 break;
23119 }
23120
23121 case value_t::null:
23122 case value_t::discarded:
23123 default:
23124 break;
23125 }
23126 }
json_value m_value
the value of the current element
Definition: json.hpp:24928
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)