Yate
|
A slice vector. More...
#include <yatemath.h>
Public Member Functions | |
SliceVector () | |
SliceVector (const SliceVector &other) | |
SliceVector (unsigned int len, const Obj *buf=0, unsigned int maxLen=0) | |
SliceVector (const SliceVector &v1, const SliceVector &v2) | |
SliceVector (const SliceVector &v1, const SliceVector &v2, const SliceVector &v3) | |
SliceVector (const SliceVector &other, unsigned int offs, unsigned int len=0) | |
virtual | ~SliceVector () |
Obj * | data (unsigned int offs, unsigned int len) |
const Obj * | data (unsigned int offs, unsigned int len) const |
Obj * | data (unsigned int offs=0) |
const Obj * | data (unsigned int offs=0) const |
Obj * | data (unsigned int offs, unsigned int len, Obj *&eod) |
const Obj * | data (unsigned int offs, unsigned int len, const Obj *&eod) const |
unsigned int | length () const |
unsigned int | maxLen () const |
unsigned int | size () const |
unsigned int | available (unsigned int offs, int len=-1) const |
unsigned int | availableClamp (unsigned int clamp, unsigned int offs=0, int len=-1) const |
virtual unsigned int | vectorSize () const |
bool | resize (unsigned int len) |
void | resizeMax () |
void | steal (SliceVector &other) |
void | resetStorage (unsigned int len, unsigned int maxLen=0) |
bool | setSlice (const SliceVector &other, unsigned int offs=0, unsigned int len=0) |
SliceVector | head (unsigned int len) const |
bool | head (SliceVector &dest, unsigned int len) const |
SliceVector | tail (unsigned int len) const |
bool | tail (SliceVector &dest, unsigned int len) const |
SliceVector | slice (unsigned int offs, unsigned int len) const |
bool | slice (SliceVector &dest, unsigned int offs, unsigned int len=0) const |
bool | copy (const SliceVector &src, unsigned int len, unsigned int offs=0, unsigned int srcOffs=0) |
void | bzero (unsigned int offs, unsigned int len) |
void | bzero () |
void | fill (const Obj &value) |
void | apply (void(*func)(Obj &)) |
Obj | sum () const |
Obj | sumApply (Obj(*func)(const Obj &)) const |
float | sumApplyF (float(*func)(const Obj &)) const |
bool | sum (const SliceVector &other) |
void | sum (const Obj &value) |
bool | sub (const SliceVector &other) |
void | sub (const Obj &value) |
bool | mul (const SliceVector &other) |
void | mul (const Obj &value) |
void | mul (float value) |
Obj & | operator[] (unsigned int index) |
const Obj & | operator[] (unsigned int index) const |
Obj & | operator[] (signed int index) |
const Obj & | operator[] (signed int index) const |
bool | operator== (const SliceVector &other) const |
bool | operator!= (const SliceVector &other) const |
SliceVector & | operator= (const SliceVector &other) |
SliceVector & | operator+= (const SliceVector &other) |
SliceVector & | operator+= (const Obj &value) |
SliceVector & | operator-= (const SliceVector &other) |
SliceVector & | operator-= (const Obj &value) |
SliceVector & | operator*= (const SliceVector &other) |
SliceVector & | operator*= (const Obj &value) |
SliceVector & | operator*= (float value) |
bool | equals (const SliceVector &other) const |
String & | dump (String &buf, String &(*func)(String &s, const Obj &o, const char *sep, const char *fmt), const char *sep=",", const char *fmt=0) const |
String & | dump (String &buf, unsigned int lineLen, String &(*func)(String &s, const Obj &o, const char *sep, const char *fmt), unsigned int offset=0, const char *linePrefix=0, const char *suffix="\r\n", const char *sep=",", const char *fmt=0) const |
String & | hexify (String &buf, char sep=0) const |
String & | dumpHex (String &buf, unsigned int lineLen, unsigned int offset=0, const char *linePrefix=0, const char *suffix="\r\n") const |
int | unHexify (const char *str, unsigned int len, int sep=255) |
int | unHexify (const String &str, int sep=255) |
![]() | |
virtual | ~MathVectorBase () |
![]() | |
GenObject () | |
virtual | ~GenObject () |
virtual bool | alive () const |
virtual void | destruct () |
virtual const String & | toString () const |
virtual const String & | traceId () const |
virtual void * | getObject (const String &name) const |
NamedCounter * | getObjCounter () const |
NamedCounter * | setObjCounter (NamedCounter *counter) |
Static Public Member Functions | |
static unsigned int | objSize () |
static unsigned int | size (unsigned int len) |
![]() | |
static void * | getObject (const String &name, const GenObject *obj) |
static bool | getObjCounting () |
static void | setObjCounting (bool enable) |
static NamedCounter * | getObjCounter (const String &name, bool create=true) |
static ObjList & | getObjCounters () |
Protected Member Functions | |
Obj * | end (Obj *start, unsigned int len) |
const Obj * | end (const Obj *start, unsigned int len) const |
bool | setData (Obj *data=0, unsigned int len=0, unsigned int maxLen=0) |
bool | initStorage (unsigned int len, const Obj *data=0, unsigned int maxLen=0) |
bool | initSlice (bool del, const SliceVector &other, unsigned int offs=0, unsigned int len=0) |
Protected Attributes | |
RefStorage * | m_storage |
Obj * | m_data |
unsigned int | m_length |
unsigned int | m_maxLen |
A slice vector.
Template for vectors holding a fixed storage and a slice in it. This class works with objects not holding pointers: it uses memcpy to copy data
|
inline |
Constructor
Referenced by SliceVector< Obj >::slice(), and SliceVector< Obj >::tail().
|
inline |
Copy constructor. Builds a slice of another vector
other | Original vector |
|
inlineexplicit |
Constructor. Build the vector storage
len | Length of data |
buf | Optional init buffer ('len' elements will be copied from it to storage) |
maxLen | Optional vector maximum length (it will be adjusted to be at least len) |
References SliceVector< Obj >::maxLen().
|
inlineexplicit |
Constructor. Build a vector by concatenating two existing ones
v1 | The first vector |
v2 | The second vector |
References SliceVector< Obj >::data(), SliceVector< Obj >::length(), SliceVector< Obj >::resizeMax(), RefStorage::set(), and SliceVector< Obj >::size().
|
inlineexplicit |
Constructor. Build a vector by concatenating three existing ones
v1 | The first vector |
v2 | The second vector |
v3 | The third vector |
References SliceVector< Obj >::data(), SliceVector< Obj >::length(), SliceVector< Obj >::resizeMax(), RefStorage::set(), and SliceVector< Obj >::size().
|
inlineexplicit |
Constructor. Builds a slice of another vector
other | Original vector |
offs | Offset in the original vector |
len | The number of elements (0 to use all available from offset) |
|
inlinevirtual |
Destructor
|
inline |
Apply an unary function to all elements in this vector
func | Function to apply |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
|
inline |
Retrieve the available number of elements from given offset (not more than required number)
offs | The offset |
len | Required number of elements (-1: all available from offset) |
References SliceVector< Obj >::length().
Referenced by SliceVector< Obj >::availableClamp(), and SliceVector< Obj >::data().
|
inline |
Retrieve the available number of elements from given offset. Clamp the available number of elements to requested value
clamp | Maximum number of elements to check |
offs | The offset |
len | Required number of elements (-1: all available from offset) |
References SliceVector< Obj >::available().
|
inline |
Fill the buffer with 0
offs | The offset |
len | The number of elements to retrieve (must not be 0) |
References SliceVector< Obj >::data(), RefStorage::fill(), and SliceVector< Obj >::size().
|
inline |
Fill the buffer with 0
References SliceVector< Obj >::data(), RefStorage::fill(), and SliceVector< Obj >::size().
|
inline |
Copies elements from another vector to this one. NOTE: This method don't check for overlapping data
src | The source vector |
len | The number of elements to copy |
offs | The start index in our vector |
srcOffs | The start index in the source vector |
References RefStorage::copy(), SliceVector< Obj >::data(), and SliceVector< Obj >::size().
|
inline |
Get a pointer to data if 'len' elements are available from offset
offs | The offset |
len | The number of elements to retrieve (must not be 0) |
References SliceVector< Obj >::length().
Referenced by SliceVector< Obj >::apply(), SliceVector< Obj >::bzero(), SliceVector< Obj >::copy(), SliceVector< Obj >::data(), SliceVector< Obj >::dump(), SliceVector< Obj >::equals(), SliceVector< Obj >::fill(), SliceVector< Obj >::hexify(), SliceVector< Obj >::mul(), SliceVector< Obj >::SliceVector(), SliceVector< Obj >::sub(), SliceVector< Obj >::sum(), SliceVector< Obj >::sumApply(), and SliceVector< Obj >::sumApplyF().
|
inline |
Get a pointer to data if 'len' elements are available from offset
offs | The offset |
len | The number of elements to retrieve (must not be 0) |
References SliceVector< Obj >::length().
|
inline |
Get a pointer to data from offset to vector end
offs | The offset |
References SliceVector< Obj >::available(), and SliceVector< Obj >::data().
|
inline |
Get a pointer to data from offset to vector end
offs | The offset |
References SliceVector< Obj >::available(), and SliceVector< Obj >::data().
|
inline |
Get a pointer to data from offset to vector end
offs | The offset |
len | The number of elements to retrieve (must not be 0) |
eod | Pointer to be filled with end of data element (pointer to first element after requested number of elements) |
References SliceVector< Obj >::data().
|
inline |
Get a pointer to data from offset to vector end
offs | The offset |
len | The number of elements to retrieve (must not be 0) |
eod | Pointer to be filled with end of data element (pointer to first element after requested number of elements) |
References SliceVector< Obj >::data().
|
inline |
Dump data to a string (append)
buf | Destination string |
func | Pointer to function who appends the object to a String (0 to dump all available from offset) |
sep | Vector elements separator |
fmt | Optional format to use |
References String::append(), SliceVector< Obj >::data(), and SliceVector< Obj >::length().
Referenced by SliceVector< Obj >::dump().
|
inline |
Dump this vector to string, split it and append lines to a buffer. Line prefix length is not included when line length is calculated. Separator length is included in line length
buf | Destination string |
lineLen | Line length in bytes |
func | Pointer to function who append the object to a String |
offset | Offset in first line (if incomplete). No data will be added on first line if offset is greater then line length |
linePrefix | Prefix for new lines. Empty string to use the suffix |
suffix | String to always add to final result (even if no data dumped) |
sep | Vector elements separator |
fmt | Optional format to use |
References String::append(), SliceVector< Obj >::data(), SliceVector< Obj >::dump(), SliceVector< Obj >::length(), String::length(), and TelEngine::null().
|
inline |
Hexify data, split it and append lines to a string
buf | Destination string |
lineLen | Line length, characters to copy |
offset | Offset in first line (if incomplete). No data will be added on first line if offset is greater then line length |
linePrefix | Prefix for new lines. Set it to empty string or 0 to use the suffix |
suffix | End of line for the last line |
References RefStorage::dumpSplit(), and SliceVector< Obj >::hexify().
|
inline |
Compare this vector to another one (compare storage)
other | Vector to compare with |
References SliceVector< Obj >::data(), RefStorage::equals(), SliceVector< Obj >::length(), and SliceVector< Obj >::size().
Referenced by SliceVector< Obj >::operator!=(), and SliceVector< Obj >::operator==().
|
inline |
Fill the vector with a given value
value | The value to be set in this vector |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
|
inline |
Retrieve vector head
len | The number of elements to retrieve |
References SliceVector< Obj >::slice().
|
inline |
Retrieve vector head
dest | Destination vector |
len | The number of elements to retrieve |
References SliceVector< Obj >::slice().
Hexify data
buf | Destination string |
sep | Optional separator |
References SliceVector< Obj >::data(), String::hexify(), and SliceVector< Obj >::size().
Referenced by SliceVector< Obj >::dumpHex().
|
inline |
Get the length of the vector
Referenced by SliceVector< Obj >::apply(), SliceVector< Obj >::available(), SliceVector< Obj >::data(), SliceVector< Obj >::dump(), SliceVector< Obj >::equals(), SliceVector< Obj >::fill(), SliceVector< Obj >::mul(), SliceVector< Obj >::operator*=(), SliceVector< Obj >::operator+=(), SliceVector< Obj >::operator-=(), SliceVector< Obj >::size(), SliceVector< Obj >::SliceVector(), SliceVector< Obj >::sub(), SliceVector< Obj >::sum(), SliceVector< Obj >::sumApply(), SliceVector< Obj >::sumApplyF(), SliceVector< Obj >::tail(), and BitVector::tail().
|
inline |
Get the maximum length of the vector
Referenced by SliceVector< Obj >::resetStorage(), SliceVector< Obj >::resize(), SliceVector< Obj >::resizeMax(), and SliceVector< Obj >::SliceVector().
|
inline |
Multiply this vector with another one
other | Vector to multiply with |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
Referenced by SliceVector< Obj >::operator*=().
|
inline |
Multiply this vector with a value
value | Value to multiply with |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
|
inline |
Multiply this vector with a value
value | Value to multiply with |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
|
inlinestatic |
Retrieve the object size
Referenced by SliceVector< Obj >::size(), and SliceVector< Obj >::unHexify().
|
inline |
Inequality operator
other | Original vector |
References SliceVector< Obj >::equals().
|
inline |
Multiply this vector with another one
other | Vector to multiply with |
References SliceVector< Obj >::length(), and SliceVector< Obj >::mul().
|
inline |
Multiply this vector with a value
value | Value to multiply with |
References SliceVector< Obj >::mul().
|
inline |
Multiply this vector with a value
value | Value to multiply with |
References SliceVector< Obj >::mul().
|
inline |
Sum this vector with another one
other | Vector to sum with this one |
References SliceVector< Obj >::length(), and SliceVector< Obj >::sum().
|
inline |
Add a value to each element of the vector
value | Value to add |
References SliceVector< Obj >::sum().
|
inline |
Substract another vector from this one
other | Vector to substract |
References SliceVector< Obj >::length(), and SliceVector< Obj >::sub().
|
inline |
Substract a value from each element of the vector
value | Value to substract |
References SliceVector< Obj >::sub().
|
inline |
Asignment operator. Builds a slice of another vector
other | Original vector |
References SliceVector< Obj >::setSlice().
|
inline |
Equality operator
other | Original vector |
References SliceVector< Obj >::equals().
|
inline |
Indexing operator with unsigned int
index | Index of element to retrieve |
|
inline |
Indexing operator with unsigned int
index | Index of element to retrieve |
|
inline |
Indexing operator with signed int
index | Index of element to retrieve |
|
inline |
Indexing operator with signed int
index | Index of element to retrieve |
|
inline |
Change the vector storage (re-allocate)
len | New vector length (0 to clear vector data) |
maxLen | Optional vector maximum length (it will be adjusted to be at least len) |
References SliceVector< Obj >::maxLen().
|
inline |
Change the vector length without changing the contents. If the vector length is increased the new elements' value are not reset
len | New vector length |
References SliceVector< Obj >::maxLen().
Referenced by SliceVector< Obj >::resizeMax().
|
inline |
Change the vector length to maximum allowed without changing the contents
References SliceVector< Obj >::maxLen(), and SliceVector< Obj >::resize().
Referenced by SliceVector< Obj >::SliceVector().
|
inline |
Set a slice containing another vector
other | Original vector |
offs | Offset in the original vector |
len | The number of elements (0 to use all available from offset) |
Referenced by SliceVector< Obj >::operator=().
|
inline |
Get the vector size in bytes
References SliceVector< Obj >::length().
Referenced by SliceVector< Obj >::bzero(), SliceVector< Obj >::copy(), SliceVector< Obj >::equals(), SliceVector< Obj >::hexify(), SliceVector< Obj >::SliceVector(), and SliceVector< Obj >::vectorSize().
|
inlinestatic |
Retrieve the length in bytes of a buffer containing 'count' objects
len | Buffer length |
References SliceVector< Obj >::objSize().
|
inline |
Retrieve a vector slice
offs | Offset in our vector |
len | The number of elements to retrieve |
References SliceVector< Obj >::SliceVector().
Referenced by SliceVector< Obj >::head().
|
inline |
Set a slice of this vector to another one. The destination vector will be changed
dest | Destination vector |
offs | Offset in our vector |
len | The number of elements (0 to use all available from offset) |
|
inline |
Steal other vector's data
other | Original vector |
|
inline |
Substract another vector from this one
other | Vector to substract |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
Referenced by SliceVector< Obj >::operator-=().
|
inline |
Substract a value from each element of the vector
value | Value to substract |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
|
inline |
Sum vector values
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
Referenced by SliceVector< Obj >::operator+=().
|
inline |
Sum this vector with another one
other | Vector to sum with this one |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
|
inline |
Add a value to each element of the vector
value | Value to add |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
|
inline |
Apply a function to all vector elements and take the sum of the results
func | Function to apply |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
|
inline |
Apply a function to all vector elements and take the sum of the results
func | Function to apply |
References SliceVector< Obj >::data(), and SliceVector< Obj >::length().
|
inline |
Retrieve vector tail (last elements)
len | The number of elements to retrieve |
References SliceVector< Obj >::length(), and SliceVector< Obj >::SliceVector().
|
inline |
Retrieve vector tail (last elements)
len | The number of elements to retrieve |
dest | Destination vector |
References SliceVector< Obj >::length().
|
inline |
Reset storage from a hexadecimal string representation. Clears the vector at start, i.e. the vector will be empty on failure. The vector may be empty on success also. Each octet must be represented in the input string with 2 hexadecimal characters. If a separator is specified, the octets in input string must be separated using exactly 1 separator. Only 1 leading or 1 trailing separators are allowed.
str | Input character string |
len | Length of input string |
sep | Separator character used between octets. [-128..127]: expected separator (0: no separator is expected). Detect the separator if other value is given |
References DataBlock::data(), DataBlock::length(), SliceVector< Obj >::objSize(), and DataBlock::unHexify().
Referenced by SliceVector< Obj >::unHexify().
|
inline |
Unhexify data
str | Input string |
sep | Separator character used between octets |
References String::c_str(), String::length(), and SliceVector< Obj >::unHexify().
|
inlinevirtual |
Retrieve vector size in bytes
Implements MathVectorBase.
References SliceVector< Obj >::size().