structures Namespace Reference

A dynamic container class that holds any kind of object via pointers. More...

Classes

class  amorph
class  bit_vector
 An array of bits with operations for manipulating and querying individual bits. More...
class  rotating_byte_hasher
 Implements a hashing algorithm based on the contents stored in an object. More...
class  checksums
class  hashing_algorithm
 A hashing algorithm takes a key and derives a related integer from it. More...
class  hash_table
 Implements hashing into buckets for quick object access. More...
class  hash_wrapper
class  bucket
class  internal_hash_array
class  int_hash
 A hash table for storing integers. More...
class  matrix
 Represents a two-dimensional array of objects. More...
class  int_matrix
 A matrix of integers. More...
class  string_matrix
 A matrix of strings. More...
class  double_matrix
 A matrix of double floating point numbers. More...
class  memory_limiter
 Tracks memory currently in use by memory manager objects. More...
class  pointer_hash
 A hash table for storing pointers. More...
class  roller
 Maintains a pseudo-unique identifier number and issues a new one on demand. More...
class  int_roller
 A roller that's based on integers. This is the most common type so far. More...
class  set
 Emulates a mathematical set, providing several standard set operations. More...
class  int_set
 A simple object that wraps a templated set of ints. More...
class  string_set
 A simple object that wraps a templated set of strings. More...
class  pointer_set
 A set of pointers that hides the platform's pointer size. More...
class  stack
 An abstraction that represents a stack data structure. More...
class  static_memory_gremlin
 Holds onto memory chunks that are allocated globally within the program. More...
class  string_array
 An array of strings with some additional helpful methods. More...
class  string_hash
 Implements a hash table indexed on character strings. More...
class  string_hasher
 Implements a simple hashing algorithm for strings. More...
class  astring_hasher
class  string_table
 Provides a symbol_table that holds strings as the content. More...
class  symbol_table
 Maintains a list of names, where each name has a type and some contents. More...
class  internal_symbol_info
class  internal_pointer_hider
class  internal_symbol_indexer
class  internal_symbol_list
struct  sym_tab_apply_data
class  unique_id
 Provides an abstraction for the responsibilities of a unique identifier. More...
class  orderable_unique_id
 A unique identifier class that supports sorting. More...
class  unique_int
 A unique identifier based on integers. More...
class  version
 Holds a file's version identifier. More...
class  version_record
 Holds all information about a file's versioning. More...

Enumerations

enum  endian { LEFT_ENDIAN, RIGHT_ENDIAN }

Functions

template<class contents >
void amorph_assign (amorph< contents > &to_assign, const amorph< contents > &to_copy)
 This can be used when the templated object has a copy constructor.
template<class contents >
void amorph_pack (basis::byte_array &packed_form, const amorph< contents > &to_pack)
 support for packing an amorph into an array of bytes.
template<class contents >
bool amorph_unpack (basis::byte_array &packed_form, amorph< contents > &to_unpack)
 unpacks the amorph from an array of bytes.
template<class contents >
int amorph_packed_size (const amorph< contents > &to_pack)
 reports how large the packed form will be.
template<class type >
void SET (type &to_modify, type bits)
 returns a number based on "to_modify" but with "bits" turned on.
template<class type >
void CLEAR (type &to_modify, type bits)
 returns a number based on "to_modify" but with "bits" turned off.
template<class type >
bool TEST (type to_test, type bits)
 returns non-zero if the "bits" bit pattern is turned on in "to_test".
template<class key_type , class contents >
void copy_hash_table (hash_table< key_type, contents > &target, const hash_table< key_type, contents > &source)
 Copies the entire hash table, given a contents type that supports copying.
void rotate_in (byte_array &attach_into, int to_attach, int size_in_bytes)
void snag_out (byte_array &eat_from, basis::un_int &accumulator, int size_in_bytes)
int packed_size (const basis::byte_array &packed_form)
 Reports the size required to pack a byte array into a byte array.
void attach (basis::byte_array &packed_form, const basis::byte_array &to_attach)
 Packs a byte_array "to_attach" into "packed_form".
bool detach (basis::byte_array &packed_form, basis::byte_array &to_detach)
 Unpacks a byte_array "to_detach" from "packed_form".
void attach (basis::byte_array &packed_form, basis::un_int to_attach)
 Packs an unsigned integer "to_attach" into "packed_form".
