@brief checks whether the container is empty. @sa https://json.nlohmann.me/api/basic_json/empty/
| 2933 | /// @brief checks whether the container is empty. |
| 2934 | /// @sa https://json.nlohmann.me/api/basic_json/empty/ |
| 2935 | bool empty() const noexcept |
| 2936 | { |
| 2937 | switch (m_data.m_type) |
| 2938 | { |
| 2939 | case value_t::null: |
| 2940 | { |
| 2941 | // null values are empty |
| 2942 | return true; |
| 2943 | } |
| 2944 | |
| 2945 | case value_t::array: |
| 2946 | { |
| 2947 | // delegate call to array_t::empty() |
| 2948 | return m_data.m_value.array->empty(); |
| 2949 | } |
| 2950 | |
| 2951 | case value_t::object: |
| 2952 | { |
| 2953 | // delegate call to object_t::empty() |
| 2954 | return m_data.m_value.object->empty(); |
| 2955 | } |
| 2956 | |
| 2957 | case value_t::string: |
| 2958 | case value_t::boolean: |
| 2959 | case value_t::number_integer: |
| 2960 | case value_t::number_unsigned: |
| 2961 | case value_t::number_float: |
| 2962 | case value_t::binary: |
| 2963 | case value_t::discarded: |
| 2964 | default: |
| 2965 | { |
| 2966 | // all other types are nonempty |
| 2967 | return false; |
| 2968 | } |
| 2969 | } |
| 2970 | } |
| 2971 | |
| 2972 | /// @brief returns the number of elements |
| 2973 | /// @sa https://json.nlohmann.me/api/basic_json/size/ |