kv_system.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <alloca.h>

Description

This file contains commonly used types and some helpful macros.

Author
Scott Fazackerley, Eric Huang, Graeme Douglas
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1.Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2.Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3.Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file kv_system.h.

Include dependency graph for kv_system.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  ion_status_t
 A status object that describes the result of a dictionary operation. More...
 
struct  record_info
 Struct used to maintain information about size of key and value. More...
 
struct  ion_record
 Struct used to maintain key and value. More...
 

Macros

#define fremove(x)   remove(x)
 
#define frewind(x)   rewind(x)
 
#define fdeleteall()
 
#define ION_USING_MASTER_TABLE   1
 
#define ION_USING_ECLIPSE   0
 
#define ION_DEBUG   0
 
#define ION_IS_EQUAL   0
 
#define ION_IS_GREATER   1
 
#define ION_IS_LESS   -1
 
#define ION_ZERO   0
 
#define ION_RETURN_VALUE   0x73/* Magic default return value to be easy to spot */
 
#define ION_MAX_FILENAME_LENGTH   12
 Since the arduino conforms to 8.3 syntax, that's 8 + 3 = 11 + 1 (null terminator) characters. More...
 
#define DUMP(varname, format)   printf("Variable %s = " format "\n", # varname, varname);fflush(stdout)
 
#define PANIC(stuff)   printf("\t\t%s\n", stuff);fflush(stdout)
 
#define IONIZE(something, type)   & (type) { (something) }
 
#define NEUTRALIZE(something, type)   (*((type *) (something)))
 
#define IONIZE_VAL(varname, size)   ion_byte_t varname[size]
 
#define UNUSED(x)   (void) ((x))
 
#define ION_STATUS_CREATE(error, count)
 
#define ION_STATUS_INITIALIZE
 
#define ION_STATUS_ERROR(error)
 
#define ION_STATUS_OK(count)
 

Typedefs

typedef unsigned char byte
 A byte type. Do not use this type directly. More...
 
typedef enum ION_KEY_TYPE ion_key_type_t
 This is the available key types for ION_DB. All types will be based on system defines. More...
 
typedef enum ION_DICTIONARY_TYPE ion_dictionary_type_t
 This is the available dictionary types for ION_DB. All types will be based on system defines. More...
 
typedef char ion_err_t
 The error type used to store error codes. More...
 
typedef unsigned char ion_byte_t
 A byte type. More...
 
typedef long ion_fpos_t
 A file position type. More...
 
typedef void * ion_key_t
 A dictionary key. More...
 
typedef void * ion_value_t
 A dictionary value. More...
 
typedef int ion_key_size_t
 The size (length) of a dictionary key in bytes. More...
 
typedef int ion_value_size_t
 The size (length) of a dictionary value in bytes. More...
 
typedef unsigned int ion_dictionary_size_t
 The implementation specific size of the dictionary. More...
 
typedef char ion_boolean_t
 A boolean type. More...
 
typedef enum ION_BOOLEAN ion_boolean_e
 Boolean values. More...
 
typedef int ion_result_count_t
 A type for the number of results changed during an operation. More...
 
typedef char ion_record_status_t
 A type for record statuses used in some structures. More...
 
typedef struct record_info ion_record_info_t
 Struct used to maintain information about size of key and value. More...
 
typedef struct ion_record ion_record_t
 Struct used to maintain key and value. More...
 

Enumerations

enum  ION_KEY_TYPE { key_type_numeric_signed, key_type_numeric_unsigned, key_type_char_array, key_type_null_terminated_string }
 This is the available key types for ION_DB. All types will be based on system defines. More...
 
enum  ION_DICTIONARY_TYPE {
  dictionary_type_bpp_tree_t, dictionary_type_flat_file_t, dictionary_type_open_address_file_hash_t, dictionary_type_open_address_hash_t,
  dictionary_type_skip_list_t, dictionary_type_linear_hash_t, dictionary_type_error_t
}
 This is the available dictionary types for ION_DB. All types will be based on system defines. More...
 
enum  ION_ERROR {
  err_ok, err_item_not_found, err_duplicate_key, err_max_capacity,
  err_dictionary_destruction_error, err_invalid_predicate, err_out_of_memory, err_file_write_error,
  err_file_read_error, err_file_open_error, err_file_close_error, err_file_delete_error,
  err_unable_to_insert, err_file_bad_seek, err_file_hit_eof, err_not_implemented,
  err_invalid_initial_size, err_duplicate_dictionary_error, err_uninitialized, err_out_of_bounds,
  err_sorted_order_violation
}
 The list of all possible errors generated by any IonDB operation. More...
 