bool detach (basis::byte_array &packed_form, basis::un_int &to_detach)
 Unpacks an unsigned integer "to_attach" from "packed_form".
void attach (basis::byte_array &packed_form, basis::un_short to_attach)
 Packs an unsigned short integer "to_attach" into "packed_form".
bool detach (basis::byte_array &packed_form, basis::un_short &to_detach)
 Unpacks an unsigned short integer "to_attach" from "packed_form".
void attach (byte_array &packed_form, abyte to_attach)
bool detach (byte_array &packed_form, abyte &to_detach)
void attach (basis::byte_array &packed_form, int to_attach)
 Packs an integer "to_attach" into "packed_form".
bool detach (basis::byte_array &packed_form, int &to_detach)
 Unpacks an integer "to_attach" from "packed_form".
void attach (basis::byte_array &packed_form, short to_attach)
 Packs a short integer "to_attach" into "packed_form".
bool detach (basis::byte_array &packed_form, short &to_detach)
 Unpacks a short integer "to_attach" from "packed_form".
void attach (basis::byte_array &packed_form, char to_attach)
 Packs a char "to_attach" into "packed_form".
bool detach (basis::byte_array &packed_form, char &to_detach)
 Unpacks a char "to_detach" from "packed_form".
void attach (basis::byte_array &packed_form, bool to_attach)
 Packs a bool "to_attach" into "packed_form".
bool detach (basis::byte_array &packed_form, bool &to_detach)
 Unpacks a bool "to_detach" from "packed_form".
double break_off_digit (double &input)
int packed_size (double to_pack)
 Reports how large the "to_pack" will be as a stream of bytes.
void attach (basis::byte_array &packed_form, double to_pack)
 Packs a double precision floating point "to_attach" into "packed_form".
bool detach (basis::byte_array &packed_form, double &to_unpack)
 Unpacks a double precision floating point "to_attach" from "packed_form".
void attach (basis::byte_array &packed_form, float to_pack)
 Packs a floating point "to_attach" into "packed_form".
bool detach (basis::byte_array &packed_form, float &to_unpack)
 Unpacks a floating point "to_attach" from "packed_form".
void obscure_attach (byte_array &packed_form, un_int to_attach)
bool obscure_detach (byte_array &packed_form, un_int &to_detach)
void attach (basis::byte_array &packed_form, basis::abyte to_attach)
 Packs a byte "to_attach" into "packed_form".
bool detach (basis::byte_array &packed_form, basis::abyte &to_detach)
 Unpacks a byte "to_detach" from "packed_form".
void obscure_attach (basis::byte_array &packed_form, basis::un_int to_attach)
 like the normal attach but shifts in some recognizable sentinel data.
bool obscure_detach (basis::byte_array &packed_form, basis::un_int &to_detach)
 shifts the number back and checks validity, false returned if corrupted.
template<class contents >
void pack_array (basis::byte_array &packed_form, const basis::array< contents > &to_pack)
 provides a way to pack any array that stores packable objects.
template<class contents >
bool unpack_array (basis::byte_array &packed_form, basis::array< contents > &to_unpack)
 provides a way to unpack any array that stores packable objects.
template<class contents >
int packed_size_array (const basis::array< contents > &to_pack)
 provides space estimation for the objects to be packed.
template<class contents >
void pack_simple (basis::byte_array &packed_form, const basis::array< contents > &to_pack)
 Packs flat objects into an array of bytes.
template<class contents >
bool unpack_simple (basis::byte_array &packed_form, basis::array< contents > &to_unpack)
 Unpacks flat objects from an array of bytes.
template<class contents >
void pack (basis::byte_array &packed_form, const set< contents > &to_pack)
 provides a way to pack any set that stores packable objects.
template<class contents >
bool unpack (basis::byte_array &packed_form, set< contents > &to_unpack)
 provides a way to unpack any set that stores packable objects.
template<class contents >
bool symbol_table_compare (const symbol_table< contents > &a, const symbol_table< contents > &b)
 returns true if table "a" and table "b" have the same contents.
template<class contents >
bool sym_tab_finder_apply (const basis::astring &key, contents &current, void *data_link)

Variables

