$darkmode
utility.cpp File Reference
#include <fable/utility.hpp>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <iterator>
#include <stdexcept>
#include <fable/environment.hpp>
#include <fable/error.hpp>
Include dependency graph for utility.cpp:

Macros

#define PRETTY_PRINT_INDENT   " "
 

Functions

Json fable::read_json_from_file (const char *filepath)
 
Json fable::read_json_from_file (const std::string &filepath)
 
Json fable::read_json_from_stdin ()
 
Json fable::read_json (const std::string &filepath_or_stdin)
 
Json fable::read_json_with_interpolation (const std::string &filepath_or_stdin, const Environment *env=nullptr)
 
Conf fable::read_conf_from_file (const char *filepath)
 
Conf fable::read_conf_from_file (const std::string &filepath)
 
Conf fable::read_conf_from_stdin ()
 
Conf fable::read_conf (const std::string &filepath_or_stdin)
 
Conf fable::read_conf_with_interpolation (const std::string &filepath_or_stdin, const Environment *env=nullptr)
 
std::string fable::indent_string (std::string s, const std::string &indent=" ")
 
void fable::pretty_print (const ConfError &e, std::ostream &os)
 
void fable::pretty_print (const SchemaError &e, std::ostream &os)
 

Detailed Description

Function Documentation

◆ indent_string()

std::string fable::indent_string ( std::string  s,
const std::string &  indent = "    " 
)

Indent a string in its entirety by the value of indent.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_json_from_file()

Json fable::read_json_from_file ( const char *  filepath)

Read a file and parse the contents to JSON.

If the file does not exist, a std::runtime_error is thrown. If the JSON is malformed, a std::invalid_argument is thrown.

Here is the call graph for this function:
Here is the caller graph for this function: