ug4
|
Singleton which stores common paths and a stack of current paths. More...
#include <path_provider.h>
Static Public Member Functions | |
static void | clear_current_path_stack () |
clears the stack of current paths. This makes sense if an error was catched. More... | |
static const std::string & | get_current_path (PathTypes defPath=BIN_PATH) |
returns the current path More... | |
static bool | get_dirname_relative_to_current_path (const std::string &relativeDirname, std::string &absoluteDirname) |
static bool | get_dirname_relative_to_path (PathTypes pathType, const std::string &relativeDirname, std::string &absoluteDirname) |
static bool | get_filename_relative_to_current_path (const std::string &relativeFilename, std::string &absoluteFilename) |
static bool | get_filename_relative_to_path (PathTypes pathType, const std::string &relativeFilename, std::string &absoluteFilename) |
static const std::string & | get_path (PathTypes pathType) |
returns the path associated with the given constant. More... | |
static bool | has_current_path () |
returns true if a current path exists, false if not. More... | |
static bool | has_path (PathTypes pathType) |
returns true, if the path associated with the given constant exists. More... | |
static void | pop_current_path () |
pops a path from the stack of current paths More... | |
static void | push_current_path (const std::string &path) |
pushes a path to the stack of current paths More... | |
static void | set_path (PathTypes pathType, const std::string &path) |
sets the path for the given constant. More... | |
Private Member Functions | |
PathProvider () | |
PathProvider (const PathProvider &) | |
Static Private Member Functions | |
static PathProvider & | inst () |
Private Attributes | |
std::stack< std::string > | m_curPaths |
std::map< PathTypes, std::string > | m_map |
Singleton which stores common paths and a stack of current paths.
All paths are initially set to "".
Note that all public methods of PathProvider are static. That means you have to call them through the :: operator. E.g.
|
inlineprivate |
|
inlineprivate |
|
inlinestatic |
clears the stack of current paths. This makes sense if an error was catched.
References has_current_path(), and pop_current_path().
|
inlinestatic |
returns the current path
current paths are stored in a stack. The top of the stack is considered to be the most current path and is returned by this method.
defPath | (optional) If the stack is empty, the path associated with defPath is returned. By default defPath is set to BIN_PATH. |
References get_path(), inst(), and m_curPaths.
Referenced by get_dirname_relative_to_current_path(), and get_filename_relative_to_current_path().
|
inlinestatic |
relativeDirname | (in) relative directory name |
absoluteDirname | (out) absolute directory name |
References ug::DirectoryExists(), get_current_path(), ug::GetPathSeparator(), has_current_path(), and inst().
|
inlinestatic |
relativeDirname | (in) relative directory name |
absoluteDirname | (out) absolute directory name |
References ug::DirectoryExists(), get_path(), ug::GetPathSeparator(), has_path(), and inst().
|
inlinestatic |
relativeFilename | (in) relative filename |
absoluteFilename | (out) absolute filename |
References ug::FileExists(), get_current_path(), ug::GetPathSeparator(), has_current_path(), and inst().
|
inlinestatic |
relativeFilename | (in) relative filename |
absoluteFilename | (out) absolute filename |
References ug::FileExists(), get_path(), ug::GetPathSeparator(), has_path(), and inst().
|
inlinestatic |
returns the path associated with the given constant.
pathType | should be one of the constants enumerated in PathTypes or a used defined constant starting from MAX_PATH_CONSTANT + 1. |
Referenced by get_current_path(), get_dirname_relative_to_path(), get_filename_relative_to_path(), and ug::InitPaths().
|
inlinestatic |
returns true if a current path exists, false if not.
References inst(), and m_curPaths.
Referenced by clear_current_path_stack(), get_dirname_relative_to_current_path(), and get_filename_relative_to_current_path().
|
inlinestatic |
returns true, if the path associated with the given constant exists.
pathType | should be one of the constants enumerated in PathTypes or a used defined constant starting from MAX_PATH_CONSTANT + 1. |
Referenced by get_dirname_relative_to_path(), get_filename_relative_to_path(), and ug::InitPaths().
|
inlinestaticprivate |
|
inlinestatic |
pops a path from the stack of current paths
References inst(), and m_curPaths.
Referenced by clear_current_path_stack().
|
inlinestatic |
pushes a path to the stack of current paths
References inst(), and m_curPaths.
|
inlinestatic |
sets the path for the given constant.
pathType | should be one of the constants enumerated in PathTypes or a used defined constant starting from MAX_PATH_CONSTANT + 1. |
Referenced by ug::InitPaths(), Java_edu_gcsc_vrl_ug_UG__1ugInit(), ug::SetAppsPath(), ug::SetPluginPath(), ug::SetRootPath(), and ug::SetScriptPath().
|
private |
Referenced by get_current_path(), has_current_path(), pop_current_path(), and push_current_path().
|
private |
Referenced by get_path(), has_path(), and set_path().