libpnicore
Public Types | Public Member Functions | Private Member Functions | Private Attributes
pni::core::binary_t< NTYPE > Class Template Reference

Binary data type. More...

#include <binary.hpp>

Public Types

typedef NTYPE storage_type
 native type that is used for binary data
 

Public Member Functions

 binary_t ()
 default constructor
 
 binary_t (const storage_type &value)
 constructor
 
 binary_t (const binary_t< storage_type > &o)
 copy constructor
 
 operator NTYPE () const
 

Private Member Functions

const binary_t< storage_type > & operator+= (const binary_t< storage_type > &b)=delete
 unary addition operator - deleted
 
const binary_t< storage_type > & operator-= (const binary_t< storage_type > &b)=delete
 unary subtraction operator - delete
 
const binary_t< storage_type > & operator*= (const binary_t< storage_type > &b)=delete
 unary multiplication operator
 
const binary_t< storage_type > & operator/= (const binary_t< storage_type > &b)=delete
 unary division operator - delete
 

Private Attributes

storage_type _value
 data value
 

Detailed Description

template<typename NTYPE>
class pni::core::binary_t< NTYPE >

This class represents a binary data type. Typically binary data is represented by a typedef to an unsigned char type. However, this has an inconvenience: the unsigned char and the typedef for binary are indistinguishable by the compiler. Thus, such a binary type cannot be used for function overloading or for template specialization - it would always be treated by the compiler as the underlying unsigned char type.

To circumvent this problem libpnicore defines this binary type which can be used instead of a simple typedef to unsigned char. The BinaryType template has several advantages:

Thus this type cannot be used for arithmetic operations directly. Its primary purpose is to hold uninterpreted binary data for transfer. However it can be converted to the native type used to hold the data. Stream operators are provided for IO operations using binary data.

Template Parameters
NTYPEnative type used to store binary data

Member Function Documentation

template<typename NTYPE>
pni::core::binary_t< NTYPE >::operator NTYPE ( ) const
inline

conversion operator

Allows a conversion from BinaryType<NTYPE> to the underlying NTYPE.


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