Skip to content

FileToml

A file handler for TOML files. Most funtionality is only provided for the C++ version as Julia already provides good tools handling TOML files.

Sources file_toml.hpp, file_toml.cpp


Constructors

FileToml(const char *filename);
FileToml(std::string filename);
FileToml(filename::String)
Name Description Default
filename filename of the TOML file

Methods

defined

Returns whether or not the TOML file has a certain key defined.

bool defined(FileToml const &fl, std::string key);

getindex / operator[] (C++ only)

Returns a handler to a value to be read from the TOML file.

io::FileTomlHandler operator[](std::string key);

Usage Example

auto fl = FileToml(XDIAG_DIRECTORY "/misc/data/toml/input.toml");
XDIAG_SHOW(defined(fl, "N"));

int N = fl["N"].as<int>();
int nup = fl["nup"].as<int>();
double J1 = fl["J1"].as<double>();
double J2 = fl["J2"].as<double>();

auto block = Spinhalf(N, nup);
auto H = OpSum();
for (int i=0; i<N; ++i){
  H += J1 * Op("SdotS", {i, (i+1)%N});
  H += J2 * Op("SdotS", {i, (i+2)%N});
}
double e0 = eigval0(H, block);
XDIAG_SHOW(e0);