CHashManipulator

April 3, 2025 ยท View on GitHub

CHashManipulator is a C single file library designed for data manipulation and validation. It provides functionalities for creating and manipulating arrays and objects, handling JSON data, and performing explicit validations. The library is lightweight, and aims to ensure data integrity through its validation mechanisms.

Releases

ItemDescription
CHashManipulatorOne.cCHashManipulato One file
CHashManipulator.cDefinition
CHashManipulator.hHeader
CHashManipulator.zipFull Folder that can be included with src/one.c

Basic Example

#include "CHashManipulatorOne.c"

CHashNamespace hash;
int main() {
    hash = newCHashNamespace();
    CHashObjectModule obj = hash.object;
    CHashArrayModule array = hash.array;

    CHash *person = newCHashObject("name", hash.newString("John"), "age", hash.newNumber(30));

    CHash_protected(person) {
        printf("Name: %s\n", obj.getString(person, "name"));
        printf("Age: %ld\n", (long)obj.getNumber(person, "age"));
    }

    CHash_catch(person) {
        printf("Error: %s\n", hash.get_error_menssage(person));
    }

    hash.free(person);
    return 0;
}

Documentation

ItemDescription
build_and_install.mdInstructions for installing and compiling the library on Linux, Windows, and building from scratch on Darwin.
array_creation.mdFunction to create an array.
array_append.mdMethod to append elements to an array.
array_delete.mdMethod to delete elements from an array.
array_iteration.mdMethod to iterate over array elements.
array_set.mdMethod to set values in an array.
object_creation.mdFunction to create an object.
object_iteration.mdMethod to iterate over object keys and values.
object_set_values.mdMethod to set values in an object.
object_check_existence.mdMethod to check for key existence.
object_set_default.mdMethod to set default values for keys.
object_delete_key.mdMethod to delete keys from an object.
validation.mdFunctions for data validation, error raising, and custom error creation.
Boolean_Conversion.mdConverts values to boolean.
Number_Conversion.mdConverts values to numbers.
introduction.mdOverview of explicit validation techniques.
incorrect_age.mdExample of incorrect age validation.
incorrect_size.mdExample of incorrect size validation.
custom_error.mdExample of custom error creation.
raising_by_index.mdExample of raising errors by index.
raising_by_key.mdExample of raising errors by key.
raising_error.mdExample of raising errors.
correct_validation.mdExample of correct validation.
foreach_with_args.mdExample of foreach with arguments.
for_in.mdExample of for_in iteration.
foreach.mdExample of foreach iteration.
dumping_to_file.mdExample of dumping JSON to a file.
dumping_to_string.mdExample of dumping JSON to a string.
loading_from_file.mdExample of loading JSON from a file.
loading_from_string.mdExample of loading JSON from a string.
handling_errors.mdExample of handling JSON errors.
dependencies.mdList of dependencies for the library.