Robotran C Documentation
Macros | Functions
mbs_xml_binder.c File Reference
#include "mbs_binder_public.h"
#include "mbs_load_struct.h"
#include "mbs_path.h"
#include "mbs_saver.h"
#include "mbs_xml_binder_private.h"
#include "mbs_define.h"
#include "mbs_errors_names.h"
#include "mbs_binder_private.h"
#include <errno.h>
#include <float.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include "mbs_message.h"

Macros

#define MSG_ERR   ">> XML>> "
 
#define MSG_PRE   " >> "
 

Functions

int get_int_xlm_node (xmlNodePtr in_node)
 GET functions ///////////////////////. More...
 
int get_int_xlm_attr (xmlAttrPtr in_node)
 
double get_double_xlm_node (xmlNodePtr in_node)
 
int get_string_xml_node (xmlNodePtr in_node, char **dest)
 
int get_string_xml_attr (xmlAttrPtr in_node, char **dest)
 
int get_string_xml_node_2 (char **string_ptr, xmlNodePtr in_node)
 
int set_double_xlm_node (xmlNodePtr in_node, double value)
 SET functions ///////////////////////. More...
 
int set_char_xlm_node (xmlNodePtr in_node, const char *text)
 
int compare_char_xml_node (xmlNodePtr in_node, const char *text)
 COMPARE functions ///////////////////. More...
 
xmlNodePtr new_double_xlm_node (xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content, double value)
 Creation functions //////////////////. More...
 
xmlNodePtr new_char_xlm_node (xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content, const char *text)
 
xmlNodePtr mbs_xmlNewDocNode_xyz (xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content, double value)
 
xmlNodePtr mbs_xmlNewDocNode_attr_rgb (xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content, char *R, char *G, char *B)
 
int cmp_string_xml_attr (xmlAttrPtr in_node, const char *string)
 other functions ///////////////////// More...
 
xmlNodePtr find_xmlNodePtr (xmlNodePtr node, char *name)
 
xmlNodePtr mbs_info_find_children_xml (xmlNodePtr node, const char *name)
 Return the children whose name matches. More...
 
xmlNodePtr get_basebody_node (xmlDocPtr doc)
 Look for the base node in the document. More...
 
xmlNodePtr get_bodytree_node (xmlDocPtr doc)
 Look for the bodytree node in the document. More...
 
xmlNodePtr get_body_node (xmlNodePtr bodytree, const char *body_name)
 Look for the specified body node in the tree. More...
 
xmlNodePtr get_basebody_3Dshapes (xmlDocPtr doc, int create)
 Look for the node containing the 3D shape (x3D) of the base node. More...
 
xmlNodePtr get_point_node (xmlNodePtr body_node, const char *point_name, int allow_new, double coords_2d[2])
 Look for the specified point node in the body or base node. More...
 
xmlNodePtr get_body_3Dshapes (xmlDocPtr doc, const char *body_name)
 Look for the node containing the 3D shape (x3D) of the specified body. More...
 
xmlNodePtr create_shape (xmlNodePtr parent_node, const char *shape_name, char *shape_nature)
 
xmlNodePtr get_inline_shape (xmlNodePtr shape3D_node, const char *shape_name, int allow_creation)
 Look for the specified inline shape. More...
 
xmlNodePtr get_base_shape (xmlNodePtr shape3D_node, const char *shape_name, int nature, int allow_creation)
 Look for the specified basic shape. More...
 
xmlNodePtr get_basebody_point (xmlDocPtr doc, const char *point_name, int allow_new)
 Look for the specified point node on the base. More...
 
xmlNodePtr get_body_point (xmlDocPtr doc, const char *body_name, const char *point_name, int allow_new)
 Look for the specified point node on the specified body. More...
 
xmlNodePtr get_links_node (xmlDocPtr doc, int create)
 Look for the node containing all the links. More...
 
int mbs_info_coordinates_xml_binder (double *coordinates_pointer, xmlNodePtr node, int mission)
 Binders /////////////////////////////. More...
 
int mbs_info_sensor_xml_binder (MbsInfoSensor *mbs_info_sensor, xmlNodePtr node, int mission)
 
int mbs_info_extforce_xml_binder (MbsInfoExtforce *mbs_info_extforce, xmlNodePtr node, int mission)
 
int mbs_info_joint_xml_binder (MbsInfoJoint *mbs_info_joint, xmlNodePtr node, int mission, int verbose)
 
int mbs_info_joint_list_xml_binder (MbsInfoJoint **joint_list, xmlNodePtr node, int mission, int verbose)
 
int mbs_info_point_xml_binder (MbsInfoPoint *mbs_info_point, xmlNodePtr node, int mission)
 
