nomlib
Loading...
Searching...
No Matches
nom::SearchPath Class Reference

Determine the directory location to use based on search prefixes. More...

#include <SearchPath.hpp>

Public Types

typedef SearchPath self_type
typedef self_type * raw_ptr
typedef std::unique_ptr< self_type > unique_ptr
typedef std::shared_ptr< self_type > shared_ptr

Public Member Functions

 SearchPath ()
 Default constructor; initialize the parser to NULL.
 ~SearchPath ()
 Destructor.
const std::string & path ()
 Get the resolved path.
void set_deserializer (std::unique_ptr< IValueDeserializer > fp)
 Set a custom parser.
bool load_file (const std::string &filename, const std::string &node="resources")
 Parse a file into memory.

Private Attributes

std::unique_ptr< IValueDeserializerfp_
 Parser object to use.
std::vector< std::string > search_prefix_
 List of path prefixes to scan through with the given path.
std::string path_
 The resolved path.

Detailed Description

Determine the directory location to use based on search prefixes.

Todo
Add an interface for using this class without a file.

Definition at line 46 of file SearchPath.hpp.

Member Typedef Documentation

◆ raw_ptr

typedef self_type* nom::SearchPath::raw_ptr

Definition at line 51 of file SearchPath.hpp.

◆ self_type

typedef SearchPath nom::SearchPath::self_type

Definition at line 49 of file SearchPath.hpp.

◆ shared_ptr

typedef std::shared_ptr<self_type> nom::SearchPath::shared_ptr

Definition at line 53 of file SearchPath.hpp.

◆ unique_ptr

typedef std::unique_ptr<self_type> nom::SearchPath::unique_ptr

Definition at line 52 of file SearchPath.hpp.

Member Function Documentation

◆ load_file()

bool nom::SearchPath::load_file ( const std::string & filename,
const std::string & node = "resources" )

Parse a file into memory.

Parameters
filenameThe absolute file path.
nodeThe top-level object to use in formation of the path; defaults to an object member by name of "resources".
Remarks
The default parser is JSON, and can be changed using the ::set_deserializer method.

◆ set_deserializer()

void nom::SearchPath::set_deserializer ( std::unique_ptr< IValueDeserializer > fp)

Set a custom parser.

Remarks
The default parser is JSON.

Member Data Documentation

◆ fp_

std::unique_ptr<IValueDeserializer> nom::SearchPath::fp_
private

Parser object to use.

See also
nom::IValueDeserializer

Definition at line 83 of file SearchPath.hpp.

◆ path_

std::string nom::SearchPath::path_
private

The resolved path.

Definition at line 89 of file SearchPath.hpp.

◆ search_prefix_

std::vector<std::string> nom::SearchPath::search_prefix_
private

List of path prefixes to scan through with the given path.

Definition at line 86 of file SearchPath.hpp.


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