SheafSystem  0.0.0.0
sheaf::data_converter Class Reference

Function object to convert between internal and external data formats. More...

#include <data_converter.h>

Inheritance diagram for sheaf::data_converter:
sheaf::any

Public Member Functions

virtual data_converterclone () const
 Virtual constructor; makes a new instance of the same type as this. More...
 
virtual ~data_converter ()
 Destructor. More...
 
virtual bool invariant () const
 Class invariant. More...
 
virtual bool is_ancestor_of (const any *other) const
 Conformance test; true if other conforms to this. More...
 
 data_converter (hid_t xexternal_type, hid_t xinternal_type, int xinternal_index)
 Creates a converter between the internal hdf type specified by xinternal_type and the external type specified by xexternal_type_name. If xcreate_ext_type, assumes that the external type does not already exist in the file and attempts to create it, otherwise attempts to open it. More...
 
bool conversion_required () const
 True if internal and external types are not identical. More...
 
hid_t external_type () const
 The external type identifier. More...
 
size_t external_size () const
 The size in bytes of the external type. More...
 
void externalize (const void *xint_buf, size_t xint_buf_ub, void *xext_buf, size_t xext_buf_ub, int xitem_ct)
 Copy xitem_ct data items from xint_buf to xext_buf and then convert them from internal to external format. More...
 
void externalize (void *xext_buf, size_t xext_buf_ub, int xitem_ct)
 Convert xitem_ct data items in xext_buf from internal to external format. More...
 
void externalize (const void *xint_buf, size_t xint_buf_ub)
 Copy one data item from xint_buf to result() and then convert it from internal to external format. More...
 
hid_t internal_type () const
 The HDF type identifier for the internal type. More...
 
hid_t internal_index () const
 The primitives poset member index for the internal type. More...
 
size_t internal_size () const
 The size in bytes of the internal type. More...
 
size_t internal_alignment () const
 The alignment of the internal type. More...
 
void internalize (const void *xext_buf, size_t xext_buf_ub, void *xint_buf, size_t xint_buf_ub, int xitem_ct)
 Convert xitem_ct data items in xext_buf from external to internal format and place the result in xint_buf. More...
 
void internalize (void *xbuf, size_t xbuf_ub, int xitem_ct)
 Convert xitem_ct data items in xbuf from external to internal format and leave the result in xbuf. More...
 
void internalize (void *xbuf, size_t xbuf_ub)
 Convert one data item from xbuf from external to internal format and leave the result in result(). More...
 
bool internal_size_greater () const
 True if the internal size is greater than the external size. More...
 
bool external_size_greater () const
 True if the external size is greater than the internal size. More...
 
size_t max_size () const
 The maximum of internal_size() and external_size(). More...
 
void * result () const
 The result of the conversion. More...
 
size_t result_size () const
 The allocated size of the result buffer. More...
 
bool is_namespace_relative_member_index_type () const
 True if this is a converter for a naemspace_relative_member_index type. More...
 
bool is_namespace_relative_subposet_index_type () const
 True if this is a converter for a namespace_relative_subposet_index type. More...
 
bool is_string_type () const
 True if this is a converter for a string type. More...
 
size_t string_length_total (const void *xbuf, int xitem_ct) const
 The total number of characters, including the terminators in all the strings in the array of strings xbuf. More...
 
- Public Member Functions inherited from sheaf::any
bool is_same_type (const any *other) const
 True if other is the same type as this. More...
 
virtual ~any ()
 Destructor. More...
 
bool invariant_check () const
 True if invariant checking is enabled. More...
 
void enable_invariant_check () const
 Enable invariant checking. More...
 
void disable_invariant_check () const
 Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing invariant checking during multi-phase initialization. More...
 
int disable_invariance_check_request_depth () const
 Number of times disable_invariant_check has been called without matching call to enable_invariant_check. More...
 

Static Public Member Functions

static size_t string_length (const char *xbuf)
 The number of characters in the string, including the terminator. More...
 

Additional Inherited Members

- Protected Member Functions inherited from sheaf::any
 any ()
 default constructor More...
 

Detailed Description

Function object to convert between internal and external data formats.

Definition at line 50 of file data_converter.h.

Constructor & Destructor Documentation

◆ ~data_converter()

sheaf::data_converter::~data_converter ( )
virtual

Destructor.

Issue:
H5Pclose seems to always return failure.

Definition at line 64 of file data_converter.cc.

References invariant().

Referenced by clone().

◆ data_converter()

sheaf::data_converter::data_converter ( hid_t  xexternal_type,
hid_t  xinternal_type,
int  xinternal_index 
)

Creates a converter between the internal hdf type specified by xinternal_type and the external type specified by xexternal_type_name. If xcreate_ext_type, assumes that the external type does not already exist in the file and attempts to create it, otherwise attempts to open it.