int mbs_info_point_list_xml_binder (MbsInfoPoint **point_list, xmlNodePtr node, int mission, char *body_name)
 
int mbs_info_ref_point_xml_binder (MbsInfoRefPoint *mbs_info_ref_point, xmlNodePtr node, int mission)
 
int mbs_info_base_xml_binder (MbsInfoBase *mbs_info_base, xmlNodePtr node, int mission)
 
int mbs_info_body_xml_binder (MbsInfoBody *mbs_info_body, xmlNodePtr node, int mission, int verbose)
 
int mbs_info_bodytree_xml_binder (MbsInfoBodytree *mbs_info_bodytree, xmlNodePtr node, int mission, int verbose)
 
int mbs_info_ball_xml_binder (MbsInfoBall *mbs_info_ball, xmlNodePtr node, int mission)
 
int mbs_info_rod_xml_binder (MbsInfoRod *mbs_info_rod, xmlNodePtr node, int mission)
 
int mbs_info_solid_xml_binder (MbsInfoSolid *mbs_info_solid, xmlNodePtr node, int mission)
 
int mbs_info_cuts_xml_binder (MbsInfoCuts *mbs_info_cuts, xmlNodePtr node, int mission)
 
int mbs_info_link_xml_binder (MbsInfoLink *mbs_info_link, xmlNodePtr node, int mission)
 
int mbs_info_links_xml_binder (MbsInfoLinks *mbs_info_links, xmlNodePtr node, int mission)
 
int mbs_info_parameter_xml_binder (MbsInfoParameter *mbs_info_parameter, xmlNodePtr node, int mission)
 
int mbs_info_user_model_xml_binder (MbsInfoUserModel *mbs_info_user_model, xmlNodePtr node, int mission)
 
int mbs_info_user_models_xml_binder (MbsInfoUserModels *mbs_info_user_models, xmlNodePtr node, int mission, int verbose)
 
int mbs_info_user_IO_xml_binder (MbsInfoUserIO *mbs_info_user_IO, xmlNodePtr node, int mission)
 
int mbs_info_user_IOs_xml_binder (MbsInfoUserIOs *mbs_info_user_IOs, xmlNodePtr node, int mission, int verbose)
 
int mbs_info_mbsDescR7_binder (MbsInfos *mbs_infos, xmlDocPtr doc, int mission)
 
xmlDocPtr mbs_xml_get_doc (const char *mbs_xml_name)
 Load an xml file to memory. More...
 
void * mbs_xml_free_clean (xmlDocPtr doc)
 Free the xml document and clean the xml library parser. More...
 
int mbs_xml_info_to_loader (MbsLoader *mbs_loader, const char *mbs_xml_name)
 Load and store the specified xml file into both MbsInfo and xmlDocPtr format. More...
 
int mbs_info_mbs_linker (MbsInfos *mbs_info, int mission)
 
int mbs_info_init_and_binderXML (MbsInfos *mbs_infos, const char *mbs_xml_name, int mission)
 
int mbs_info_update_inlines_xml (MbsLoader *mbs_loader, UpdateInline *up_in, int allow_new)
 Update, or create this inline and all next inlines in the linked list. More...
 
int mbs_info_update_shapes_xml (MbsLoader *mbs_loader, UpdateShape *up_in, int allow_new)
 Update, or create this 3D shape and all next 3D shapes in the linked list. More...
 
int mbs_info_update_extforces_xml (MbsLoader *mbs_loader, UpdateExtForces *frc, int allow_new)
 Update, or create this external force all next ExtFrc in the linked list. More...
 
int mbs_info_update_linkforce_xml (MbsLoader *mbs_loader, UpdateLinkForces *lnk, int allow_new)
 Update, or create the provided link force. More...
 

Macro Definition Documentation

◆ MSG_ERR

#define MSG_ERR   ">> XML>> "

◆ MSG_PRE

#define MSG_PRE   " >> "

Function Documentation

◆ cmp_string_xml_attr()

int cmp_string_xml_attr ( xmlAttrPtr  in_node,
const char *  string 
)

other functions /////////////////////

◆ compare_char_xml_node()

int compare_char_xml_node ( xmlNodePtr  in_node,
const char *  text 
)

COMPARE functions ///////////////////.

Compare the string in an XML node with a provided string.

Parameters
[in]in_nodeThe node whose content must be a string to be compared.
[in]textThe string to be compared with the node.
Returns
- Same string: 0;
  • Error (NULL pointer): MBS_INFO_FAILURE;
  • Different string: positive integer (>0);

◆ create_shape()

