PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
deckField.h File Reference
#include "util/io.h"
#include "util/json.h"
#include <algorithm>
#include <functional>
#include <optional>
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <vector>
Include dependency graph for deckField.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  inp::Field< Deck >
 One field of a deck, declared once. More...
 
struct  inp::Accepts< T >
 What a field accepts. More...
 
struct  inp::OneOf
 A quantity that can be given in more than one way. More...
 

Namespaces

namespace  inp
 Collection of methods and database related to input.
 

Functions

template<class T >
std::string inp::typeName ()
 Name of the type of a field, reported by the schema.
 
template<>
std::string inp::typeName< bool > ()
 Name of the type of a field, reported by the schema.
 
template<>
std::string inp::typeName< int > ()
 Name of the type of a field, reported by the schema.
 
template<>
std::string inp::typeName< std::size_t > ()
 Name of the type of a field, reported by the schema.
 
template<>
std::string inp::typeName< double > ()
 Name of the type of a field, reported by the schema.
 
template<>
std::string inp::typeName< std::string > ()
 Name of the type of a field, reported by the schema.
 
template<>
std::string inp::typeName< std::vector< double > > ()
 Name of the type of a field, reported by the schema.
 
template<>
std::string inp::typeName< std::vector< std::string > > ()
 Name of the type of a field, reported by the schema.
 
template<>
std::string inp::typeName< std::vector< std::size_t > > ()
 Name of the type of a field, reported by the schema.
 
template<class T >
void inp::printValue (std::ostringstream &oss, const T &v)
 Appends a value to a stream.
 
template<class T >
void inp::printValue (std::ostringstream &oss, const std::vector< T > &v)
 Appends the entries of a vector, separated by commas.
 
template<class Deck , class T >
Field< Deck > inp::field (T Deck::*m, std::string key, T def, std::string doc, Accepts< T > accepts={}, std::function< bool(const T &)> emitIf=[](const T &) { return true;})
 Declares a field that maps one key to one member.
 
template<class Deck , class T >
Field< Deck > inp::requiredField (T Deck::*m, std::string key, std::string doc, Accepts< T > accepts={})
 Declares a field that has no default and must be present.
 
template<class Deck >
void inp::readFields (Deck &d, const json &j, const std::vector< Field< Deck > > &fs)
 Reads every field of the table from the block.
 
template<class Deck >
void inp::writeFields (const Deck &d, json &j, const std::vector< Field< Deck > > &fs)
 Writes every field of the table into the block.
 
template<class Deck >
void inp::printFields (const Deck &d, std::ostringstream &oss, const std::vector< Field< Deck > > &fs, const std::string &tab="")
 Appends every field of the table to a stream.
 
template<class Deck >
json inp::defaultsJson (const std::vector< Field< Deck > > &fs)
 The block with every field at its default.
 
template<class Deck >
json inp::schemaJson (const std::vector< Field< Deck > > &fs)
 Key, type, default and description of every field.
 
void inp::checkGroups (const json &block, const std::vector< OneOf > &groups)
 Checks that each group has exactly one of its keys.
 
std::size_t inp::editDistance (const std::string &a, const std::string &b)
 Number of single character edits between two strings.
 
void inp::checkNames (const json &given, const std::vector< std::string > &names)
 Rejects a key that is not among those named.
 
template<class Deck >
void inp::checkKeys (const json &given, const std::vector< Field< Deck > > &fs, const std::vector< std::string > &extra={})
 Rejects a key that no field declares.
 
template<class Deck >
json inp::applyGiven (const json &given, const std::vector< Field< Deck > > &fs, const std::vector< std::string > &extra={})
 The default block with the given keys replaced.