Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
ELM provides several facilities to handle type and parametric types. More...
Namespaces | |
array | |
Classes | |
class | type_info< T > |
Typedefs | |
typedef signed char | int8 |
typedef unsigned char | uint8 |
typedef short | int16 |
typedef unsigned short | uint16 |
typedef int | int32 |
typedef unsigned int | uint32 |
typedef long | int64 |
typedef unsigned long | uint64 |
typedef uint64 | size |
typedef uint64 | offset |
typedef uint64 | uint |
typedef uint64 | intptr |
template<class T > | |
using | var = typename type_info< T >::var_t |
template<class T > | |
using | in = typename type_info< T >::in_t |
template<class T > | |
using | out = typename type_info< T >::out_t |
template<class T > | |
using | ret = typename type_info< T >::ret_t |
template<class T > | |
using | mut = typename type_info< T >::mut_t |
Functions | |
int | msb (t::uint32 i) |
int | msb (t::uint64 i) |
int | ones (t::uint8 i) |
t::uint32 | leastUpperPowerOf2 (t::uint32 v) |
t::uint64 | leastUpperPowerOf2 (t::uint64 v) |
t::uint32 | mult (t::uint32 a, t::uint32, bool &over) |
t::uint64 | mult (t::uint64 a, t::uint64, bool &over) |
t::uint32 | roundup (t::uint32 v, t::uint32 m) |
t::uint32 | rounddown (t::uint32 v, t::uint32 m) |
int | ones (t::uint16 i) |
int | ones (t::uint32 i) |
int | ones (t::uint64 i) |
template<class T > | |
T * | null (void) |
template<class T > | |
T & | single (void) |
template<class T > | |
void | put (var< T > &x, in< T > v) |
template<class T > | |
ret< T > | get (const var< T > &v) |
template<class T > | |
mut< T > | ref (var< T > &x) |
ELM provides several facilities to handle type and parametric types.
This definitions provide several facilities to work with integers. To use, one has to include <elm/int.h>.
This module provides reliable and OS-independent types to represent integers together with a list of efficiently-implemented functions to process them. These types are stored in the elm::t
sub-namespace and, if you are using the elm
namespace, are quickly accessed by syntax t::type
.
You can also use the null<T>() function to build easily typed null pointer.
Class elm::type_info<T> allows to get information from the type passed as the parametric argument. The following information are available:
In addition, elm::type_info<T> provides facilities to efficiently and powerfully manage types used in templates:
Notice that ELM provides type information for basic (integer, float, string) and composed types (pointer, references) but need the developer help for more complex types like classes, struct or unions. Either one can add the specialized type_info structure for the defined type:
Or just add a static member named "__type_name" in the class declaration:
Instead of using directly type_info<T> members, some shortcuts are available (and advised):
Users may also benefit from whole facilities of input/output, serialization and like for the enumerated type. First, the type_info must be specialized (in the header containing the enumeration declaration):
And then to provided the missing (usually in the source file providing implementation).
As the primitives provided by ELM, the values may examined with such a loop:
The include file <otawa/util/array.h> provides functions to handling arrays:
According to the type of the type of the items, these functions may invokes specific system functions to make faster this operation. Usually, only types without pointers can only be processed in this way (scalar data) but you can informs that your own class can be shallowly copied by specializing the type_info class:
#include <include/elm/type_info.h>
Shortcut to type_info<T>::in_t;
#include <include/elm/arch.h>
Signed 16-bit integer type.
#include <include/elm/arch.h>
Signed 32-bit integer type.
#include <include/elm/arch.h>
Signed 64-bit integer type.
#include <include/elm/arch.h>
Signed 8-bit integer type.
#include <include/elm/arch.h>
Integer sufficiently big to store a pointer (according to the system configuration).
#include <include/elm/type_info.h>
Shortcut to type_info<T>::mut_t;
#include <include/elm/arch.h>
Integer type to represent memory offset (according to the system configuration).
#include <include/elm/type_info.h>
Shortcut to type_info<T>::out_t;
#include <include/elm/type_info.h>
Shortcut to type_info<T>::ret_t;
#include <include/elm/arch.h>
Integer type to represent memory size (according to the system configuration).
#include <include/elm/arch.h>
Unsigned 16-bit integer type.
#include <include/elm/arch.h>
Unsigned 32-bit integer type.
#include <include/elm/arch.h>
Unsigned 64-bit integer type.
#include <include/elm/arch.h>
Unsigned 8-bit integer type.
#include <include/elm/type_info.h>
Shortcut to type_info<T>::var_t;
#include <include/elm/type_info.h>
Shortcut to type_info::get().
References type_info< T >::get().
Referenced by access_t< const cstring & >::set(), and access_t< const string & >::set().
#include <include/elm/int.h>
Get the least upper power of 2 for the given value. If the value is a power of two, return it else compute the least greater power.
v | Value to process. |
References elm::msb().
Referenced by Builder< K, T, Comparator< K > >::allocate().
#include <include/elm/int.h>
Get the least upper power of 2 for the given value. If the value is a power of two, return it else compute the least greater power.
v | Value to process. |
References elm::msb().
int msb | ( | t::uint32 | i | ) |
#include <include/elm/int.h>
Compute the position of the left-most bit to one.
i | Integer to test. |
Referenced by elm::leastUpperPowerOf2(), and elm::msb().
int msb | ( | t::uint64 | i | ) |
#include <include/elm/int.h>
Compute the position of the left-most bit to one.
i | Integer to test. |
References elm::msb().
#include <include/elm/int.h>
Perform multiplication on unsigned integer 32-bits.
a | First number to multiply. |
b | Second number to multiply. |
over | Set to true if overflow occurs. |
#include <include/elm/int.h>
Perform multiplication on unsigned integer 64-bits.
a | First number to multiply. |
b | Second number to multiply. |
over | Set to true if overflow occurs. |
|
inline |
#include <include/elm/types.h>
Build a typed null pointer from the template type.
T | Pointed object type. |
Referenced by Tree< K, T, C >::node_t::node_t().
|
inline |
#include <include/elm/int.h>
Count the number of ones in the given half-word.
i | Half-word to count ones in. |
References elm::countOnes().
|
inline |
#include <include/elm/int.h>
Count the number of ones in the given word.
i | Word to count ones in. |
References elm::countOnes().
|
inline |
#include <include/elm/int.h>
Count the number of ones in the given double-word.
i | Double-word to count ones in. |
References elm::countOnes().
|
inline |
#include <include/elm/int.h>
Count the number of ones in the given byte.
i | Byte to count ones in. |
References elm::countOnes().
Referenced by BitVector::countBits(), elm::countOnes(), WAHVector::countOnes(), and BitVector::countOnes().
#include <include/elm/type_info.h>
Shortcut to type_info::ref().
References type_info< T >::ref().
Referenced by XOMUnserializer::onPointer(), RefAttribute< T >::operator*(), elm::operator<<(), Ref< T >::operator=(), RefAttribute< T >::process(), and RefAttribute< T >::reset().
#include <include/elm/int.h>
Round upto upper multiple integer
v | Value to round. |
m | Multiple to round with. |
References elm::countOnes().
#include <include/elm/int.h>
Round upto upper multiple integer
v | Value to round. |
m | Multiple to round with. |
References elm::countOnes().
|
inline |
#include <include/elm/types.h>
Returns a singleton corresponding to the parameter type. The uniqueness of the return value is ensured, meaning that any call to this function will ever return the same singleton object. This function provides an easy and fast way to define a singleton.
T | Type of singleton. Must support default constructor. |
References elm::_.