enum  ION_BOOLEAN { boolean_false = 0, boolean_true = 1 }
 Boolean values. More...
 

Macro Definition Documentation

#define DUMP (   varname,
  format 
)    printf("Variable %s = " format "\n", # varname, varname);fflush(stdout)

Definition at line 78 of file kv_system.h.

#define fdeleteall ( )

Definition at line 58 of file kv_system.h.

#define fremove (   x)    remove(x)

Definition at line 56 of file kv_system.h.

#define frewind (   x)    rewind(x)

Definition at line 57 of file kv_system.h.

#define ION_DEBUG   0

Definition at line 63 of file kv_system.h.

#define ION_IS_EQUAL   0

Definition at line 64 of file kv_system.h.

#define ION_IS_GREATER   1

Definition at line 65 of file kv_system.h.

#define ION_IS_LESS   -1

Definition at line 66 of file kv_system.h.

#define ION_MAX_FILENAME_LENGTH   12

Since the arduino conforms to 8.3 syntax, that's 8 + 3 = 11 + 1 (null terminator) characters.

Definition at line 73 of file kv_system.h.

#define ION_RETURN_VALUE   0x73/* Magic default return value to be easy to spot */

Definition at line 68 of file kv_system.h.

#define ION_STATUS_CREATE (   error,
  count 
)
Value:
((ion_status_t) { (error), (count) } \
)
#define error(rc)
Definition: bpp_tree.c:151
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290

Definition at line 104 of file kv_system.h.

#define ION_STATUS_ERROR (   error)
Value:
((ion_status_t) { (error), 0 } \
)
#define error(rc)
Definition: bpp_tree.c:151
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290

Definition at line 110 of file kv_system.h.

#define ION_STATUS_INITIALIZE
Value:
)
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290

Definition at line 107 of file kv_system.h.

#define ION_STATUS_OK (   count)
Value:
((ion_status_t) { err_ok, (count) } \
)
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290

Definition at line 113 of file kv_system.h.

#define ION_USING_ECLIPSE   0

Definition at line 62 of file kv_system.h.

#define ION_USING_MASTER_TABLE   1

Definition at line 61 of file kv_system.h.

#define ION_ZERO   0

Definition at line 67 of file kv_system.h.

#define IONIZE (   something,
  type 
)    & (type) { (something) }

Definition at line 98 of file kv_system.h.

#define IONIZE_VAL (   varname,
  size 
)    ion_byte_t varname[size]

Definition at line 100 of file kv_system.h.

#define NEUTRALIZE (   something,
  type 
)    (*((type *) (something)))

Definition at line 99 of file kv_system.h.

#define PANIC (   stuff)    printf("\t\t%s\n", stuff);fflush(stdout)

Definition at line 79 of file kv_system.h.

#define UNUSED (   x)    (void) ((x))

Definition at line 102 of file kv_system.h.

Typedef Documentation

typedef unsigned char byte

A byte type. Do not use this type directly.

This type is only provided for compatibility with the Arduino. If you want a byte type, use ion_byte_t instead.

Definition at line 93 of file kv_system.h.

typedef enum ION_BOOLEAN ion_boolean_e

Boolean values.

typedef char ion_boolean_t

A boolean type.

Definition at line 269 of file kv_system.h.

typedef unsigned char ion_byte_t

A byte type.

This is an unsigned, integral value capable of holding the range of a byte.

Definition at line 232 of file kv_system.h.

typedef unsigned int ion_dictionary_size_t

The implementation specific size of the dictionary.

Each implementation uses the dictionary size variable differently. It may be important to preserve the ability for variables of this type to become negative.

Definition at line 264 of file kv_system.h.

This is the available dictionary types for ION_DB. All types will be based on system defines.

typedef char ion_err_t

The error type used to store error codes.

This allows us to have finite control over the size of error codes returned.

Definition at line 226 of file kv_system.h.

typedef long ion_fpos_t

A file position type.

Definition at line 237 of file kv_system.h.

typedef int ion_key_size_t

The size (length) of a dictionary key in bytes.

Definition at line 251 of file kv_system.h.

