simdjson  3.11.0
Ridiculously Fast JSON
simdjson::dom::object::iterator Class Reference

Public Types

using value_type = const key_value_pair
 
using difference_type = std::ptrdiff_t
 
using pointer = void
 
using reference = value_type
 
using iterator_category = std::forward_iterator_tag
 

Public Member Functions

reference operator* () const noexcept
 Get the actual key/value pair.
 
iteratoroperator++ () noexcept
 Get the next key/value pair. More...
 
iterator operator++ (int) noexcept
 Get the next key/value pair. More...
 
bool operator!= (const iterator &other) const noexcept
 Check if these values come from the same place in the JSON. More...
 
bool operator== (const iterator &other) const noexcept
 
bool operator< (const iterator &other) const noexcept
 
bool operator<= (const iterator &other) const noexcept
 
bool operator>= (const iterator &other) const noexcept
 
bool operator> (const iterator &other) const noexcept
 
std::string_view key () const noexcept
 Get the key of this key/value pair.
 
uint32_t key_length () const noexcept
 Get the length (in bytes) of the key in this key/value pair. More...
 
bool key_equals (std::string_view o) const noexcept
 Returns true if the key in this key/value pair is equal to the provided string_view. More...
 
bool key_equals_case_insensitive (std::string_view o) const noexcept
 Returns true if the key in this key/value pair is equal to the provided string_view in a case-insensitive manner. More...
 
const char * key_c_str () const noexcept
 Get the key of this key/value pair.
 
element value () const noexcept
 Get the value of this key/value pair.
 
 iterator (const iterator &) noexcept=default
 
iteratoroperator= (const iterator &) noexcept=default
 

Detailed Description

Definition at line 19 of file object.h.

Member Function Documentation

◆ key_equals()

bool simdjson::dom::object::iterator::key_equals ( std::string_view  o) const
inlinenoexcept

Returns true if the key in this key/value pair is equal to the provided string_view.

Design notes: Instead of constructing a string_view and then comparing it with a user-provided strings, it is probably more performant to have dedicated functions taking as a parameter the string we want to compare against and return true when they are equal.

That avoids the creation of a temporary std::string_view. Though it is possible for the compiler to avoid entirely any overhead due to string_view, relying too much on compiler magic is problematic: compiler magic sometimes fail, and then what do you do? Also, enticing users to rely on high-performance function is probably better on the long run.

Definition at line 233 of file object-inl.h.

◆ key_equals_case_insensitive()

bool simdjson::dom::object::iterator::key_equals_case_insensitive ( std::string_view  o) const
inlinenoexcept

Returns true if the key in this key/value pair is equal to the provided string_view in a case-insensitive manner.

Case comparisons may only be handled correctly for ASCII strings.

Definition at line 244 of file object-inl.h.

◆ key_length()

uint32_t simdjson::dom::object::iterator::key_length ( ) const
inlinenoexcept

Get the length (in bytes) of the key in this key/value pair.

You should expect this function to be faster than key().size().

Definition at line 210 of file object-inl.h.

◆ operator!=()

bool simdjson::dom::object::iterator::operator!= ( const iterator other) const
inlinenoexcept

Check if these values come from the same place in the JSON.

Part of the std::iterator interface.

Definition at line 179 of file object-inl.h.

◆ operator++() [1/2]

object::iterator & simdjson::dom::object::iterator::operator++ ( )
inlinenoexcept

Get the next key/value pair.

Part of the std::iterator interface.

Definition at line 197 of file object-inl.h.

◆ operator++() [2/2]

object::iterator simdjson::dom::object::iterator::operator++ ( int  )
inlinenoexcept

Get the next key/value pair.

Part of the std::iterator interface.

Definition at line 202 of file object-inl.h.


The documentation for this class was generated from the following files: