MLV_xml.h(3)

📦
version 3.1.0 · 2 versions
, in ubuntu jammy

💖 MLV_xml.h 💖

okay bestie, gather round, because this is the manual page for MLV_xml.h — straight out of the Library Functions Manual. it's giving "your fave library finally learned to read xml" and honestly? obsessed. let's get into it 🫶


✨ NAME ✨

MLV_xml.h — this file defines the prototypes of the functions that let you read xml files. that's the whole job description. iconic, concise, no notes 💅


🦋 SYNOPSIS 🦋

🎀 Définitions de type

  • typedef struct _MLV_Xml MLV_Xml — defines the data type that gets stored in xml format inside the MLV library. it's the lil container bestie, hold it close 🥺

🌸 Énumérations

  • enum MLV_Xml_error { MLV_XML_NONE, MLV_XML_THE_FIELD_DOESNT_EXIST, MLV_XML_THE_FIELD_IS_NOT_A_REAL, MLV_XML_THE_FIELD_IS_NOT_AN_INTEGER, MLV_XML_THE_FIELD_IS_TOO_BIG } — lists out all the different error codes you can bump into when the computer is reading an xml document. yes there are five. yes you will meet at least one of them 😭

⭐ Fonctions

  • MLV_Xml * MLV_load_xml (const char *xml_file_path) — loads an xml-format file into memory. main character behaviour tbh ✨
  • void MLV_free_xml (MLV_Xml *xml_data) — frees the memory used by the xml file's data. clean up after yourself, bestie 🧹
  • MLV_Xml_error MLV_get_string_value_from_xml (const MLV_Xml *xml_data, char **result, const char *xpath,...) — gives you access to the inside of a given field in the xml file. peek inside, it's allowed 👀
  • MLV_Xml_error MLV_get_integer_value_from_xml (const MLV_Xml *xml_data, int *result, const char *xpath,...) — grabs the integer from a given field of the xml file 🔢
  • MLV_Xml_error MLV_get_double_value_from_xml (const MLV_Xml *xml_data, double *result, const char *xpath,...) — grabs the real (double) from a given field of the xml file 💫
  • MLV_Xml_error MLV_get_float_value_from_xml (const MLV_Xml *xml_data, float *result, const char *xpath,...) — grabs the real (float) from a given field of the xml file 🌊
  • int MLV_get_number_of_objects_from_xml (const MLV_Xml *xml_data, const char *xpath,...) — counts how many objects in the xml file match a certain number of criteria passed as parameters to the function. math girlies rise 🧮
  • MLV_Xml * MLV_get_xml_object_of (const MLV_Xml *xml_data, const char *xpath,...) — lets you grab an internal node of the tree that represents the XML file. tree traversal era 🌳
  • void MLV_print_xml (const MLV_Xml *xml_data) — writes the contents of an xml file to the terminal. dump it right on the screen, no filter 💻

💜 Description détaillée 💜

This file defines the prototypes of the functions that let you read xml files. that's the mission statement, and she's serving it 🎀

🧚 Auteur

  • Adrien Boussicault
  • Marc Zipstein

Xml files are used to store the data a program needs in order to work. they let you change how a program runs without ever having to modify the program itself. and why is that possible? because they're readable by humans and by machines at the same time. so they're basically a super convenient interface between the computer and the user. it's giving bilingual queen, fluent in both 🌈✨


🌟 Documentation du type de l'énumération 🌟

🔥 enum MLV_Xml_error

Lists out all the different error codes you can run into when the computer is reading an xml document. lowkey a whole mood board of things going wrong 🙈

🌸 Valeurs énumérées

  • MLV_XML_NONE — no error detected. the dream. the fantasy. the peace we all deserve ✨
  • MLV_XML_THE_FIELD_DOESNT_EXIST — the field does not exist in the xml document. she's not there bestie, stop looking 💀
  • MLV_XML_THE_FIELD_IS_NOT_A_REAL — the field doesn't contain a character string that encodes a real. nope, that's not a real number 😭
  • MLV_XML_THE_FIELD_IS_NOT_AN_INTEGER — the field doesn't contain a character string that encodes an integer. same energy, different type 🙃
  • MLV_XML_THE_FIELD_IS_TOO_BIG — the string encodes a real/integer that's too long to be stored in the variable. it simply does not fit, the variable said no 🫣

🦄 Documentation des fonctions 🦄

💖 void MLV_free_xml (MLV_Xml * xml_data)

Frees the memory used by the xml file's data. be a responsible icon and release it 💅

Paramètres

  • xml_data — the xml data to delete.

Exemples

  • advanced/10_read_xml_file.c.

💖 MLV_Xml_error MLV_get_double_value_from_xml (const MLV_Xml * xml_data, double * result, const char * xpath, ...)

Lets you grab the real (double) from a given field of the xml file. just like the MLV_get_string_value_from_xml() function, this one can take a variable number of parameters. for more info, go read the documentation for the MLV_get_string_value_from_xml() function. it's the source of truth, fr fr 📚

