libamxd
6.4.1
Data Model Manager
|
Data model path helper functions. More...
Functions | |
amxd_status_t | amxd_path_init (amxd_path_t *path, const char *object_path) |
Initializes an amxd_path_t structure. More... | |
void | amxd_path_clean (amxd_path_t *path) |
Cleans an amxd_path_t structure. More... | |
amxd_status_t | amxd_path_new (amxd_path_t **path, const char *object_path) |
Allocates and initializes an amxd_path_t structure. More... | |
void | amxd_path_delete (amxd_path_t **path) |
Frees an allocated amxd_path_t structure. More... | |
void | amxd_path_reset (amxd_path_t *path) |
Resets the amxd_path_t structure. More... | |
amxd_status_t | amxd_path_vsetf (amxd_path_t *path, bool add_dot, const char *obj_path, va_list args) |
Sets or replaces the path contained in the amxd_path_t structure. More... | |
amxd_status_t | amxd_path_setf (amxd_path_t *path, bool add_dot, const char *obj_path,...) __attribute__((format(printf |
Sets or replaces the path contained in the amxd_path_t structure. More... | |
amxd_status_t amxd_status_t | amxd_path_append (amxd_path_t *path, const char *extension, bool add_dot) |
Appends a parameter name or object name/index to the path. More... | |
amxd_status_t | amxd_path_prepend (amxd_path_t *path, const char *extension) |
Prepends an object name/index to the path. More... | |
const char * | amxd_path_get (amxd_path_t *path, int flags) |
Returns the path stored in the amxd_path_t structure. More... | |
const char * | amxd_path_get_param (amxd_path_t *path) |
Gets the parameter name. More... | |
char * | amxd_path_get_first (amxd_path_t *path, bool remove) |
Gets the first part of the path. More... | |
char * | amxd_path_get_last (amxd_path_t *path, bool remove) |
Gets the last part of the path. More... | |
char * | amxd_path_get_fixed_part (amxd_path_t *path, bool remove) |
Gets the fixed part of the path. More... | |
char * | amxd_path_get_supported_path (amxd_path_t *path) |
Translates the path into a path that can be used to fetch the object definition. More... | |
char * | amxd_path_get_reference_part (amxd_path_t *path, bool remove) |
Returns the reference path. More... | |
uint32_t | amxd_path_get_reference_index (amxd_path_t *path) |
Returns the reference path index. More... | |
char * | amxd_path_build_supported_path (amxd_path_t *path) |
Creates the supported path representation of the given path. More... | |
uint32_t | amxd_path_get_depth (const amxd_path_t *const path) |
Calculates the depth of the path. More... | |
static amxd_path_type_t | amxd_path_get_type (amxd_path_t *path) |
Returns the path type. More... | |
static bool | amxd_path_is_valid (amxd_path_t *path) |
Checks if the path is valid path. More... | |
static bool | amxd_path_is_search_path (amxd_path_t *path) |
Checks if the path is a search path. More... | |
static bool | amxd_path_is_supported_path (amxd_path_t *path) |
Checks if the path is in the supported data model. More... | |
static bool | amxd_path_is_object_path (amxd_path_t *path) |
Checks if the path is an object path. More... | |
bool | amxd_path_is_instance_path (const amxd_path_t *const path) |
Checks if the path is in the instantiated data model. More... | |
char * | amxd_path_get_param_path (amxd_path_t *path) |
Get the full parameter path from the provided amxd_path_t struct. More... | |
Data model path helper functions.
These functions help in parsing data model paths.
Path Names are represented by a hierarchy of Objects (“parents”) and Sub-Objects (“children”), separated by the dot “.” character, ending with a Parameter if referencing a Parameter Path. There are six different types of Path Names used to address the data model:
Reference following.
The data model can contain parameters that contains reference paths to other objects in the data model. The Reference Following mechanism allows references to Objects (not Parameters) to be followed from inside a single Path Name. Reference Following is indicated by a “+” character after the Parameter Path, referencing the Object followed by a “.”, optionally followed by a Relative Object or Parameter Path that are children of the Referenced Object.
For example, "Device.NAT.PortMapping.{i}.Interface" references an IP Interface Object (Device.IP.Interface.{i}.) and that Object has a Parameter called “Name”. With Reference Following, a Path Name of "Device.NAT.PortMapping.1.Interface+.Name" references the “Name” Parameter of the Interface Object that the PortMapping is associated with (i.e. it is the equivalent of using Device.IP.Interface.1.Name as the Path Name).
amxd_status_t amxd_status_t amxd_path_append | ( | amxd_path_t * | path, |
const char * | extension, | ||
bool | add_dot | ||
) |
Appends a parameter name or object name/index to the path.
Adds a parameter name or object name, instance index, wildcard, search expression to the path contained in the amxd_path_t structure.
When add_dot is set to true, a dot is added if the extension doesn't end with a dot.
path | amxd_path_t struct containing a path |
extension | the string that must be added to the path |
add_dot | make sure the path ends with a dot, even if the extension doesn't contain a dot. |
Definition at line 441 of file amxd_path.c.
char* amxd_path_build_supported_path | ( | amxd_path_t * | path | ) |
Creates the supported path representation of the given path.
Replaces each index, wildcard or search string into '{i}' placeholder.
path | amxd_path_t struct containing a path |
Definition at line 699 of file amxd_path.c.
void amxd_path_clean | ( | amxd_path_t * | path | ) |
Cleans an amxd_path_t structure.
Frees all allocated memory and resets the amxd_path_t structure.
path | amxd_path_t struct containing a path |
Definition at line 351 of file amxd_path.c.
void amxd_path_delete | ( | amxd_path_t ** | path | ) |
Frees an allocated amxd_path_t structure.
After freeing the allocated memory, resets the amxd_path_t pointer to NULL.
path | amxd_path_t struct containing a path |
Definition at line 378 of file amxd_path.c.
const char* amxd_path_get | ( | amxd_path_t * | path, |
int | flags | ||
) |
Returns the path stored in the amxd_path_t structure.
Returns the object path as a string that is stored in the amxd_path_t structure.
When the amxd_path_t structure contains a parameter path, this function will only return the object path without the parameter name.
When the full parameter path is needed use amxd_path_get_param_path
path | amxd_path_t struct containing a path |
flags | bitmap of flags. Currently only AMXD_OBJECT_TERMINATE is supported. |
Definition at line 470 of file amxd_path.c.
uint32_t amxd_path_get_depth | ( | const amxd_path_t *const | path | ) |
Calculates the depth of the path.
Calculates the depth of the path. This is the depth of the hierarchy of the path in the data model. Each object in the hierarchy increases the depth, parameters are not counted as a depth.
path | amxd_path_t struct containing a path |
Definition at line 733 of file amxd_path.c.
char* amxd_path_get_first | ( | amxd_path_t * | path, |
bool | remove | ||
) |
Gets the first part of the path.
Gets the first part of the path, that is until the first dot encountered.
When remove is set to true, it is removed from the path contained in the amxd_path_t structure.
path | amxd_path_t struct containing a path |
remove | when set to true it is removed from the path contained in the structure. |
Definition at line 501 of file amxd_path.c.
char* amxd_path_get_fixed_part | ( | amxd_path_t * | path, |
bool | remove | ||
) |
Gets the fixed part of the path.
The fixed part of a path is the path starting from the beginning until a wildcard or seearch expression.
If the path doesn't contain a wildcard or search expression the full path is returned.
When remove is set to true, the fixed part is removed from the path.
path | amxd_path_t struct containing a path |
remove | when set to true it is removed from the path contained in the structure. |
Definition at line 576 of file amxd_path.c.
char* amxd_path_get_last | ( | amxd_path_t * | path, |
bool | remove | ||
) |
Gets the last part of the path.
Gets the last part of the path, that is the part in front of the last dot.
When remove is set to true, it is removed from the path contained in the amxd_path_t structure.
Parameter names are not returned by this function, use amxd_path_get_param to get the parameter name.
path | amxd_path_t struct containing a path |
remove | when set to true it is removed from the path contained in the structure. |
Definition at line 531 of file amxd_path.c.
const char* amxd_path_get_param | ( | amxd_path_t * | path | ) |
Gets the parameter name.
Gets the parameter name if the path is a parameter path. This function returns NULL if the path contained in the amxd_path_t structure is not a parameter path.
path | amxd_path_t struct containing a path |
Definition at line 497 of file amxd_path.c.
char* amxd_path_get_param_path | ( | amxd_path_t * | path | ) |
Get the full parameter path from the provided amxd_path_t struct.
path | amxd_path_t struct containing a parameter path |
Definition at line 787 of file amxd_path.c.
uint32_t amxd_path_get_reference_index | ( | amxd_path_t * | path | ) |
Returns the reference path index.
When the given path has reference following decorations, this function will return the index of the reference.
When the parameter that contains the reference is a comma separated list of references, the index is used to specify which item in the list must be used. The index starts with 1 for the first item in the list.
If no index is provided in the reference following decoration, the index returned is 1.
Example: When the path is "Device.NAT.PortMapping.1.Interface+#2.Name" this function returns 2
path | amxd_path_t struct containing a path |
Definition at line 689 of file amxd_path.c.
char* amxd_path_get_reference_part | ( | amxd_path_t * | path, |
bool | remove | ||
) |
Returns the reference path.
When the given path has reference following decorations, this function will return the reference path.
Example: When the path is "Device.NAT.PortMapping.1.Interface+.Name" this function returns the string "Device.NAT.PortMapping.1.Interface."
When remove is set to true the reference path is removed from the path contained in the amxd_path_t structure.
path | amxd_path_t struct containing a path |
remove | when set to true it is removed from the path contained in the structure. |
Definition at line 640 of file amxd_path.c.
char* amxd_path_get_supported_path | ( | amxd_path_t * | path | ) |
Translates the path into a path that can be used to fetch the object definition.
This function will remove the '{i}' placeholders or indices from the path contained in the amxd_path_t structure. This will result in an ambiorix data model object definition path.
The resulting path can be used to fetch the object definition.
path | amxd_path_t struct containing a path |
Definition at line 611 of file amxd_path.c.
|
inlinestatic |
Returns the path type.
See amxd_path_type_t for the supported path types.
path | amxd_path_t struct containing a path |
Definition at line 507 of file amxd_path.h.
amxd_status_t amxd_path_init | ( | amxd_path_t * | path, |
const char * | object_path | ||
) |
Initializes an amxd_path_t structure.
Initializes an amxd_path_t structure and sets the path.
If the given object path is invalid the structure will be initialized but an error is returned
path | amxd_path_t struct containing a path |
object_path | NULL or a valid path string |
Definition at line 328 of file amxd_path.c.
bool amxd_path_is_instance_path | ( | const amxd_path_t *const | path | ) |
Checks if the path is in the instantiated data model.
A path is in the instantiated data model if the path ends with an instance index, a wildcard or a search expression.
path | amxd_path_t struct containing a path |
Definition at line 753 of file amxd_path.c.
|
inlinestatic |
Checks if the path is an object path.
An object path is a path pointing to a singleton object or an instance object.
path | amxd_path_t struct containing a path |
Definition at line 579 of file amxd_path.h.
|
inlinestatic |
Checks if the path is a search path.
A search path is an object path containing a wildcard character ('*') or it contains search expressions (between '[' and ']')
path | amxd_path_t struct containing a path |
Definition at line 544 of file amxd_path.h.
|
inlinestatic |
Checks if the path is in the supported data model.
A path is an supported path if it contains '{i}' or it is pointing to a an object under a template object (not an instance of the template object).
path | amxd_path_t struct containing a path |
Definition at line 562 of file amxd_path.h.
|
inlinestatic |
Checks if the path is valid path.
Examples of invalid paths:
path | amxd_path_t struct containing a path |
Definition at line 526 of file amxd_path.h.
amxd_status_t amxd_path_new | ( | amxd_path_t ** | path, |
const char * | object_path | ||
) |
Allocates and initializes an amxd_path_t structure.
Allocates memory on the heap for the amxd_path_t structure and initializes it.
path | amxd_path_t struct containing a path |
object_path | NULL or a valid path string |
Definition at line 365 of file amxd_path.c.
amxd_status_t amxd_path_prepend | ( | amxd_path_t * | path, |
const char * | extension | ||
) |
Prepends an object name/index to the path.
Prepends the current path with an object name, instance index, wildcard, search expression to the path contained in the amxd_path_t structure.
The extension can not be a parameter name in this case, as a parameter name can only be added to the end of the path.
path | amxd_path_t struct containing a path |
extension | the string that must be prepended to the path |
Definition at line 456 of file amxd_path.c.
void amxd_path_reset | ( | amxd_path_t * | path | ) |
Resets the amxd_path_t structure.
path | amxd_path_t struct containing a path |
Definition at line 389 of file amxd_path.c.
amxd_status_t amxd_path_setf | ( | amxd_path_t * | path, |
bool | add_dot, | ||
const char * | obj_path, | ||
... | |||
) |
Sets or replaces the path contained in the amxd_path_t structure.
This function supports printf notations in the object path.
When the add_dot argument is set to true, a dot will be added to the end, if no dot at the end was present.
If the given path ends with a dot it will be an object path or an instance path. If the given path doesn't end with a dot it is a parameter path and the last part is the name of the parameter.
When an invalid object path is given, the function will return amxd_invalid_path and the type of the amxd_path_t will be set to amxd_path_invalid.
path | amxd_path_t struct containing a path |
add_dot | makes sure the path is ended with a dot when set to true |
obj_path | the object path that must be set in the amxd_path_t structure. printf like format string is supported. |
amxd_status_t amxd_path_vsetf | ( | amxd_path_t * | path, |
bool | add_dot, | ||
const char * | obj_path, | ||
va_list | args | ||
) |
Sets or replaces the path contained in the amxd_path_t structure.
This function does exactly the same as amxd_path_setf, but takes a va_list of values.
path | amxd_path_t struct containing a path |
add_dot | makes sure the path is ended with a dot when set to true |
obj_path | the object path that must be set in the amxd_path_t structure. printf like format string is supported. |
args | a va_list, containing the values for the printf formatting |
Definition at line 403 of file amxd_path.c.