NAME
EDG::WP4::CCM::Path - Path class
SYNOPSIS
$path = EDG::WP4::CCM::Path->new("/hardware/memory/size");
print "$path"; # stringification
$path = $path->down($level);
$path = $path->up();
DESCRIPTION
Module provides implementation of the Path class. Class is used to manipulate absolute paths
Public methods
-
new ($path)
Create new
EDG::WP4::CCM::Pathinstance.If path argument is not specified, root path (
/) is used. Empty string is not allowed as an argument.path is a string representation of the path as defined in the NVA-API Specification document.
-
depth
Return the number of subpaths, starting from
/. -
get_last
Return last (safe unescaped) subpath or undef in case of
/. Thestrip_unescapeboolean is passed to_safe_unescape. -
toString
Get the (raw) string representation of path.
The
EDG::WP4::CCM::Pathinstances also support stringification (the_stringifymethod is used for that) and might create different result due tosafe_unescape. -
_boolean
bool overload:
Pathinstance is always true (avoids stringification on logic test) -
_stringify
Method for overloaded stringification.
This includes support for
safe_unescapeto wrap unescaped subpaths in{}. -
up
Removes last chunk of the path and returns it. If the path is already
/then the method raises an exception. -
down
Add
chunkto the path. The chunk can be compound path. (A leading/will be ignored). -
merge
Return a new instance with optional (list of) subpaths added.
-
parent
Return a new instance with parent path. Returns undef if current element is
/.
Public functions
-
unescape
Returns an unescaped version of the argument. This method is exported for use with all the components that deal with escaped keys.
-
escape
Returns an escaped version of the argument. This method is exported on demand for use with all tools that have to escape and unescape values.
-
path_split
Function to split a string in list of subpaths. Supports escaping of subpaths wrapped in
{...}. -
set_safe_unescape
Set the list of (parent) paths whose children are known to be escaped paths. (The list is set to all arguments passed, not appended to current safe_unescape list).
Paths can either be strings (an exact match will be used) or compiled regular expressions.
These child subpaths are safe to represent as their unescaped value wrapped in
{}when <toString> method is called (e.g. during stringification).Parent paths who have a safe-to escape parent path of their own should be added already escaped.
The list is stored in the
safe_unescapemodule variable and can emptied withreset_safe_unescapeexported functions.If no argument is passed, a predefined list of paths is used. The paths are known to be escaped in quattor profiles, e.g.
/software/components/metaconfig/services. (To reset the activesafe_unescapelist, usereset_safe_unescapefunction. -
reset_safe_unescape
Reset the
safe_unescapelist. -
_safe_unescape
Given path and
subpath, test is path is in@safe_unescapeand if it is, return unescaped subpath enclosed in{}(or not enclosed ifstrip_unescapeis true).If not, return unmodified subpath.