Paramètres

  • xml_data — the xml data.
  • result — a pointer to a real in which the function's result will be stored.
  • xpath — the access path.

Renvoie

returns an error code (see MLV_Xml_error) if the function didn't manage to extract the desired data from the xml document. it tried, okay 😤

Exemples

  • advanced/10_read_xml_file.c.

💖 MLV_Xml_error MLV_get_float_value_from_xml (const MLV_Xml * xml_data, float * result, const char * xpath, ...)

Lets you grab the real (float) from a given field of the xml file. just like the MLV_get_string_value_from_xml() function, this one can take a variable number of parameters. for more info, go read the documentation for the MLV_get_string_value_from_xml() function. same deal, different precision 🎀

Paramètres

  • xml_data — the xml data.
  • result — a pointer to a real in which the function's result will be stored.
  • xpath — the access path.

Renvoie

returns an error code (see MLV_Xml_error) if the function didn't manage to extract the desired data from the xml document.


💖 MLV_Xml_error MLV_get_integer_value_from_xml (const MLV_Xml * xml_data, int * result, const char * xpath, ...)

Lets you grab the integer from a given field of the xml file. just like the MLV_get_string_value_from_xml() function, this one can take a variable number of parameters. for more info, go read the documentation for the MLV_get_string_value_from_xml() function. whole numbers only, bestie 🔢

Paramètres

  • xml_data — the xml data.
  • result — a pointer to an integer in which the function's result will be stored.
  • xpath — the access path.

Renvoie

returns an error code if the function didn't manage to extract the desired data from the xml document. (yeah the original has a lil typo in "reussie" here, we're keeping the meaning, not the typo police badge 🚓)

Exemples

  • advanced/10_read_xml_file.c.

💖 int MLV_get_number_of_objects_from_xml (const MLV_Xml * xml_data, const char * xpath, ...)

Counts how many objects in the xml file match a certain number of criteria passed as parameters to the function. she's doing a headcount, and she's thorough 🧮✨

Paramètres

  • xml_data — the xml data.
  • xpath — the access path.
  • ... — the function's parameters.

Renvoie

this function returns the number of objects whose access path is 'xpath'.

Exemples

  • advanced/10_read_xml_file.c.

💖 MLV_Xml_error MLV_get_string_value_from_xml (const MLV_Xml * xml_data, char ** result, const char * xpath, ...)

Lets you access the inside of a given field in the xml file. this function can take a variable number of parameters. just like with the printf function, the extra parameters — sitting after the xpath parameter — let you build advanced xpath queries. okay so this is the part where it gets fancy 👑

For example:

int id_batiment = 2;
char * type_salle = "informatique"
int id_salle = 4;
char* nom_salle;
MLV_get_string_value_from_xml(
        xml_data, &(nom_salle),
     "/batiment[%d]/salle[type=%s][%d]/nom",
     id_batiment, type_salle, id_salle
)
free( nom_salle ); // on oublie pas de libérer la mémoire après avoir
                   // utilisé nom_salle

this lets you grab the contents of the 'nom' field located in the 4th computer-science room of the 2nd building. yes she really just did all that with one call 🌟

Attention: don't forget to free the memory associated with the result field. seriously. free it. the leaks are not cute 💀

Paramètres

  • xml_data — the xml data.
  • result — a pointer to an empty address that will hold the address of the character string corresponding to the function's result.
  • xpath — the access path.

Renvoie

returns an error code if the function didn't manage to extract the desired data from the xml document.

Exemples

  • advanced/10_read_xml_file.c.

💖 MLV_Xml* MLV_get_xml_object_of (const MLV_Xml * xml_data, const char * xpath, ...)

Lets you grab an internal node of the tree that represents the XML file. this function is not implemented yet. she's announced but she hasn't shown up to the party 🫠

Paramètres

  • xml_data — the xml data.
  • xpath — the access path.
  • ... — the function's parameters.

Renvoie

an internal node of the XML tree.


💖 MLV_Xml* MLV_load_xml (const char * xml_file_path)

Loads an xml-format file into memory. this function returns NULL when the file couldn't be loaded correctly. so if you get NULL, that's your sign bestie 🚩

Paramètres

  • xml_file_path — access path of the xml file.

Renvoie

the xml file, read, parsed and loaded. she's ready ✨

Exemples

  • advanced/10_read_xml_file.c.

💖 void MLV_print_xml (const MLV_Xml * xml_data)

Writes the contents of an xml file to the terminal. this function is not implemented yet. same situation as before, future icon, currently ghosting us 🙈

Paramètres

  • xml_data — the xml data.
  • ... — the function's parameters.

🎀 Auteur 🎀

Generated automatically by Doxygen for MLV-3.1.0 from the source code. the robot wrote it, we just made it cute 🤖💖


and that's the whole page, bestie! this one came from MLV-3.1.0 and it was dated Samedi 29 Janvier 2022 — so yeah, vintage, but she aged like fine wine 🍷✨ mwah, take care of your xml, free your memory, and don't forget the free( nom_salle ). periodt. 💅🦋🌸

📦 where this page comes from