Precondition
  • is_primitive_index(xinternal_index)
Postcondition

Definition at line 169 of file data_converter.cc.

References sheaf::primitive_attributes::descriptor(), externalize(), invariant(), sheaf::is_primitive_index(), is_string_type(), and max_size().

Member Function Documentation

◆ clone()

sheaf::data_converter * sheaf::data_converter::clone ( ) const
virtual

Virtual constructor; makes a new instance of the same type as this.

Postcondition
  • result != 0
  • is_same_type(result)

Reimplemented from sheaf::any.

Definition at line 40 of file data_converter.cc.

References sheaf::any::is_same_type(), result(), and ~data_converter().

◆ conversion_required()

bool sheaf::data_converter::conversion_required ( ) const
inline

True if internal and external types are not identical.

Definition at line 99 of file data_converter.h.

Referenced by externalize(), and internalize().

◆ external_size()

size_t sheaf::data_converter::external_size ( ) const
inline

The size in bytes of the external type.

Definition at line 119 of file data_converter.h.

Referenced by externalize(), and internalize().

◆ external_size_greater()

bool sheaf::data_converter::external_size_greater ( ) const
inline

True if the external size is greater than the internal size.

Definition at line 229 of file data_converter.h.

Referenced by internalize().

◆ external_type()

hid_t sheaf::data_converter::external_type ( ) const
inline

The external type identifier.

Definition at line 109 of file data_converter.h.

Referenced by internalize(), and sheaf::record_set::write_attribute().

◆ externalize() [1/3]

void sheaf::data_converter::externalize ( const void *  xint_buf,
size_t  xint_buf_ub,
void *  xext_buf,
size_t  xext_buf_ub,
int  xitem_ct 
)

Copy xitem_ct data items from xint_buf to xext_buf and then convert them from internal to external format.

Precondition
  • xitem_ct > 0
  • xint_buf != 0
  • is_string_type() ? xint_buf_ub >= xitem_ct*sizeof(char*) : xint_buf_ub >= xitem_ct*internal_size()
  • xext_buf != 0
  • is_string_type() ? xext_buf_ub >= string_length_total(xint_buf, xitem_ct) : xext_buf_ub >= xitem_ct*max_size()
Todo:
finish implementation ; deal with error status

Definition at line 243 of file data_converter.cc.

References external_size(), internal_size(), internal_size_greater(), is_string_type(), max_size(), string_length(), and string_length_total().

Referenced by data_converter(), and externalize().

◆ externalize() [2/3]

void sheaf::data_converter::externalize ( void *  xext_buf,
size_t  xext_buf_ub,
int  xitem_ct 
)

Convert xitem_ct data items in xext_buf from internal to external format.

Precondition
  • xitem_ct > 0
  • xext_buf != 0
  • xext_buf_ub >= xitem_ct*max_size()
Issue:
we need to make this routine inlineable.
Todo:
finish implementation ; deal with error status

Definition at line 305 of file data_converter.cc.

References conversion_required(), externalize(), and max_size().

◆ externalize() [3/3]

void sheaf::data_converter::externalize ( const void *  xint_buf,
size_t  xint_buf_ub 
)

Copy one data item from xint_buf to result() and then convert it from internal to external format.

Precondition
  • xint_buf != 0
Issue:
we need to make this routine inlineable.
Todo:
finish implementation ; deal with error status

Definition at line 336 of file data_converter.cc.

References conversion_required(), internal_size(), max_size(), result_size(), and string_length().

◆ internal_alignment()

size_t sheaf::data_converter::internal_alignment ( ) const
inline

The alignment of the internal type.

Definition at line 186 of file data_converter.h.

Referenced by internalize().

◆ internal_index()

hid_t sheaf::data_converter::internal_index ( ) const
inline

The primitives poset member index for the internal type.

Definition at line 166 of file data_converter.h.

Referenced by internalize(), and sheaf::poset_general_record::transfer_poset_to_internal_buffer().

◆ internal_size()

size_t sheaf::data_converter::internal_size ( ) const
inline

The size in bytes of the internal type.

Definition at line 176 of file data_converter.h.

Referenced by externalize(), internalize(), and sheaf::record_set::read_attribute().

◆ internal_size_greater()

bool sheaf::data_converter::internal_size_greater ( ) const
inline

True if the internal size is greater than the external size.

Definition at line 219 of file data_converter.h.

Referenced by externalize().

◆ internal_type()

hid_t sheaf::data_converter::internal_type ( ) const
inline

The HDF type identifier for the internal type.

Definition at line 156 of file data_converter.h.