typedef void* ion_key_t

A dictionary key.

Definition at line 241 of file kv_system.h.

This is the available key types for ION_DB. All types will be based on system defines.

Struct used to maintain information about size of key and value.

typedef char ion_record_status_t

A type for record statuses used in some structures.

This is used in at least the open address hash tables and the flat file dictionaries.

Definition at line 301 of file kv_system.h.

typedef struct ion_record ion_record_t

Struct used to maintain key and value.

typedef int ion_result_count_t

A type for the number of results changed during an operation.

Definition at line 284 of file kv_system.h.

typedef int ion_value_size_t

The size (length) of a dictionary value in bytes.

Definition at line 256 of file kv_system.h.

typedef void* ion_value_t

A dictionary value.

Definition at line 246 of file kv_system.h.

Enumeration Type Documentation

Boolean values.

Enumerator
boolean_false 

Truthy boolean value.

boolean_true 

Falsy boolean value.

Definition at line 274 of file kv_system.h.

274  {
276  boolean_false = 0,
278  boolean_true = 1,
279 } ion_boolean_e;
enum ION_BOOLEAN ion_boolean_e
Boolean values.

This is the available dictionary types for ION_DB. All types will be based on system defines.

Enumerator
dictionary_type_bpp_tree_t 

Dictionary type is a B+tree implementation.

dictionary_type_flat_file_t 

Dictionary type is a Flat File implementation.

dictionary_type_open_address_file_hash_t 

Dictionary type is an Open Address File Hash implementation.

dictionary_type_open_address_hash_t 

Dictionary type is an Open Address Hash implementation.

dictionary_type_skip_list_t 

Dictionary type is a Skip List implementation.

dictionary_type_linear_hash_t 

Dictionary type is a Linear Hash implementation.

dictionary_type_error_t 

Dictionary type is not initialized.

Definition at line 137 of file kv_system.h.

enum ION_ERROR

The list of all possible errors generated by any IonDB operation.

Enumerator
err_ok 

An error code describing the situation where everything is OK.

err_item_not_found 

An error code describing the situation where an item is not found.

err_duplicate_key 

An error code describing the situation where duplicate key is used

inappropriately.

err_max_capacity 

An error code describing the situation where a structure is asked

to grow beyond it's capacity.

err_dictionary_destruction_error 

An error code describing the situation where an error occurred in

destroying a dictionary.

err_invalid_predicate 

An error code describing the situation where a predicate is invalid.

err_out_of_memory 

An error code describing the situation where a memory allocation

could not occur due to the system being out of allocatable memory.

err_file_write_error 

An error code describing the situation where a write operation

has failed.

err_file_read_error 

An error code describing the situation where a read operation

has failed.

err_file_open_error 

An error code describing the situation where an open operation

has failed.

err_file_close_error 

An error code describing the situation where an close operation

has failed.

err_file_delete_error 

An error code describing the situation where an delete operation

has failed.

err_unable_to_insert 

An error code describing the situation where an insert operation could

not be completed.

err_file_bad_seek 

An error code describing the situation where a seek operation could

not be made to completion.

err_file_hit_eof 

An error code describing the situation where a file operation hit

the EOF.

err_not_implemented 

An error code describing the situation where a requested operation

is not implemented.

err_invalid_initial_size 

An error code describing the situation where specified size is

illegal, invalid, or otherwise unreasonable.

err_duplicate_dictionary_error 

An error code returned when a dictionary of the same name as

an existing dictionary is attempted to be created.

err_uninitialized 

An error code describing the situation a system object or dictionary

was not properly initialized.

err_out_of_bounds 

An error code describing the situation where something is out of

valid bounds.

err_sorted_order_violation 

An error code describing the situation where an operation would

violate the sorted precondition.

Definition at line 158 of file kv_system.h.

158  {
160  err_ok,
219 };

This is the available key types for ION_DB. All types will be based on system defines.

Enumerator
key_type_numeric_signed 

Key is a signed numeric value.

key_type_numeric_unsigned 

Key is an unsigned numeric value.

key_type_char_array 

Key is char array.

key_type_null_terminated_string 

Key is a null-terminated string.

Note that this needs padding out to avoid reading memory one does not own.

Definition at line 121 of file kv_system.h.

121  {
enum ION_KEY_TYPE ion_key_type_t
This is the available key types for ION_DB. All types will be based on system defines.