<commit_before>#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "gotham_private.h"

void *
gotham_serialize_string_to_struct(const char *s,
                                  size_t len,
                                  Gotham_Deserialization_Function func)
{
   Azy_Content *ac;
   Eina_Bool r;
   Eina_Value *ev;
   void *data = NULL;

   ac = azy_content_new(NULL);
   EINA_SAFETY_ON_NULL_RETURN_VAL(ac, NULL);

   r = azy_content_deserialize_json(ac, s, len);
   EINA_SAFETY_ON_TRUE_GOTO(!r, free_ac);

   ev = azy_content_retval_get(ac);
   EINA_SAFETY_ON_NULL_GOTO(ev, free_ac);

   func(ev, &data);

free_ac:
   azy_content_free(ac);
   return data;
}

char *
gotham_serialize_struct_to_string(void *data,
                                  Gotham_Serialization_Function func)
{
   char *s;
   Eina_Value *ev = NULL;

   ev = func(data);

   s = azy_content_serialize_json(ev);
   eina_value_free(ev);
   EINA_SAFETY_ON_NULL_RETURN_VAL(s, NULL);

   return s;
}

void *
gotham_serialize_file_to_struct(const char *file,
                                Gotham_Deserialization_Function func)
{
   char *s;
   size_t l;

   s = gotham_utils_file_data_read(file, &l);
   EINA_SAFETY_ON_NULL_RETURN_VAL(s, NULL);

   return gotham_serialize_string_to_struct(s, l, func);
}
<commit_msg>serialize: Add missing @since<commit_after>#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "gotham_private.h"

/**
 * @since 1.3.0
 */
void *
gotham_serialize_string_to_struct(const char *s,
                                  size_t len,
                                  Gotham_Deserialization_Function func)
{
   Azy_Content *ac;
   Eina_Bool r;
   Eina_Value *ev;
   void *data = NULL;

   ac = azy_content_new(NULL);
   EINA_SAFETY_ON_NULL_RETURN_VAL(ac, NULL);

   r = azy_content_deserialize_json(ac, s, len);
   EINA_SAFETY_ON_TRUE_GOTO(!r, free_ac);

   ev = azy_content_retval_get(ac);
   EINA_SAFETY_ON_NULL_GOTO(ev, free_ac);

   func(ev, &data);

free_ac:
   azy_content_free(ac);
   return data;
}

/**
 * @since 1.3.0
 */
char *
gotham_serialize_struct_to_string(void *data,
                                  Gotham_Serialization_Function func)
{
   char *s;
   Eina_Value *ev = NULL;

   ev = func(data);

   s = azy_content_serialize_json(ev);
   eina_value_free(ev);
   EINA_SAFETY_ON_NULL_RETURN_VAL(s, NULL);

   return s;
}

/**
 * @since 1.3.0
 */
void *
gotham_serialize_file_to_struct(const char *file,
                                Gotham_Deserialization_Function func)
{
   char *s;
   size_t l;

   s = gotham_utils_file_data_read(file, &l);
   EINA_SAFETY_ON_NULL_RETURN_VAL(s, NULL);

   return gotham_serialize_string_to_struct(s, l, func);
}

/**
 * @since 1.3.0
 */
{'fraction_non_alphanumeric': 0.10214655810510732, 'fraction_numerical': 0.0044411547002220575, 'mean_word_length': 2.8836206896551726, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1045720', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1049, 'n_words': 175}