SPRAAK
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | Data Fields
SprDT_EnumT Class Reference
+ Inheritance diagram for SprDT_EnumT:
+ Collaboration diagram for SprDT_EnumT:

Public Member Functions

virtual int read1 (const SprDT_EnumT *restrict dt, SprStream *restrict fd, void *restrict dst)
 
virtual int write1 (const SprDT_EnumT *restrict dt, SprStream *restrict fd, const void *restrict src)
 
virtual ssize_t skipN (const SprDT *restrict dt, SprStream *restrict fd, size_t Nel)
 
virtual char * str_cvt (const SprDT_EnumT *restrict dt, void *restrict dst, const char *restrict str)
 
virtual void * cpy (const SprDT *dt, void *dst, const void *src)
 
virtual void reserve_dt (SprDT_EnumT *restrict dt)
 
virtual void release_dt (SprDT_EnumT *restrict dt)
 
- Public Member Functions inherited from SprDT
virtual int read1 (const SprDT *restrict dt, SprStream *restrict fd, void *restrict dst)
 
virtual ssize_t readN (const SprDT *restrict dt, SprStream *restrict fd, void *restrict dst, size_t Nel)
 
virtual ssize_t readNi (const SprDT *restrict dt, SprStream *restrict fd, void *restrict dst, size_t Nel, size_t offs_next)
 
virtual int write1 (const SprDT *restrict dt, SprStream *restrict fd, const void *restrict src)
 
virtual int writeN (const SprDT *restrict dt, SprStream *restrict fd, const void *restrict src, size_t Nel)
 
virtual int writeNi (const SprDT *restrict dt, SprStream *restrict fd, const void *restrict src, size_t Nel, size_t offs_next)
 
virtual SprDTRead1Func get_read1_func (const SprDT *dt, const SprStream *fd)
 
virtual SprDTReadNFunc get_readN_func (const SprDT *dt, const SprStream *fd)
 
virtual SprDTReadNiFunc get_readNi_func (const SprDT *dt, const SprStream *fd)
 
virtual SprDTWrite1Func get_write1_func (const SprDT *dt, const SprStream *fd)
 
virtual SprDTWriteNFunc get_writeN_func (const SprDT *dt, const SprStream *fd)
 
virtual SprDTWriteNiFunc get_writeNi_func (const SprDT *dt, const SprStream *fd)
 
virtual SprDTSkipNFunc get_skipN_func (const SprDT *dt, const SprStream *fd)
 
virtual char * str_cvt (const SprDT *restrict dt, void *restrict dst, const char *restrict str)
 
virtual void free (const SprDT *restrict dt, void *restrict ptr)
 
virtual SprDynStr str (const SprDT *restrict dt, const void *restrict src)
 
virtual ssize_t print (const SprDT *restrict dt, SprStream *restrict fd, const void *restrict src)
 
virtual void * cvt1 (const SprDT *dt_dst, void *restrict dst, const SprDT *dt_src, const void *restrict src)
 
virtual void * cvtN (const SprDT *dt_dst, void *restrict dst, const SprDT *dt_src, const void *restrict src, size_t Nel)
 
virtual void * cvtNsi (const SprDT *dt_dst, void *restrict dst, const SprDT *dt_src, const void *restrict src, size_t Nel, size_t offs_src_next)
 
virtual void * cvtNdi (const SprDT *dt_dst, void *restrict dst, const SprDT *dt_src, const void *restrict src, size_t Nel, size_t offs_dst_next)
 
virtual void * cvtNsdi (const SprDT *dt_dst, void *restrict dst, const SprDT *dt_src, const void *restrict src, size_t Nel, size_t offs_src_next, size_t offs_dst_next)
 
virtual SprDTCvt1Func get_cvt1_func (const SprDT *dt_dst, const SprDT *dt_src, SprDTCvtAux **aux_data)
 
virtual SprDTCvtNFunc get_cvtN_func (const SprDT *dt_dst, const SprDT *dt_src, SprDTCvtAux **aux_data)
 
virtual SprDTCvtNsiFunc get_cvtNsi_func (const SprDT *dt_dst, const SprDT *dt_src, SprDTCvtAux **aux_data)
 
virtual SprDTCvtNsiFunc get_cvtNdi_func (const SprDT *dt_dst, const SprDT *dt_src, SprDTCvtAux **aux_data)
 
virtual SprDTCvtNsdiFunc get_cvtNsdi_func (const SprDT *dt_dst, const SprDT *dt_src, SprDTCvtAux **aux_data)
 
