tetengo 1.8.2
A multipurpose library set
Loading...
Searching...
No Matches
storage.h File Reference

A storage. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
+ Include dependency graph for storage.h:

Go to the source code of this file.

Typedefs

typedef char path_character_type
 A path character type.
 

Functions

uint8_t tetengo_trie_storage_vacantCheckValue ()
 Returns the check value for a vacant element.
 
tetengo_trie_storage_t * tetengo_trie_storage_createStorage (const tetengo_trie_trie_t *p_trie)
 Creates a storage.
 
tetengo_trie_storage_t * tetengo_trie_storage_createMemoryStorage (const path_character_type *path)
 Creates a memory storage.
 
tetengo_trie_storage_t * tetengo_trie_storage_createSharedStorage (const path_character_type *path)
 Creates a shared storage.
 
tetengo_trie_storage_t * tetengo_trie_storage_createMmapStorage (const path_character_type *path, size_t content_offset)
 Creates an mmap storage.
 
void tetengo_trie_storage_destroy (const tetengo_trie_storage_t *p_storage)
 Destroys a storage.
 
size_t tetengo_trie_storage_baseCheckSize (const tetengo_trie_storage_t *p_storage)
 Returns the base-check size.
 
int32_t tetengo_trie_storage_baseAt (const tetengo_trie_storage_t *p_storage, size_t base_check_index)
 Returns the base value.
 
bool tetengo_trie_storage_setBaseAt (tetengo_trie_storage_t *p_storage, size_t base_check_index, int32_t base)
 Sets a base value.
 
uint8_t tetengo_trie_storage_checkAt (const tetengo_trie_storage_t *p_storage, size_t base_check_index)
 Returns the check value.
 
bool tetengo_trie_storage_setCheckAt (tetengo_trie_storage_t *p_storage, size_t base_check_index, uint8_t check)
 Sets a check value.
 
size_t tetengo_trie_storage_valueCount (const tetengo_trie_storage_t *p_storage)
 Returns the value count.
 
const void * tetengo_trie_storage_valueAt (const tetengo_trie_storage_t *p_storage, size_t value_index)
 Returns the value object.
 
bool tetengo_trie_storage_addValueAt (tetengo_trie_storage_t *p_storage, size_t value_index, const void *p_value, size_t value_size)
 Adds a value object.
 
double tetengo_trie_storage_fillingRate (const tetengo_trie_storage_t *p_storage)
 Returns the filling rate.
 
bool tetengo_trie_storage_serialize (const tetengo_trie_storage_t *p_storage, const path_character_type *path, size_t fixed_value_size)
 Serializes the storage.
 
tetengo_trie_storage_t * tetengo_trie_storage_clone (const tetengo_trie_storage_t *p_storage)
 Clones a storage.
 

Detailed Description

A storage.

Copyright (C) 2019-2024 kaoru https://www.tetengo.org/

Function Documentation

◆ tetengo_trie_storage_addValueAt()

bool tetengo_trie_storage_addValueAt ( tetengo_trie_storage_t * p_storage,
size_t value_index,
const void * p_value,
size_t value_size )

Adds a value object.

Parameters
p_storageA pointer to a storage.
value_indexA value index.
p_valueA pointer to a value object. Must not be NULL.
value_sizeA value size.
Return values
trueOn no error.
falseOtherwise.

◆ tetengo_trie_storage_baseAt()

int32_t tetengo_trie_storage_baseAt ( const tetengo_trie_storage_t * p_storage,
size_t base_check_index )

Returns the base value.

Parameters
p_storageA pointer to a storage.
base_check_indexA base-check index.
Returns
The base value. Or INT32_MAX on error.

◆ tetengo_trie_storage_baseCheckSize()

size_t tetengo_trie_storage_baseCheckSize ( const tetengo_trie_storage_t * p_storage)

Returns the base-check size.

Parameters
p_storageA pointer to a storage.
Returns
The base-check size. Or (size_t)-1 on error.

◆ tetengo_trie_storage_checkAt()

uint8_t tetengo_trie_storage_checkAt ( const tetengo_trie_storage_t * p_storage,
size_t base_check_index )

Returns the check value.

Parameters
p_storageA pointer to a storage.
base_check_indexA base-check index.
Returns
The check value. Or UINT8_MAX on error.

