nfx-serialization 0.3.0
Cross-platform C++ JSON serialization library with extensible trait capabilities
Loading...
Searching...
No Matches
nfx::serialization::json::Document::PathView Class Referencefinal

Path iterator for traversing all paths in a JSON document. More...

#include <nfx/serialization/json/Document.h>

Classes

struct  Entry
 Represents a single path entry in the document. More...
class  Iterator
 Forward iterator for path entries. More...

Public Types

enum class  Format : bool {
  JsonPointer = 0 ,
  DotNotation
}
 Format for path string representation. More...

Public Member Functions

 PathView (const Document &doc, Format format=Format::JsonPointer, bool includeContainers=true)
 Construct PathView for a document.
Iterator begin () const
 Get iterator to first entry.
Iterator end () const
 Get iterator past last entry.
size_t size () const
 Get number of path entries.
bool empty () const
 Check if empty.
const Entryoperator[] (size_t index) const
 Access entry by index.
std::vector< Entryleaves () const
 Get only leaf entries (primitives).

Detailed Description

Path iterator for traversing all paths in a JSON document.

Provides depth-first traversal of all JSON paths with their values. Supports both JSON Pointer format ("/user/name") and dot notation ("user.name").

Example usage:

for (const auto& entry : Document::PathView(doc)) {
std::cout << entry.path << " = " << entry.value().toString() << "\n";
}
Path iterator for traversing all paths in a JSON document.
Definition Document.h:1107

Definition at line 1106 of file Document.h.

Member Enumeration Documentation

◆ Format

Format for path string representation.

Enumerator
JsonPointer 

RFC 6901 JSON Pointer format (e.g., "/user/addresses/0/city").

DotNotation 

Dot notation format (e.g., "user.addresses[0].city").

Definition at line 1122 of file Document.h.

Constructor & Destructor Documentation

◆ PathView()

nfx::serialization::json::Document::PathView::PathView ( const Document & doc,
Format format = Format::JsonPointer,
bool includeContainers = true )
explicit

Construct PathView for a document.

Parameters
docDocument to iterate
formatPath format to use
includeContainersWhether to include object/array container paths

Example usage:

for (const auto& entry : Document::PathView(doc)) {
std::cout << entry.path << "\n";
}
Here is the call graph for this function:

Member Function Documentation

◆ begin()

Iterator nfx::serialization::json::Document::PathView::begin ( ) const
inline

Get iterator to first entry.

Returns
Iterator pointing to first path entry

Definition at line 1208 of file Document.h.

◆ empty()

bool nfx::serialization::json::Document::PathView::empty ( ) const
inline

Check if empty.

Returns
true if no entries

Definition at line 1230 of file Document.h.

◆ end()

Iterator nfx::serialization::json::Document::PathView::end ( ) const
inline

Get iterator past last entry.

Returns
Iterator representing end position

Definition at line 1214 of file Document.h.

◆ leaves()

std::vector< Entry > nfx::serialization::json::Document::PathView::leaves ( ) const

Get only leaf entries (primitives).

Returns
Vector of leaf entries

◆ operator[]()

const Entry & nfx::serialization::json::Document::PathView::operator[] ( size_t index) const
inline

Access entry by index.

Parameters
indexIndex of entry
Returns
Reference to entry at index

Definition at line 1237 of file Document.h.

◆ size()

size_t nfx::serialization::json::Document::PathView::size ( ) const
inline

Get number of path entries.

Returns
Number of entries

Definition at line 1224 of file Document.h.


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