NGen
Loading...
Searching...
No Matches
anonymous_namespace{Formulation_Manager.cpp} Namespace Reference

Classes

struct  DirectoryCloser
 Wrap closedir in a deleter to avoid GCC's ignored-attributes warning for decltype(&closedir) More...
 

Typedefs

using DirectoryPointer = std::unique_ptr<DIR, DirectoryCloser>
 A self-closing pointer to a directory that may be operated upon.
 
using PlaceholderContext = std::vector<std::pair<std::string, std::string>>
 A mapping of placeholder tokens to the values that should serve as their replacements.
 

Functions

bool is_regular_file_or_symlink_target (const std::string &path, const dirent *entry)
 Test to see if a directory entry at a path is either a regular file or a symlink that points at a file.
 
DirectoryPointer open_directory (const std::string &path, const unsigned int wait_seconds=2, const unsigned int maximum_attempts=5)
 Get a self-closing pointer to a directory.
 
std::pair< std::regex, std::string > create_file_pattern_matcher (std::string file_pattern, const PlaceholderContext &context)
 Replace all placeholders in a given file pattern with a supplied context and return a prepared regular expression paired with its pattern.
 

Typedef Documentation

◆ DirectoryPointer

using anonymous_namespace{Formulation_Manager.cpp}::DirectoryPointer = std::unique_ptr<DIR, DirectoryCloser>

A self-closing pointer to a directory that may be operated upon.

◆ PlaceholderContext

using anonymous_namespace{Formulation_Manager.cpp}::PlaceholderContext = std::vector<std::pair<std::string, std::string>>

A mapping of placeholder tokens to the values that should serve as their replacements.

Function Documentation

◆ create_file_pattern_matcher()

std::pair< std::regex, std::string > anonymous_namespace{Formulation_Manager.cpp}::create_file_pattern_matcher ( std::string file_pattern,
const PlaceholderContext & context )

Replace all placeholders in a given file pattern with a supplied context and return a prepared regular expression paired with its pattern.

TODO: Integrate with the path_tokens resolution functionality

Parameters
file_patternA configured pattern to match on when searching for a file
contextA set of placeholders and values that need to be inserted into the file pattern
Returns
A pairing of a prepared regular expression and its pattern

References create_file_pattern_matcher().

Referenced by create_file_pattern_matcher().

◆ is_regular_file_or_symlink_target()

bool anonymous_namespace{Formulation_Manager.cpp}::is_regular_file_or_symlink_target ( const std::string & path,
const dirent * entry )

Test to see if a directory entry at a path is either a regular file or a symlink that points at a file.

Parameters
pathThe path to the directory containing the entry of interest
entryThe loaded/assigned directory entry
Returns
Whether the received entry is a regular file or a link to a regular file
Exceptions
std::invalid_argumentif a null directory entry was passed
std::runtime_errorif the file could not be called with stat

References is_regular_file_or_symlink_target().

Referenced by is_regular_file_or_symlink_target().

◆ open_directory()

DirectoryPointer anonymous_namespace{Formulation_Manager.cpp}::open_directory ( const std::string & path,
const unsigned int wait_seconds = 2,
const unsigned int maximum_attempts = 5 )

Get a self-closing pointer to a directory.

See also
https://www.gnu.org/software/libc/manual/html_node/Opening-a-Directory.html#Opening-a-Directory
Note
: The following errors prevent any attempt to retry the opening process: ENOENT, ENXIO, EACCES, EPERM, ENOTDIR, EMFILE, ENFILE
Parameters
pathWhere to look for a directory to open
wait_secondsThe number of seconds to wait between attempts to open the directory. Must be 1 or greater
maximum_attemptsThe maximum number of times to get an open directory. Must be 1 or greater
Returns
A self-closing pointer to a directory handle
Exceptions
std::invalid_argumentif the wait_seconds is less than 1
std::invalid_argumentif the maximum_attempts is less than 1
std::runtime_errorif an error occurred while attempting to read the directory
std::runtime_errorif the maximum_attempts was reached before successfully connecting to the directory

References open_directory().

Referenced by open_directory().