Data types and type management¶
pni::type_id_t
¶
-
enum
pni
::
type_id_t
¶ type codes for PNI data types
Typed enumeration with type IDs.
Values:
-
enumerator
None
¶ no data type
-
enumerator
Int8
¶ signed 8Bit integer
-
enumerator
UInt8
¶ unsigned 8Bit integer
-
enumerator
Int16
¶ signed 16Bit integer
-
enumerator
UInt16
¶ unsigned 16Bit integer
-
enumerator
Int32
¶ signed 32Bit integer
-
enumerator
UInt32
¶ unsigned 32Bit integer
-
enumerator
Int64
¶ signed 64Bit integer
-
enumerator
UInt64
¶ unsigned 64Bit integer
-
enumerator
Float32
¶ 32Bit IEEE floating point
-
enumerator
Float64
¶ 64Bit IEEE floating point
-
enumerator
Float128
¶ 128Bit IEEE floating point
-
enumerator
Complex32
¶ 32Bit IEEE floating point complex
-
enumerator
Complex64
¶ 64Bit IEEE floating point complex
-
enumerator
Complex128
¶ 128Bit IEEE floating point complex
-
enumerator
String
¶ String type.
-
enumerator
Binary
¶ binary data
-
enumerator
Bool
¶ integer boolean data
-
enumerator
EBool
¶ enum boolean data
-
enumerator
Operators¶
Predicates¶
-
PNINEXUS_EXPORT bool
pni
::
is_numeric
(type_id_t tid)¶ check numeric type
Returns true if the type associated with tid belongs to the numeric types.
- Return
true if tid refers to a numeric type, false otherwise
- Parameters
tid
: type ID of the type to check
-
PNINEXUS_EXPORT bool
pni
::
is_integer
(type_id_t tid)¶ check integer type
Returns true if the type associated with tid belongs to the integer types.
- Return
true if tid refers to an integer type, false otherwise
- Parameters
tid
: type ID of the type to check
-
PNINEXUS_EXPORT bool
pni
::
is_complex
(type_id_t tid)¶ check complex type
Returns true if the type associated with tid belongs to the complex types.
- Return
true if tid refers to a complex type, false otherwise
- Parameters
tid
: type ID of the type to check
-
PNINEXUS_EXPORT bool
pni
::
is_float
(type_id_t tid)¶ check float type
Returns true if the type associated with the tid belongs to the float types.
- Return
true if tid refers to a float type, false otherwise
- Parameters
tid
: id of the type to check
-
PNINEXUS_EXPORT bool
pni
::
is_checked_convertible
(type_id_t source_tid, type_id_t target_tid)¶ check if two types are checked convertible
Returns true if two types, determined by their type ID, are checked convertible.
- Return
true if types are checked convertible, false otherwise
- Parameters
source_tid
: ID of the source typetarget_tid
: ID of the target type
-
PNINEXUS_EXPORT bool
pni
::
is_unchecked_convertible
(type_id_t source_tid, type_id_t target_tid)¶ check if two types are unchecked convertible
Returns true if two types, determined by their type ID, are unchecked convertible.
- Return
true if types are unchecked convertible, false otherwise
- Parameters
source_tid
: ID of the source typetarget_tid
: ID of the target type
-
PNINEXUS_EXPORT bool
pni
::
is_convertible
(type_id_t source_tid, type_id_t target_tid)¶ check if two types are unchecked convertible
Returns true if two types, determined by their type ID, are convertible.
- Return
true if types are , false otherwise
- Parameters
source_tid
: ID of the source typetarget_tid
: ID of the target type
Utility functions¶
-
PNINEXUS_EXPORT type_id_t
pni
::
type_id_from_str
(const string &s)¶ get a type ID from a string
Returns the type ID for a particular string representation of a type. If the string passed is not a valid type representation an exception will be thrown.
- Return
corresponding type ID
- Exceptions
key_error
: if the string does not describe a type
- Parameters
s
: string representation of the type
-
PNINEXUS_EXPORT string
pni
::
str_from_type_id
(type_id_t id)¶ get the string rep. for a type
Returns the string representation for a type determined by its type id. If the type determined by the ID does not have a string representation an exception will be thrown.
- Return
string representation of the type
- Exceptions
key_error
: if the type has no string representation
- Parameters
id
: type ID of the type
-
template<typename
GeneralT
>
type_id_tpni
::
type_id
(const GeneralT&)¶ get type id of an object
This function returns the type ID of an instance of an object. In the case of scalar data the type if a variable is returned. If the argument passed is a container the type id of the element type is returned.
- Return
type ID
- Template Parameters
GeneralT
: type if the object
pni::type_class_t
¶
-
enum
pni
::
type_class_t
¶ type class definitions
classes of data types provided by the PNI utility library
Values:
-
enumerator
None
¶ unspecified type
-
enumerator
Integer
¶ integer type
-
enumerator
Float
¶ floating point type
-
enumerator
Binary
¶ binary data type
-
enumerator
Bool
¶ boolean data type
-
enumerator
Complex
¶ complex data type
-
enumerator
String
¶ class for string types
-
enumerator
pni::bool_t
¶
-
class
pni
::
bool_t
¶ boolean type
There is a particular problem when using the standard bool type in connection with std::vector. The std::vector template is overloaded for bool in a sense that each boolean value is stored in an individual bit. Thus elements cannot be addressed. Thus std::vector<bool> cannot be used in connection with libpninexus. This type prevents the C++ compiler to overload std:vector<bool_t> making boolean values available for libpninexus.
pni::none
¶
-
struct
none
¶ none type
This type is used in situations where a type for initialization is required but not provided (or at the moment not available). It thus denotes the absence of type information.
Operators¶
-
PNINEXUS_EXPORT std::ostream &
pni
::
operator<<
(std::ostream &stream, const none &n)¶ output stream for none
Using the none type with the output stream operator has no effect and does not modify the stream.
- Return
reference to the output stream
- Parameters
stream
: reference the output streamn
: none instance
-
PNINEXUS_EXPORT std::istream &
pni
::
operator>>
(std::istream &stream, none &n)¶ input stream for none
Using the none type with the input stream operator has no effect and does not modify the stream.
- Return
reference to the input stream
- Parameters
stream
: reference the input streamn
: none instance
pni::binary_t
¶
-
template<typename
NativeT
>
classpni
::
binary_t
¶ Binary data type.
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
libpninexus
defines this binary type which can be used instead of a simple typedef to unsigned char. The BinaryType template has several advantages:it can be distinguished from the type used to store binary data
all arithmetic operators are stripped from the type.
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
NativeT
: native type used to store binary data
Public Functions
-
binary_t
()¶ default constructor
-
binary_t
(const storage_type &value)¶ constructor
-
binary_t
(const binary_t<storage_type> &o)¶ copy constructor
-
operator NativeT
() const¶ conversion operator
Allows a conversion from BinaryType<NativeT> to the underlying NativeT.
-
template<typename
NativeT
>
std::ostream &pni
::
operator<<
(std::ostream &os, const binary_t<NativeT> &o)¶ output stream operator for binary data
This is the overloaded output stream operator for binary data.
- Return
reference to the modified output stream
- Template Parameters
NativeT
: basic type for binary
- Parameters
os
: reference to the output streamo
: reference to the binary object