virtual void reserve_dt (SprDT *restrict dt)
 
virtual void release_dt (SprDT *restrict dt)
 

Data Fields

base::< SprDTinterface_
 
unsigned int lock_cnt
 
void * alloc_data
 
- Data Fields inherited from SprDT
base::< SprObjectinterface_
 
int dsize
 
unsigned int dalign
 
int dsize_packed
 

Additional Inherited Members

- Protected Attributes inherited from SprDT
unsigned int flags
 
const char * desc_str
 

Detailed Description

A enumeration type. The internal values (in memory) are binary numbers. The external values (even in binary streams) are strings.

Note
The list of possible values is assumed to be small (linear search).

Member Function Documentation

virtual int SprDT_EnumT::read1 ( const SprDT_EnumT *restrict  dt,
SprStream *restrict  fd,
void *restrict  dst 
)
virtual

Read a single data element from the given stream fd. The binary data is written to dst. It is the callers responsability to assure that dst is large enough to contain the whole data element.

Returns
(-1) on error and 0 on success.
Note
When the read fails, a simple check of fd->eof allows the caller to distinguish between read errors and an end-of-file condition. An additional check if fd->buf_rptr equals fd->buf_end allows the caller to check for partial data when encountering an error or an end-of-file condition.
virtual int SprDT_EnumT::write1 ( const SprDT_EnumT *restrict  dt,
SprStream *restrict  fd,
const void *restrict  src 
)
virtual

Write a single data element of which the binary data can be found at address src to the given stream fd.

Returns
(-1) on error and 0 on success.
virtual ssize_t SprDT_EnumT::skipN ( const SprDT *restrict  dt,
SprStream *restrict  fd,
size_t  Nel 
)
virtual

Skip Nel elements in the input stream fd.

Returns
0 if all requested elements were skipped successfully, the number of elements short of Nel when encountering an EOF, and (-1) on encountering an error (even if some elements were skipped).

Reimplemented from SprDT.

virtual char* SprDT_EnumT::str_cvt ( const SprDT_EnumT *restrict  dt,
void *restrict  dst,
const char *restrict  str 
)
virtual

Convert to the initial part of the dst to a data element of this type. The binary data is written to dst. Leading space is ignored. The conversion stops at the first character that does not fit the data type.

Returns
The address of the first character not belonging to this data type or (NULL) if the conversion failed.
Note
This method does not issue a warning when the conversion fails!
virtual void* SprDT_EnumT::cpy ( const SprDT dt,
void *  dst,
const void *  src 
)
virtual

Copy the item *src of type dt to *dst (same type).

Returns
dst on success and NULL on failure.

Reimplemented from SprDT.

virtual void SprDT_EnumT::reserve_dt ( SprDT_EnumT *restrict  dt)
virtual

Some complex data type descriptors (things of the type SprDT) are dynamic allocated, and hence must be released when no longer needed (or reserved when a copy is made). This method will reserve the type description (augment some counter with 1), making sure the dynamic allocated structure will not be freed before a matching SprDT::release_dt() method is called.

Note
Checking if some data type descriptor requires calls to the SprDT::reserve_dt() and SprDT::release_dt() methods can be done in two ways: (1) check the documentation if the type is known, or (2) check if the SPR_DT_REQ_RR flag in dt->flags is set.
The SprDT::reserve_dt() and SprDT::release_dt() methods can be called for any data type descriptor. Those that don't need is, will simply do nothing.
virtual void SprDT_EnumT::release_dt ( SprDT_EnumT *restrict  dt)
virtual

Some complex data type descriptors (things of the type SprDT) are dynamic allocated, and hence must be released when no longer needed (or reserved when a copy is made). This method will reserve the type description (augment some counter with 1), making sure the dynamic allocated structure will not be freed before a matching SprDT::release_dt() method is called.

Note
Checking if some data type descriptor requires calls to the SprDT::reserve_dt() and SprDT::release_dt() methods can be done in two ways: (1) check the documentation if the type is known, or (2) check if the SPR_DT_REQ_RR flag in dt->flags is set.
The SprDT::reserve_dt() and SprDT::release_dt() methods can be called for any data type descriptor. Those that don't need is, will simply do nothing.

Field Documentation

base::<SprDT> SprDT_EnumT::interface_
unsigned int SprDT_EnumT::lock_cnt

If created dynamically, we need to clean-up when no longer needed.

void* SprDT_EnumT::alloc_data