endian host_byte_order = LEFT_ENDIAN
endian host_bit_order = LEFT_ENDIAN
const int HIGHEST_MOD_VALUE = 32014
const int PACKED_SIZE_BYTE = 1
const int PACKED_SIZE_INT16 = 2
const int PACKED_SIZE_INT32 = 4
const int SMG_CHUNKING_FACTOR = 32
const int MAX_STRING_CHARS_USED = 3

Detailed Description

A dynamic container class that holds any kind of object via pointers.

The object is considered owned by the amorph unless re-acquired from it, and will be deleted when the amorph is destroyed.

An amorph has a specified number of fields at any one time, but the number can be changed with "zap", "insert" and "adjust". Fields in the amorph are either full or empty, where an empty field in the amorph has NIL as its content. "put" adds a new field to the amorph. "get" retrieves the contents of a field as a constant. "acquire" is used to check a field out of the amorph, meaning that the amorph no longer possesses that field. The legal range of indices in an amorph is from 0 through "elements() - 1". In general, a range violation for an index is treated as an invalid request and is ignored (although BAD_INDEX is returned by functions with compatible return values).

Model:

The policy followed in amorph is that once an object is checked in with "put" or "append", then the amorph owns that object. The object must not be destroyed externally, because the amorph will automatically destroy the object when either: 1) the amorph itself is destroyed, or 2) another object is entered into the same field. If the stored object must be destroyed externally, then it should be checked out of the amorph with "acquire"; after that, the pointer may be deleted. "get" and "borrow" return a pointer to the stored item while leaving it checked in to the amorph. it is safe to modify what was "borrow"ed or to look at what one "get"s, but do not destroy the pointers returned from either method.


Enumeration Type Documentation

Enumerator:
LEFT_ENDIAN 
RIGHT_ENDIAN 

Definition at line 229 of file bit_vector.cpp.


Function Documentation

template<class contents >
void structures::amorph_assign ( amorph< contents > &  to_assign,
const amorph< contents > &  to_copy 
) [inline]

This can be used when the templated object has a copy constructor.

this makes the "to_assign" into a copy of the "to_copy" amorph.

Definition at line 464 of file amorph.h.

References structures::amorph< contents >::elements(), structures::amorph< contents >::get(), and PACKED_SIZE_INT32.

template<class contents >
void structures::amorph_pack ( basis::byte_array packed_form,
const amorph< contents > &  to_pack 
) [inline]

support for packing an amorph into an array of bytes.

this can be used when the underlying object is based on packable or supports the same pack/unpack methods. note that if there are empty spots in the amorph, they are not packed. when the packed form is unpacked again, it will have only the first N elements set, where N is the number of non-empty items.

Definition at line 440 of file amorph.h.

Referenced by filesystem::filename_list::pack().

template<class contents >
int structures::amorph_packed_size ( const amorph< contents > &  to_pack  )  [inline]

reports how large the packed form will be.

Definition at line 429 of file amorph.h.

References CHECK_FIELDS, and FUNCDEF.

Referenced by filesystem::filename_list::packed_size().

template<class contents >
bool structures::amorph_unpack ( basis::byte_array packed_form,
amorph< contents > &  to_unpack 
) [inline]

unpacks the amorph from an array of bytes.

Definition at line 450 of file amorph.h.

Referenced by filesystem::filename_list::unpack().

void structures::attach ( basis::byte_array packed_form,
basis::abyte  to_attach 
)

Packs a byte "to_attach" into "packed_form".

void structures::attach ( byte_array &  packed_form,
float  to_pack 
)

Packs a floating point "to_attach" into "packed_form".

void structures::attach ( byte_array &  packed_form,
double  to_pack 
)

Packs a double precision floating point "to_attach" into "packed_form".

void structures::attach ( byte_array &  packed_form,
bool  to_attach 
)

Packs a bool "to_attach" into "packed_form".

void structures::attach ( byte_array &  packed_form,
char  to_attach 
)

Packs a char "to_attach" into "packed_form".

void structures::attach ( byte_array &  packed_form,
short  to_attach 
)

Packs a short integer "to_attach" into "packed_form".

void structures::attach ( basis::byte_array packed_form,
int  to_attach 
)

Packs an integer "to_attach" into "packed_form".

This method and the other simple numerical storage methods use a little endian ordering of the bytes. They are platform independent with respect to endianness and will reassemble the number properly on any platform.

void structures::attach ( byte_array packed_form,
abyte  to_attach 
)

Definition at line 94 of file object_packers.cpp.

void structures::attach ( byte_array &  packed_form,
basis::un_short  to_attach 
)

Packs an unsigned short integer "to_attach" into "packed_form".

void structures::attach ( byte_array &  packed_form,
basis::un_int  to_attach 
)

Packs an unsigned integer "to_attach" into "packed_form".

void structures::attach ( byte_array &  packed_form,
const byte_array &  to_attach 
)

Packs a byte_array "to_attach" into "packed_form".

Referenced by obscure_attach(), structures::string_table::pack(), and pack_simple().

double structures::break_off_digit ( double &  input  ) 

Definition at line 154 of file object_packers.cpp.

template<class type >
void structures::CLEAR ( type &  to_modify,
type  bits 
) [inline]

returns a number based on "to_modify" but with "bits" turned off.

Definition at line 151 of file bit_vector.h.

template<class key_type , class contents >
void structures::copy_hash_table ( hash_table< key_type, contents > &  target,
const hash_table< key_type, contents > &  source 
) [inline]

Copies the entire hash table, given a contents type that supports copying.

Provides a copy operation on hash tables where the contents object supports a copy constructor, which is not appropriate to require in general. The hash_table held in "target" will be wiped out and replaced with items equivalent to those in "source".

Definition at line 292 of file hash_table.h.

References structures::hash_table< key_type, contents >::add(), deadly_error, FUNCDEF, basis::array< hash_wrapper< key_type, contents > >::length(), structures::hash_table< key_type, contents >::reset(), structures::hash_table< key_type, contents >::table_access(), and structures::hash_table< key_type, contents >::verify().

bool structures::detach ( basis::byte_array packed_form,
basis::abyte to_detach 
)

Unpacks a byte "to_detach" from "packed_form".

bool structures::detach ( byte_array &  packed_form,
float &  to_unpack 
)

Unpacks a floating point "to_attach" from "packed_form".

bool structures::detach ( byte_array &  packed_form,
double &  to_unpack 
)

Unpacks a double precision floating point "to_attach" from "packed_form".

bool structures::detach ( byte_array &  packed_form,
bool &  to_detach 
)

Unpacks a bool "to_detach" from "packed_form".

bool structures::detach ( byte_array &  packed_form,
char &  to_detach 
)

Unpacks a char "to_detach" from "packed_form".

bool structures::detach ( byte_array &  packed_form,
short &  to_detach 
)

Unpacks a short integer "to_attach" from "packed_form".

bool structures::detach ( byte_array &  packed_form,
int &  to_detach 
)

Unpacks an integer "to_attach" from "packed_form".

bool structures::detach ( byte_array packed_form,
abyte &  to_detach 
)
bool structures::detach ( byte_array &  packed_form,
basis::un_short to_detach 
)

Unpacks an unsigned short integer "to_attach" from "packed_form".

bool structures::detach ( byte_array &  packed_form,
basis::un_int to_detach 
)

Unpacks an unsigned integer "to_attach" from "packed_form".

bool structures::detach ( byte_array &  packed_form,
byte_array &  to_detach 
)
void structures::obscure_attach ( basis::byte_array packed_form,
basis::un_int  to_attach 
)

like the normal attach but shifts in some recognizable sentinel data.

this is slightly more sure than a simple integer attachment. it can be used to make sure upcoming data is probably a valid int.

void structures::obscure_attach ( byte_array packed_form,
un_int  to_attach 
)

Definition at line 244 of file object_packers.cpp.

References attach().

Referenced by pack(), manifest_chunk::pack(), pack_array(), and pack_simple().

bool structures::obscure_detach ( basis::byte_array packed_form,
basis::un_int to_detach 
)

shifts the number back and checks validity, false returned if corrupted.

bool structures::obscure_detach ( byte_array packed_form,
un_int &  to_detach 
)
template<class contents >
void structures::pack ( basis::byte_array packed_form,
const set< contents > &  to_pack 
) [inline]

provides a way to pack any set that stores packable objects.

Definition at line 131 of file set.h.

References structures::set< contents >::elements(), and obscure_attach().

Referenced by processes::post_office::deliver_mail_on_route(), structures::symbol_table< contents >::find(), and pack_array().

template<class contents >
void structures::pack_array ( basis::byte_array packed_form,
const basis::array< contents > &  to_pack 
) [inline]

provides a way to pack any array that stores packable objects.