xmlNodePtr create_shape ( xmlNodePtr  parent_node,
const char *  shape_name,
char *  shape_nature 
)

◆ find_xmlNodePtr()

xmlNodePtr find_xmlNodePtr ( xmlNodePtr  node,
char *  name 
)

◆ get_base_shape()

xmlNodePtr get_base_shape ( xmlNodePtr  shape3D_node,
const char *  shape_name,
int  nature,
int  allow_creation 
)

Look for the specified basic shape.

Parameters
[in]shape3D_nodePointer to the "x3D" node of a body or the base.
[in]shape_nameName of the base shape to find.
[in]natureIdentifier of the base shape nature (SHAPE_BOX...).
[in]allow_creationCreate the shape node shape if not found in existing.
Returns
The specified shape node or NULL in case of error.

◆ get_basebody_3Dshapes()

xmlNodePtr get_basebody_3Dshapes ( xmlDocPtr  doc,
int  create 
)

Look for the node containing the 3D shape (x3D) of the base node.

Parameters
[in]docThe pointer to the xml document
[in]createIf false (0), it does not create missing "x3D" node. If True, missing "x3D" node will be created.
Returns
The "x3D" node of the base or NULL in case of error.

◆ get_basebody_node()

xmlNodePtr get_basebody_node ( xmlDocPtr  doc)

Look for the base node in the document.

Parameters
[in]docThe pointer to the xml document
Returns
The "base" node or NULL in case of error.

◆ get_basebody_point()

xmlNodePtr get_basebody_point ( xmlDocPtr  doc,
const char *  point_name,
int  allow_new 
)

Look for the specified point node on the base.

Parameters
[in]docThe pointer to the xml document.
[in]point_nameThe name of the point.
[in]allow_newAllow to create new items.
Returns
The specified point node on base or NULL in case of error.

◆ get_body_3Dshapes()

xmlNodePtr get_body_3Dshapes ( xmlDocPtr  doc,
const char *  body_name 
)

Look for the node containing the 3D shape (x3D) of the specified body.

Parameters
[in]docThe pointer to the xml document
[in]body_nameThe name of the body.
Returns
The "x3D" node of the specified body or NULL in case of error.

◆ get_body_node()

xmlNodePtr get_body_node ( xmlNodePtr  bodytree,
const char *  body_name 
)

Look for the specified body node in the tree.

Parameters
[in]bodytreeThe pointer to the bodytree node.
[in]body_nameThe name of the body.
Returns
The specified body node or NULL in case of error.

◆ get_body_point()

xmlNodePtr get_body_point ( xmlDocPtr  doc,
const char *  body_name,
const char *  point_name,
int  allow_new 
)

Look for the specified point node on the specified body.

Parameters
[in]docThe pointer to the xml document.
[in]body_nameThe name of the body.
[in]point_nameThe name of the point.
[in]allow_newAllow to create new items.
Returns
The specified point node on the body or NULL in case of error.

◆ get_bodytree_node()

xmlNodePtr get_bodytree_node ( xmlDocPtr  doc)

Look for the bodytree node in the document.

Parameters
[in]docThe pointer to the xml document
Returns
The "bodytree" node or NULL in case of error.

◆ get_double_xlm_node()

double get_double_xlm_node ( xmlNodePtr  in_node)

◆ get_inline_shape()

xmlNodePtr get_inline_shape ( xmlNodePtr  shape3D_node,
const char *  shape_name,
int  allow_creation 
)

Look for the specified inline shape.

Parameters
[in]shape3D_nodePointer to the "x3D" node of a body or the base.
[in]shape_nameName of the inline shape to find.
[in]allow_creationCreate the inline node shape if not found in existing.
Returns
The specified shape node or NULL in case of error.

◆ get_int_xlm_attr()

int get_int_xlm_attr ( xmlAttrPtr  in_node)

◆ get_int_xlm_node()

int get_int_xlm_node ( xmlNodePtr  in_node)

GET functions ///////////////////////.

◆ get_links_node()

xmlNodePtr get_links_node ( xmlDocPtr  doc,
int  create 
)

Look for the node containing all the links.

Parameters
docThe pointer to the xml document
createIf false (0), it does not create missing "links" node. If True, missing "links" node will be created.
Returns
The "links" node or NULL in case of error.

◆ get_point_node()

xmlNodePtr get_point_node ( xmlNodePtr  body_node,
const char *  point_name,
int  allow_new,
double  coords_2d[2] 
)

Look for the specified point node in the body or base node.