Referenced by sheaf::dof_tuple_record_set::create_int_data_type(), internalize(), sheaf::record_set::read_attribute(), and sheaf::record_set::write_attribute().

◆ internalize() [1/3]

void sheaf::data_converter::internalize ( const void *  xext_buf,
size_t  xext_buf_ub,
void *  xint_buf,
size_t  xint_buf_ub,
int  xitem_ct 
)

Convert xitem_ct data items in xext_buf from external to internal format and place the result in xint_buf.

Precondition
  • xitem_ct > 0
  • xext_buf != 0
  • xint_buf != 0
  • is_string_type() ? xint_buf_ub >= xitem_ct*internal_size() : xint_buf_ub >= xitem_ct*max_size()
Issue:
we need to make this routine inlineable.
Error:
where does this string get deleted?
Todo:
finish implementation; handle error return

Definition at line 432 of file data_converter.cc.

References external_size(), external_size_greater(), internal_size(), is_string_type(), max_size(), and string_length().

Referenced by internalize(), and string_length_total().

◆ internalize() [2/3]

void sheaf::data_converter::internalize ( void *  xbuf,
size_t  xbuf_ub,
int  xitem_ct 
)

Convert xitem_ct data items in xbuf from external to internal format and leave the result in xbuf.

Precondition
  • xitem_ct > 0
  • xbuf != 0
  • xbuf_ub >= xitem_ct*max_size()
Issue:
we need to make this routine inlineable.
Todo:
finish implementation; handle error return

Definition at line 523 of file data_converter.cc.

References conversion_required(), internalize(), and max_size().

◆ internalize() [3/3]

void sheaf::data_converter::internalize ( void *  xbuf,
size_t  xbuf_ub 
)

Convert one data item from xbuf from external to internal format and leave the result in result().

Precondition
  • xbuf != 0
Issue:
we need to make this routine inlineable.
Todo:
finish implementation; handle error return

Definition at line 554 of file data_converter.cc.

References conversion_required(), external_size(), external_type(), internal_alignment(), internal_index(), internal_size(), internal_type(), invariant(), max_size(), and result_size().

◆ invariant()

bool sheaf::data_converter::invariant ( ) const
virtual

◆ is_ancestor_of()

bool sheaf::data_converter::is_ancestor_of ( const any other) const
virtual

Conformance test; true if other conforms to this.

Precondition
  • other != 0

Reimplemented from sheaf::any.

Definition at line 144 of file data_converter.cc.

References result().

Referenced by invariant().

◆ is_namespace_relative_member_index_type()

bool sheaf::data_converter::is_namespace_relative_member_index_type ( ) const
inline

True if this is a converter for a naemspace_relative_member_index type.

Definition at line 269 of file data_converter.h.

Referenced by sheaf::dof_tuple_record_set::externalize_all_dofs(), and sheaf::dof_tuple_record_set::internalize_all_dofs().

◆ is_namespace_relative_subposet_index_type()

bool sheaf::data_converter::is_namespace_relative_subposet_index_type ( ) const
inline

◆ is_string_type()

bool sheaf::data_converter::is_string_type ( ) const
inline

True if this is a converter for a string type.

Definition at line 289 of file data_converter.h.

Referenced by data_converter(), externalize(), internalize(), and string_length_total().

◆ max_size()

size_t sheaf::data_converter::max_size ( ) const
inline

The maximum of internal_size() and external_size().

Definition at line 239 of file data_converter.h.

Referenced by data_converter(), externalize(), internalize(), and invariant().

◆ result()

void* sheaf::data_converter::result ( ) const
inline

The result of the conversion.

Definition at line 249 of file data_converter.h.

Referenced by clone(), invariant(), is_ancestor_of(), string_length(), and string_length_total().

◆ result_size()

size_t sheaf::data_converter::result_size ( ) const
inline

The allocated size of the result buffer.

Definition at line 259 of file data_converter.h.

Referenced by externalize(), internalize(), and invariant().

◆ string_length()

size_t sheaf::data_converter::string_length ( const char *  xbuf)
static

The number of characters in the string, including the terminator.

Precondition
  • xbuf != 0
Todo:
extend to other types of terminated strings.
Postcondition
  • result > 0

Definition at line 373 of file data_converter.cc.

References result(), and string_length_total().

Referenced by externalize(), internalize(), and string_length_total().

◆ string_length_total()

size_t sheaf::data_converter::string_length_total ( const void *  xbuf,
int  xitem_ct 
) const

The total number of characters, including the terminators in all the strings in the array of strings xbuf.

Precondition
Postcondition
  • result > 0

Definition at line 401 of file data_converter.cc.

References internalize(), is_string_type(), result(), and string_length().

Referenced by externalize(), and string_length().


The documentation for this class was generated from the following files: