DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
Loading...
Searching...
No Matches
CppUtils::Files::FileParser Class Reference

#include <fileParser.hpp>

Public Member Functions

 FileParser (const std::filesystem::path &fileName_) noexcept
 
std::filesystem::path getFileName () const noexcept
 
template<typename F, typename... TArgs>
constexpr decltype(auto) parseDataFile (F &&f_, TArgs &&... args_) const
 
void clearCache () noexcept
 

Private Member Functions

void readFileContent () const
 

Private Attributes

const std::filesystem::path fileName
 
std::string fileContentCache
 

Constructor & Destructor Documentation

◆ FileParser()

CppUtils::Files::FileParser::FileParser ( const std::filesystem::path & fileName_)
inlineexplicitnoexcept

References fileName.

Member Function Documentation

◆ readFileContent()

void CppUtils::Files::FileParser::readFileContent ( ) const
inlineprivate

A function to read the contents of a file and assign them to the appropriate cache.

Exceptions
CppUtils::Files::FileNotFoundIf the file isn't a regular file, we will throw an exception

References fileContentCache, and fileName.

Referenced by parseDataFile().

◆ getFileName()

std::filesystem::path CppUtils::Files::FileParser::getFileName ( ) const
inlinenoexcept

References fileName.

◆ parseDataFile()

template<typename F, typename... TArgs>
decltype(auto) CppUtils::Files::FileParser::parseDataFile ( F && f_,
TArgs &&... args_ ) const
inlineconstexpr

A wrapper to move the parsing of a given input file to the client.

Template Parameters
F- The type of the function we are calling
...TArgs- The types of the arguments passed to the function f
Parameters
f- The function to invoke
args- The parameters of the function we are invoking
Returns
Here we return whatever the function, f, returns even if that is a void function.
Warning
The function must take the file contents as a std::string by constant-reference in it's first argument. This requirement disqualifies all member functions but allows for a simpler syntax for those callable types we do support.

References fileContentCache, and readFileContent().

◆ clearCache()

void CppUtils::Files::FileParser::clearCache ( )
inlinenoexcept

References fileContentCache.

Member Data Documentation

◆ fileName

const std::filesystem::path CppUtils::Files::FileParser::fileName
private

◆ fileContentCache

std::string CppUtils::Files::FileParser::fileContentCache
mutableprivate

The documentation for this class was generated from the following file: