JDFTx  1.7.0
Input-file parser and commands

Files

file  command.h
 Provides the base class and various helpers for defining commands in the input file.
 
file  minimize.h
 Provides base class for defining the minimize commands.
 
file  ParamList.h
 Helper class for parsing command lines in input file.
 
file  parser.h
 Functions for parsing JDFTx input files.
 

Classes

class  Command
 Abstract base class for all commands. More...
 
class  DeprecatedCommand
 Base class for a deprecated command which will translate old syntax into the new command that replaces it. More...
 
struct  LinkDescription< Enum >
 Generate a description functor for addDescriptions() from an EnumStringMap. More...
 
struct  CommandMinimize
 Abstract base class for all the minimize commands. More...
 
class  ParamList
 Wrapper to std::istringstream that eases parsing of input file command lines. More...
 

Functions

std::map< string, Command * > & getCommandMap ()
 Retrieve the map from command names to objects created during static initialization.
 
std::map< string, DeprecatedCommand * > & getDeprecatedMap ()
 Retrieve the map from deprecated command names to objects.
 
template<typename GetDescription >
string addDescriptions (string optionList, const GetDescription &getDescription, string spacer="\n+ ")
 Process the EnumStringMap::optionList() to add descriptions using an arbitrary functor. More...
 
string nullDescription (const string &)
 Null description function that can be used with addDescriptions(). This can be useful for simply reformatting EnumStringMap::optionList()

 
template<typename Enum >
LinkDescription< Enum > linkDescription (const EnumStringMap< Enum > &nameMap, const EnumStringMap< Enum > &descMap)
 Helper function to select appropriate LinkDescription<> by overloading. More...
 
std::shared_ptr< class SpeciesInfofindSpecies (string id, Everything &e, bool addSpecies=false)
 Find species matching an id (and create it from a wildcard if necessary) More...
 
bool isReadable (string fname)
 Check if file is readable in an MPI friendly way. This function must be called from all processes, the file will be checked on one process and the result broadcast to all processes. More...
 
void setAvailableFilename (string filenamePattern, string varName, string &target)
 
void setAvailableFilenames (string filenamePattern, Everything &e)
 Apply setAvailableFilename for all standard input variables (action of CommandInitialState)
 
std::vector< std::pair< string, string > > readInputFile (string filename)
 Read input from file into an array of command/argument-list pairs. This routine handles comments, line continuation as well as environment substitution. In MPI mode, the input will be read only on head and distributed to all the processes. More...
 
void parse (std::vector< std::pair< string, string > > input, Everything &everything, bool printDefaults=false)
 Parse input and initialize everything. More...
 
void printDefaultTemplate (Everything &e)
 Output command documentation in the form of an input file template. This will output the comments for all the commands, along with the default command line, if any. More...
 
void writeCommandManual (Everything &e, string section)
 Output command docuemntation in Doxygen format which gets converted to the HTML and LaTeX manuals. More...
 

Detailed Description

Function Documentation

◆ addDescriptions()

template<typename GetDescription >
string addDescriptions ( string  optionList,
const GetDescription &  getDescription,
string  spacer = "\n+ " 
)

Process the EnumStringMap::optionList() to add descriptions using an arbitrary functor.

Template Parameters
GetDescriptionFunction/functor with the signature string GetDescription(const string&).
Parameters
optionListList of strings separated by pipe characters as returned by EnumStringMap::optionList()
getDescriptionA function/functor that returns the description given an option from optionList
spacerSpacer to insert before each option/description pair
Returns
string containing the options along with their descriptions

◆ findSpecies()

std::shared_ptr<class SpeciesInfo> findSpecies ( string  id,
Everything e,
bool  addSpecies = false 
)

Find species matching an id (and create it from a wildcard if necessary)

Parameters
idPsuedopotential species identifier string (typically chemical symbol)
eReference to Everything
addSpeciesWhether to add species from wildcards when trying to find id.
Returns
Smart pointer to SpeciesInfo corresponding to id.

◆ isReadable()

bool isReadable ( string  fname)

Check if file is readable in an MPI friendly way. This function must be called from all processes, the file will be checked on one process and the result broadcast to all processes.

Parameters
fnameFile name to check for
Returns
Whether file is readable

◆ linkDescription()

template<typename Enum >
LinkDescription<Enum> linkDescription ( const EnumStringMap< Enum > &  nameMap,
const EnumStringMap< Enum > &  descMap 
)

Helper function to select appropriate LinkDescription<> by overloading.

Template Parameters
EnumThe template parameter of EnumStringMap
Parameters
nameMapLink between enum members to corresponding name strings
descMapLink between enum members to corresponding description strings

◆ parse()

void parse ( std::vector< std::pair< string, string > >  input,
Everything everything,
bool  printDefaults = false 
)

Parse input and initialize everything.

Parameters
inputList o commands and arguments as obtained by readInputFile()
everythingReference to everything to initialize
printDefaultsIf true, print status of commands that were invoked by default in addition to those invoked manually

◆ printDefaultTemplate()

void printDefaultTemplate ( Everything e)

Output command documentation in the form of an input file template. This will output the comments for all the commands, along with the default command line, if any.

Parameters
eA reference to Everything

◆ readInputFile()

std::vector< std::pair<string,string> > readInputFile ( string  filename)

Read input from file into an array of command/argument-list pairs. This routine handles comments, line continuation as well as environment substitution. In MPI mode, the input will be read only on head and distributed to all the processes.

Parameters
filenameName of file to read, or empty for reading from stdin
Returns
Pairs of commands and their argument lists

◆ setAvailableFilename()

void setAvailableFilename ( string  filenamePattern,
string  varName,
string target 
)

Set target to the filename for reading variable varName from file with pattern specified by filenamePattern if that file exists and is readable

◆ writeCommandManual()

void writeCommandManual ( Everything e,
string  section 
)

Output command docuemntation in Doxygen format which gets converted to the HTML and LaTeX manuals.

Parameters
eA reference to Everything
sectionWhich executable to generate documentation for i.e. only include commands whose section matches this