Parameters
[in]body_nodeThe pointer to the body or base node.
[in]point_nameThe name of the point.
[in]allow_newAllow to create new items.
[in]coords_2dIn case of new point creation, this set the [x, y] coordinates of the point. If NULL is provided, the default coordinates are [100, 100].
Returns
The specified point node or NULL in case of error.

◆ get_string_xml_attr()

int get_string_xml_attr ( xmlAttrPtr  in_node,
char **  dest 
)

◆ get_string_xml_node()

int get_string_xml_node ( xmlNodePtr  in_node,
char **  dest 
)

◆ get_string_xml_node_2()

int get_string_xml_node_2 ( char **  string_ptr,
xmlNodePtr  in_node 
)

◆ mbs_info_ball_xml_binder()

int mbs_info_ball_xml_binder ( MbsInfoBall mbs_info_ball,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_base_xml_binder()

int mbs_info_base_xml_binder ( MbsInfoBase mbs_info_base,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_body_xml_binder()

int mbs_info_body_xml_binder ( MbsInfoBody mbs_info_body,
xmlNodePtr  node,
int  mission,
int  verbose 
)

◆ mbs_info_bodytree_xml_binder()

int mbs_info_bodytree_xml_binder ( MbsInfoBodytree mbs_info_bodytree,
xmlNodePtr  node,
int  mission,
int  verbose 
)

◆ mbs_info_coordinates_xml_binder()

int mbs_info_coordinates_xml_binder ( double *  coordinates_pointer,
xmlNodePtr  node,
int  mission 
)

Binders /////////////////////////////.

◆ mbs_info_cuts_xml_binder()

int mbs_info_cuts_xml_binder ( MbsInfoCuts mbs_info_cuts,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_extforce_xml_binder()

int mbs_info_extforce_xml_binder ( MbsInfoExtforce mbs_info_extforce,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_find_children_xml()

xmlNodePtr mbs_info_find_children_xml ( xmlNodePtr  node,
const char *  name 
)

Return the children whose name matches.

Parameters
[in]nodeThe parent node.
[in]nameThe name of the required children.
Returns
The specified children or NULL in case of error (including not found).

◆ mbs_info_init_and_binderXML()

int mbs_info_init_and_binderXML ( MbsInfos mbs_infos,
const char *  mbs_xml_name,
int  mission 
)

◆ mbs_info_joint_list_xml_binder()

int mbs_info_joint_list_xml_binder ( MbsInfoJoint **  joint_list,
xmlNodePtr  node,
int  mission,
int  verbose 
)

◆ mbs_info_joint_xml_binder()

int mbs_info_joint_xml_binder ( MbsInfoJoint mbs_info_joint,
xmlNodePtr  node,
int  mission,
int  verbose 
)

◆ mbs_info_link_xml_binder()

int mbs_info_link_xml_binder ( MbsInfoLink mbs_info_link,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_links_xml_binder()

int mbs_info_links_xml_binder ( MbsInfoLinks mbs_info_links,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_mbs_linker()

int mbs_info_mbs_linker ( MbsInfos mbs_info,
int  mission 
)

◆ mbs_info_mbsDescR7_binder()

int mbs_info_mbsDescR7_binder ( MbsInfos mbs_infos,
xmlDocPtr  doc,
int  mission 
)

◆ mbs_info_parameter_xml_binder()

int mbs_info_parameter_xml_binder ( MbsInfoParameter mbs_info_parameter,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_point_list_xml_binder()

int mbs_info_point_list_xml_binder ( MbsInfoPoint **  point_list,
xmlNodePtr  node,
int  mission,
char *  body_name 
)

◆ mbs_info_point_xml_binder()

int mbs_info_point_xml_binder ( MbsInfoPoint mbs_info_point,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_ref_point_xml_binder()

int mbs_info_ref_point_xml_binder ( MbsInfoRefPoint mbs_info_ref_point,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_rod_xml_binder()

int mbs_info_rod_xml_binder ( MbsInfoRod mbs_info_rod,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_sensor_xml_binder()

int mbs_info_sensor_xml_binder ( MbsInfoSensor mbs_info_sensor,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_solid_xml_binder()

int mbs_info_solid_xml_binder ( MbsInfoSolid mbs_info_solid,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_update_extforces_xml()

int mbs_info_update_extforces_xml ( MbsLoader mbs_loader,
UpdateExtForces frc,
int  allow_new 
)

Update, or create this external force all next ExtFrc in the linked list.

The UpdateExtForces is a linked list, the function will parse all the UpdateExtForces::next items for updates until reaching the end of the list.

Parameters
[in,out]mbs_loaderThe MbsLoader that contains all informations.
[in]frcThe description of the external force(s).
[in]allow_newAllow to create new items.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE

◆ mbs_info_update_inlines_xml()

int mbs_info_update_inlines_xml ( MbsLoader mbs_loader,
UpdateInline up_in,
int  allow_creation 
)

Update, or create this inline and all next inlines in the linked list.

The UpdateInline is a linked list, the function will parse all the UpdateInline::next items for updates until reaching the end of the list.

Parameters
[in,out]mbs_loaderThe MbsLoader that contains all informations.
[in]up_inThe descriptions of the modification to set on the inline(s).
[in]allow_creationAllow to create the inline shape.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE

◆ mbs_info_update_linkforce_xml()

int mbs_info_update_linkforce_xml ( MbsLoader mbs_loader,
UpdateLinkForces lnk,
int  allow_new 
)

Update, or create the provided link force.

WARNING, in the opposite of other update function, this one only update the current provided link force and does not parse the linked list for other updates.

Parameters
[in,out]mbs_loaderThe MbsLoader that contains all informations.
[in]lnkThe description of the unique link force.
[in]allow_newAllow to create new items.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE

◆ mbs_info_update_shapes_xml()

int mbs_info_update_shapes_xml ( MbsLoader mbs_loader,
UpdateShape up_in,
int  allow_new 
)

Update, or create this 3D shape and all next 3D shapes in the linked list.

The UpdateShape is a linked list, the function will parse all the UpdateShape::next items for updates until reaching the end of the list.

Parameters
[in,out]mbs_loaderThe MbsLoader that contains all informations.
[in]up_inThe descriptions of the modification to set on the shape(s).
[in]allow_newAllow to create new items.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE

◆ mbs_info_user_IO_xml_binder()

int mbs_info_user_IO_xml_binder ( MbsInfoUserIO mbs_info_user_IO,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_user_IOs_xml_binder()

int mbs_info_user_IOs_xml_binder ( MbsInfoUserIOs mbs_info_user_IOs,
xmlNodePtr  node,
int  mission,
int  verbose 
)

◆ mbs_info_user_model_xml_binder()

int mbs_info_user_model_xml_binder ( MbsInfoUserModel mbs_info_user_model,
xmlNodePtr  node,
int  mission 
)

◆ mbs_info_user_models_xml_binder()

int mbs_info_user_models_xml_binder ( MbsInfoUserModels mbs_info_user_models,
xmlNodePtr  node,
int  mission,
int  verbose 
)

◆ mbs_xml_free_clean()

void* mbs_xml_free_clean ( xmlDocPtr  doc)

Free the xml document and clean the xml library parser.

Parameters
[out]docThe xml document to be freed.
Returns
NULL;

◆ mbs_xml_get_doc()

xmlDocPtr mbs_xml_get_doc ( const char *  mbs_xml_name)

Load an xml file to memory.

Parameters
[in]mbs_xml_nameThe filepath to the document to be loaded.
Returns
The structure of the loaded file, or NULL in case of error.

◆ mbs_xml_info_to_loader()

int mbs_xml_info_to_loader ( MbsLoader mbs_loader,
const char *  mbs_xml_name 
)

Load and store the specified xml file into both MbsInfo and xmlDocPtr format.

Parameters
[in,out]mbs_loaderThe MbsLoader that contains all informations.
[in]mbs_xml_nameThe filepathe to the mbs to be loaded.
Returns
MBS_INFO_SUCCESS for succes, other is error code.

◆ mbs_xmlNewDocNode_attr_rgb()

xmlNodePtr mbs_xmlNewDocNode_attr_rgb ( xmlDocPtr  doc,
xmlNsPtr  ns,
const xmlChar *  name,
const xmlChar *  content,
char *  R,
char *  G,
char *  B 
)

◆ mbs_xmlNewDocNode_xyz()

xmlNodePtr mbs_xmlNewDocNode_xyz ( xmlDocPtr  doc,
xmlNsPtr  ns,
const xmlChar *  name,
const xmlChar *  content,
double  value 
)

◆ new_char_xlm_node()

xmlNodePtr new_char_xlm_node ( xmlDocPtr  doc,
xmlNsPtr  ns,
const xmlChar *  name,
const xmlChar *  content,
const char *  text 
)

◆ new_double_xlm_node()

xmlNodePtr new_double_xlm_node ( xmlDocPtr  doc,
xmlNsPtr  ns,
const xmlChar *  name,
const xmlChar *  content,
double  value 
)

Creation functions //////////////////.

◆ set_char_xlm_node()

int set_char_xlm_node ( xmlNodePtr  in_node,
const char *  text 
)

◆ set_double_xlm_node()

int set_double_xlm_node ( xmlNodePtr  in_node,
double  value 
)

SET functions ///////////////////////.