◆ tetengo_trie_storage_clone()

tetengo_trie_storage_t * tetengo_trie_storage_clone ( const tetengo_trie_storage_t * p_storage)

Clones a storage.

Parameters
p_storageA pointer to a storage.
Returns
A pointer to a clone of the storage. Or NULL on error.

◆ tetengo_trie_storage_createMemoryStorage()

tetengo_trie_storage_t * tetengo_trie_storage_createMemoryStorage ( const path_character_type * path)

Creates a memory storage.

Parameters
pathA file path in which content is stored.
Returns
A pointer to a memory storage. Or NULL when content cannot be loaded from the path.

◆ tetengo_trie_storage_createMmapStorage()

tetengo_trie_storage_t * tetengo_trie_storage_createMmapStorage ( const path_character_type * path,
size_t content_offset )

Creates an mmap storage.

Parameters
pathA file path in which content is stored.
content_offsetA content offset in the file of the path.
Returns
A pointer to an mmap storage. Or NULL when content cannot be loaded from the path, content_offset is greater than the file size, or the value size is not fixed.

◆ tetengo_trie_storage_createSharedStorage()

tetengo_trie_storage_t * tetengo_trie_storage_createSharedStorage ( const path_character_type * path)

Creates a shared storage.

Parameters
pathA file path in which content is stored.
Returns
A pointer to a shared storage. Or NULL when content cannot be loaded from the path.

◆ tetengo_trie_storage_createStorage()

tetengo_trie_storage_t * tetengo_trie_storage_createStorage ( const tetengo_trie_trie_t * p_trie)

Creates a storage.

Parameters
p_trieA pointer to a trie.
Returns
A pointer to a storage. Or NULL on error.

◆ tetengo_trie_storage_destroy()

void tetengo_trie_storage_destroy ( const tetengo_trie_storage_t * p_storage)

Destroys a storage.

Parameters
p_storageA pointer to a storage.

◆ tetengo_trie_storage_fillingRate()

double tetengo_trie_storage_fillingRate ( const tetengo_trie_storage_t * p_storage)

Returns the filling rate.

Parameters
p_storageA pointer to a storage.
Returns
The filling rate. Or NAN on error.

◆ tetengo_trie_storage_serialize()

bool tetengo_trie_storage_serialize ( const tetengo_trie_storage_t * p_storage,
const path_character_type * path,
size_t fixed_value_size )

Serializes the storage.

Parameters
p_storageA pointer to a storage.
pathA file path.
fixed_value_sizeThe value size if it is fixed. Or 0 if the size is variable.
Return values
trueOn no error.
falseOtherwise.

◆ tetengo_trie_storage_setBaseAt()

bool tetengo_trie_storage_setBaseAt ( tetengo_trie_storage_t * p_storage,
size_t base_check_index,
int32_t base )

Sets a base value.

Parameters
p_storageA pointer to a storage.
base_check_indexA base-check index.
baseA base value.
Return values
trueOn no error.
falseOtherwise.

◆ tetengo_trie_storage_setCheckAt()

bool tetengo_trie_storage_setCheckAt ( tetengo_trie_storage_t * p_storage,
size_t base_check_index,
uint8_t check )

Sets a check value.

Parameters
p_storageA pointer to a storage.
base_check_indexA base-check index.
checkA check value.
Return values
trueOn no error.
falseOtherwise.

◆ tetengo_trie_storage_vacantCheckValue()

uint8_t tetengo_trie_storage_vacantCheckValue ( )

Returns the check value for a vacant element.

Returns
The check value for a vacant element.

◆ tetengo_trie_storage_valueAt()

const void * tetengo_trie_storage_valueAt ( const tetengo_trie_storage_t * p_storage,
size_t value_index )

Returns the value object.

Parameters
p_storageA pointer to a storage.
value_indexA value index.
Returns
A pointer to the value object. Or NULL when there is no corresponding value object.

◆ tetengo_trie_storage_valueCount()

size_t tetengo_trie_storage_valueCount ( const tetengo_trie_storage_t * p_storage)

Returns the value count.

Parameters
p_storageA pointer to a storage.
Returns
The value count. Or (size_t)-1 on error.