OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
toml_to_json.hpp File Reference

Convert TOML data to nlohmann::json format. More...

#include <nlohmann/json.hpp>
#include <toml++/toml.hpp>
Include dependency graph for toml_to_json.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

nlohmann::json pfc::utils::toml_to_json (const toml::node &node_ref)
 Convert a TOML node to nlohmann::json.
 
nlohmann::json pfc::utils::toml_to_json (const toml::table &table)
 Convert a TOML table to nlohmann::json.
 
nlohmann::json pfc::utils::toml_to_json (const toml::node_view< const toml::node > &node_view)
 Convert a TOML node_view to nlohmann::json.
 

Detailed Description

Convert TOML data to nlohmann::json format.

This utility provides conversion from TOML format to JSON format, allowing TOML configuration files to be used with existing JSON parsing code.

Note
This is a zero-cost abstraction - TOML files are converted to JSON at load time, then all existing JSON parsing code works unchanged.

Function Documentation

◆ toml_to_json() [1/3]

nlohmann::json pfc::utils::toml_to_json ( const toml::node node_ref)
inline

Convert a TOML node to nlohmann::json.

Handles all TOML node types (table, array, string, integer, float, boolean, date, time, etc.) and converts them to appropriate JSON types.

Parameters
nodeTOML node to convert
Returns
JSON value representing the TOML node
Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_to_json() [2/3]

nlohmann::json pfc::utils::toml_to_json ( const toml::node_view< const toml::node > &  node_view)
inline

Convert a TOML node_view to nlohmann::json.

Overload for node_view (used when accessing array elements)

Parameters
node_viewTOML node_view to convert
Returns
JSON value representing the TOML node
Here is the call graph for this function:

◆ toml_to_json() [3/3]

nlohmann::json pfc::utils::toml_to_json ( const toml::table table)
inline

Convert a TOML table to nlohmann::json.

Recursively converts TOML data structures to JSON format, preserving all data types and structure.

Parameters
tableTOML table to convert
Returns
JSON object representing the TOML data
Here is the call graph for this function: