Conversion.h

Classes

Conversion -- A class with general conversion definitions (full description)

class Conversion

Interface

Public Members
typedef unsigned int ValueFunction (void* to, const void* from, unsigned int nvalues)
typedef void* ByteFunction (void* to, const void* from, unsigned int nbytes)
static unsigned int boolToBit (void* to, const void* from, unsigned int nvalues)
static void boolToBit (void* to, const void* from, unsigned int startBit, unsigned int nvalues)
static unsigned int bitToBool (void* to, const void* from, unsigned int nvalues)
static void bitToBool (void* to, const void* from, unsigned int startBit, unsigned int nvalues)
static unsigned int valueCopy (void* to, const void* from, unsigned int nbytes)
static ByteFunction* getmemcpy()
static void* mymemcpy (void* to, const void* from, unsigned int nbytes)

Description

Review Status

Reviewed By:
Friso Olnon
Date Reviewed:
1996/11/06
Programs:
Tests:

Synopsis

This class contains the general definitions for the Conversion classes. Static functions in the classes CanonicalConversion, VAXConversion, and IBMConversion convert data from/to canonical, VAX, and IBM/360 format, resp..
Classes derived from DataConversion provide the same functionality in a polymorphic way.

Motivation

This provides a common place for definitions used elsewhere. It also provides a uniform interface to memcpy.

Member Description

typedef unsigned int ValueFunction (void* to, const void* from, unsigned int nvalues)

Define the signature of a function converting nvalues values from internal to external format or vice-versa. These functions are used in the IO framework , but are also used in the table system. Examples of such conversions are:
- local <-> canonical (when storing in canonical format)
- local <-> local (when storing in local format)
- binary <-> ASCII
It returns the number of bytes in external format. (For example the ToLocal/FromLocal functions in class CanonicalConversion return the number of bytes in canonical format).

typedef void* ByteFunction (void* to, const void* from, unsigned int nbytes)

Define the signature of a function converting from one format to another providing the number of bytes. It returns the to pointer (similar to memcpy). (For example the byteTo/FromLocalXXX functions in class CanonicalConversion.

static unsigned int boolToBit (void* to, const void* from, unsigned int nvalues)
static void boolToBit (void* to, const void* from, unsigned int startBit, unsigned int nvalues)

Convert a stream of Bools to output format (as bits). The variable startBit (0-relative) indicates where to start in the to buffer.

static unsigned int bitToBool (void* to, const void* from, unsigned int nvalues)
static void bitToBool (void* to, const void* from, unsigned int startBit, unsigned int nvalues)

Convert a stream of Bools to output format (as bits). The variable startBit (0-relative) indicates where to start in the from buffer.

static unsigned int valueCopy (void* to, const void* from, unsigned int nbytes)

Copy a value using memcpy. It differs from memcpy in the return value. This version has the ValueFunction signature, but it expects as input the number of bytes.

static ByteFunction* getmemcpy()

Get a pointer to the memcpy function.

static void* mymemcpy (void* to, const void* from, unsigned int nbytes)

A placeholder for the ObjectCenter or DEC-alpha memcpy or 64bit SGI Also added this for HPUX11 (2b provided in the makedefs) (because they do not use an unsigned int for nbytes).