XDGKit v1.0.0-1
C++ XDG Utilities
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
XDGINIView Class Reference

A parsed INI file using string view based maps. More...

#include <XDGINI.h>

+ Inheritance diagram for XDGINIView:

Public Member Functions

XDGINIViewoperator= (XDGINIView &&other) noexcept
 Move operator.
 
void clear () noexcept
 Clears the map values and backing storage if any.
 
const void * map () const noexcept
 Pointer to the temporary file map.
 
uint64_t mapSize () const noexcept
 Size in bytes of the temporary file map.
 

Static Public Member Functions

static std::shared_ptr< XDGINIViewLoadFile (const std::filesystem::path &iniFile) noexcept
 Loads and parses an INI file.
 
static std::shared_ptr< XDGINIViewFromData (char *data, size_t size) noexcept
 Creates an XDGINIView instance from serialized data.
 

Detailed Description

A parsed INI file using string view based maps.

The content is organized in nested unordered maps. The top-level map represents the sections, while the nested maps hold the key-value pairs within each section.

Unlike XDGINI, this class provides a memory view of data stored in a serialized format.

Member Function Documentation

◆ LoadFile()

std::shared_ptr< XDG::XDGINIView > LoadFile ( const std::filesystem::path &  iniFile)
staticnoexcept

Loads and parses an INI file.

The strings are stored in a mapped temporary file.

Parameters
iniFileThe path to the INI file to be loaded and parsed.
Returns
Always returns a valid pointer to an XDGINIView object. The returned pointer may reference an empty object if an error occurs.

◆ FromData()

std::shared_ptr< XDGINIView > FromData ( char *  data,
size_t  size 
)
staticnoexcept

Creates an XDGINIView instance from serialized data.

The data must remain immutable throughout the lifetime of the object as no copy is made.

Used internally for loading serialized index.theme maps from the cache.

Parameters
dataPointer to serialized data.
sizeSize of the data buffer (used for validation).
Returns
Always returns a valid pointer to an XDGINIView object. The returned pointer may reference an empty object if an error occurs.

◆ operator=()

XDGINIView & operator= ( XDGINIView &&  other)
inlinenoexcept

Move operator.

◆ clear()

void clear ( )
noexcept

Clears the map values and backing storage if any.

◆ map()

const void * map ( ) const
inlinenoexcept

Pointer to the temporary file map.

Returns
nullptr if there is no backing storage.

◆ mapSize()

uint64_t mapSize ( ) const
inlinenoexcept

Size in bytes of the temporary file map.

Returns
0 if there is no backing storage.