<commit_before>.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at http://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2016 <NAME>
.\"
.Dd June 26, 2016
.Dt CTACHE_DATA 3
.Os
.Sh NAME
.Nm ctache_data_create ctache_data_create_hash ctache_data_create_array
.Nd create, maniipulate, and destroy ctache_data_t structures
.Sh LIBRARY
.Lb libctache
.Sh SYNOPSIS
.In ctache/ctache.h
.Ft ctache_data_t
.Fn ctache_data_create_hash
.Ft ctache_data_t
.Fo ctache_data_create_string
.Fa "char *str" "size_t len"
.Fc
.Ft ctache_data_t
.Fo *ctache_data_create_array
.Fa "size_t num_elements"
.Fc
.Ft void
.Fo ctache_data_hash_table_set
.Fa "ctache_data_t *data" "const char *key" "ctache_data_t *value"
.Fc
.Ft void
.Fo ctache_data_array_append
.Fa "ctache_data_t *data" "ctache_data_t *value"
.Fc
.Ft ctache_data_t
.Fo *ctache_data_merge_hashes
.Fa "ctache_data_t *first" "ctache_data_t *second"
.Fc
.Sh DESCRIPTION
Ctache uses a generic data format (the ctache_data_t) structure to contain
several different possible types of data (e.g. boolean, string, array, hash)
such that none of the templates require any logic. For example, if a section
tag (
.Qq {{#section}}
) corresponds to an array, the content of the section tag will be repeated,
once for each element in the array. If it is a hash, the hash will become the
new
.Qq context
for the rendering such. If the section tag corresponds to a boolean, the text
inside the section will not be rendered if the boolean value is false.
.Pp
Note that the ctache_data_t structure, while documented, is not meant to be
public and direct access by users is not supported. Its internal composition
is not guaranteed to stay the same between releases.
.Pp
The
.Fn ctache_create_hash
function will create a ctache_data_t that is a hash
table (maps string keys to ctache_data_t values). The
.Fn ctache_create_array
function will create an array of
.Fa num_elements
elements (or a sensible default
if 0 is passed) also of type ctache_data_t.
.Pp
The
.Fn ctache_data_hash_table_set
function is used to set a key/value pair in a ctache_data_t hash table. The
.Fa data
argument is the hash table into which to insert the key/value pair. The
.Fa key
argument is the string key and the
.Fa value
argument is the ctache_data_t value to set. The
.Fn ctache_data_array_append
function adds a ctache_data_t structure to the end of the array pointed to
by
.Fa data. 
The
.Fn ctache_data_merge_hashes
function is used to merge two ctache_data_t hash tables with non-overlapping
sets of keys.<commit_msg>Add ctache_data_length() to man page<commit_after>.\" This Source Code Form is subject to the terms of the Mozilla Public
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
.\" file, You can obtain one at http://mozilla.org/MPL/2.0/.
.\"
.\" Copyright (c) 2016 <NAME>
.\"
.Dd June 26, 2016
.Dt CTACHE_DATA 3
.Os
.Sh NAME
.Nm ctache_data_create ctache_data_create_hash ctache_data_create_array
.Nd create, maniipulate, and destroy ctache_data_t structures
.Sh LIBRARY
.Lb libctache
.Sh SYNOPSIS
.In ctache/ctache.h
.Ft ctache_data_t
.Fn ctache_data_create_hash
.Ft ctache_data_t
.Fo ctache_data_create_string
.Fa "char *str" "size_t len"
.Fc
.Ft ctache_data_t
.Fo *ctache_data_create_array
.Fa "size_t num_elements"
.Fc
.Ft void
.Fo ctache_data_hash_table_set
.Fa "ctache_data_t *data" "const char *key" "ctache_data_t *value"
.Fc
.Ft void
.Fo ctache_data_array_append
.Fa "ctache_data_t *data" "ctache_data_t *value"
.Fc
.Ft ctache_data_t
.Fo *ctache_data_merge_hashes
.Fa "ctache_data_t *first" "ctache_data_t *second"
.Fc
.Ft size_t
.Fo ctache_data_length
.Fa "ctache_data_t *data"
.Fc
.Sh DESCRIPTION
Ctache uses a generic data format (the ctache_data_t) structure to contain
several different possible types of data (e.g. boolean, string, array, hash)
such that none of the templates require any logic. For example, if a section
tag (
.Qq {{#section}}
) corresponds to an array, the content of the section tag will be repeated,
once for each element in the array. If it is a hash, the hash will become the
new
.Qq context
for the rendering such. If the section tag corresponds to a boolean, the text
inside the section will not be rendered if the boolean value is false.
.Pp
Note that the ctache_data_t structure, while documented, is not meant to be
public and direct access by users is not supported. Its internal composition
is not guaranteed to stay the same between releases.
.Pp
The
.Fn ctache_create_hash
function will create a ctache_data_t that is a hash
table (maps string keys to ctache_data_t values). The
.Fn ctache_create_array
function will create an array of
.Fa num_elements
elements (or a sensible default
if 0 is passed) also of type ctache_data_t.
.Pp
The
.Fn ctache_data_hash_table_set
function is used to set a key/value pair in a ctache_data_t hash table. The
.Fa data
argument is the hash table into which to insert the key/value pair. The
.Fa key
argument is the string key and the
.Fa value
argument is the ctache_data_t value to set. The
.Fn ctache_data_array_append
function adds a ctache_data_t structure to the end of the array pointed to
by
.Fa data. 
The
.Fn ctache_data_merge_hashes
function is used to merge two ctache_data_t hash tables with non-overlapping
sets of keys. The
.Fn ctache_data_length
function will return the "length" of particular data - e.g. array length.
{'fraction_non_alphanumeric': 0.06318480642804968, 'fraction_numerical': 0.005843681519357195, 'mean_word_length': 4.417408506429278, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3466543', 'n_tokens_mistral': 1979, 'n_tokens_neox': 1822, 'n_words': 803}