Definition at line 115 of file object_packers.h.

References basis::array< contents >::length(), obscure_attach(), and pack().

Referenced by octopi::infoton::fast_pack().

template<class contents >
void structures::pack_simple ( basis::byte_array packed_form,
const basis::array< contents > &  to_pack 
) [inline]

Packs flat objects into an array of bytes.

Similar to pack above, but operates on arrays with simple objects that do not support functional pack and unpack.

Definition at line 151 of file object_packers.h.

References attach(), basis::array< contents >::length(), and obscure_attach().

int structures::packed_size ( double  to_pack  ) 

Reports how large the "to_pack" will be as a stream of bytes.

int structures::packed_size ( const byte_array &  packed_form  ) 

Reports the size required to pack a byte array into a byte array.

Referenced by packed_size_array().

template<class contents >
int structures::packed_size_array ( const basis::array< contents > &  to_pack  )  [inline]

provides space estimation for the objects to be packed.

Definition at line 140 of file object_packers.h.

References basis::array< contents >::length(), and packed_size().

void structures::rotate_in ( byte_array attach_into,
int  to_attach,
int  size_in_bytes 
)

Definition at line 25 of file object_packers.cpp.

template<class type >
void structures::SET ( type &  to_modify,
type  bits 
) [inline]

returns a number based on "to_modify" but with "bits" turned on.

Definition at line 147 of file bit_vector.h.

Referenced by structures::bit_vector::get().

void structures::snag_out ( byte_array eat_from,
basis::un_int accumulator,
int  size_in_bytes 
)

Definition at line 34 of file object_packers.cpp.

References basis::array< contents >::zap().

template<class contents >
bool structures::sym_tab_finder_apply ( const basis::astring key,
contents &  current,
void *  data_link 
) [inline]

Definition at line 344 of file symbol_table.h.

References FUNCDEF, and LOG.

Referenced by structures::symbol_table< contents >::find().

template<class contents >
bool structures::symbol_table_compare ( const symbol_table< contents > &  a,
const symbol_table< contents > &  b 
) [inline]

returns true if table "a" and table "b" have the same contents.

Definition at line 436 of file symbol_table.h.

References structures::set< contents >::elements(), structures::symbol_table< contents >::find(), and structures::symbol_table< contents >::names().

template<class type >
bool structures::TEST ( type  to_test,
type  bits 
) [inline]

returns non-zero if the "bits" bit pattern is turned on in "to_test".

Definition at line 155 of file bit_vector.h.

template<class contents >
bool structures::unpack ( basis::byte_array packed_form,
set< contents > &  to_unpack 
) [inline]

provides a way to unpack any set that stores packable objects.

Definition at line 139 of file set.h.

References structures::set< contents >::add(), structures::set< contents >::clear(), and obscure_detach().

Referenced by filesystem::filename::unpack(), and unpack_array().

template<class contents >
bool structures::unpack_array ( basis::byte_array packed_form,
basis::array< contents > &  to_unpack 
) [inline]

provides a way to unpack any array that stores packable objects.

Definition at line 122 of file object_packers.h.

References basis::array< contents >::flags(), NIL, obscure_detach(), basis::array< contents >::reset(), and unpack().

Referenced by octopi::infoton::fast_unpack().

template<class contents >
bool structures::unpack_simple ( basis::byte_array packed_form,
basis::array< contents > &  to_unpack 
) [inline]

Unpacks flat objects from an array of bytes.

Similar to unpack above, but operates on arrays with simple objects that do not support functional pack and unpack.

Definition at line 161 of file object_packers.h.

References detach(), basis::array< contents >::flags(), NIL, obscure_detach(), and basis::array< contents >::reset().


Variable Documentation

const int structures::HIGHEST_MOD_VALUE = 32014

Definition at line 23 of file checksums.cpp.

Definition at line 231 of file bit_vector.cpp.

Referenced by structures::bit_vector::get(), and structures::bit_vector::set().

Definition at line 230 of file bit_vector.cpp.

Referenced by structures::bit_vector::get().

Definition at line 24 of file string_hasher.cpp.

Referenced by structures::string_hasher::hash().

Definition at line 25 of file object_packers.h.

Definition at line 26 of file object_packers.h.

Generated on Sat Jan 28 04:25:54 2012 for hoople2 project by  doxygen 1.6.3