#include <data.h>
Classes | |
class | Storage |
Public Member Functions | |
Data (size_t s=0, unsigned priority=0) throw (std::bad_alloc) | |
Constructor initializes buffer to a specific size. | |
Data (const void *d, size_t s, unsigned priority=0, DataMode mode=COPY) throw (std::bad_alloc) | |
Constructor initializes buffer with a copy of specific data. | |
Data (const Data &other) | |
Copy constructor. | |
~Data () | |
Destructor. | |
uint8_t * | data () |
Pointer to the actual data. | |
const uint8_t * | data () const |
Constant pointer to the actual data. | |
bool | set_data (const void *newdata, size_t newsize, DataMode mode=COPY) throw (std::bad_alloc) |
Sets the buffer to specific data. | |
size_t | size () const |
Current buffer size. | |
bool | resize (size_t s) throw (std::bad_alloc) |
Resize buffer to size s. | |
Data | clone () const |
Performs a deep copy of this data object. | |
operator bool () | |
operator bool () const | |
operator uint8_t * () | |
Cast to a 1-octet pointer. | |
operator const uint8_t * () const | |
Cast to a 1-octet const pointer. | |
operator char * () | |
operator const char * () const | |
operator void * () | |
operator const void * () const | |
uint8_t & | operator[] (const ssize_t offset) |
const uint8_t & | operator[] (const ssize_t offset) const |
std::string | hex_string (std::string separator=std::string()) const |
Returns a hex string representation of the data. | |
void | clear () |
Releases any allocated memory and resets size to 0. | |
const TimeVal & | time () const |
Returns the timeval associated with this data item. | |
void | set_time (const TimeVal &) |
Sets the timeval associated with this data item. | |
void | set_current_time () |
Sets the timeval associated with this data item to the current time. | |
unsigned | priority () const |
Get the priority, where 0 is the lowest priority. | |
void | set_priority (unsigned p) |
Set the priority, where 0 is the lowest priority. | |
bool | operator< (const Data &other) const |
bool | operator<= (const Data &other) const |
bool | operator== (const Data &other) const |
bool | operator!= (const Data &other) const |
bool | operator>= (const Data &other) const |
bool | operator> (const Data &other) const |
int | compare (const Data &other) const |
Similar to memcmp. | |
bool | append (const Data &other) |
Appends a copy of the other data object to this data object. | |
Data | operator+ (const Data &other) const |
Data & | operator+= (const Data &other) |
Protected Attributes | |
Storage::pointer | m_storage |
anonymous_pipe.cpp, anonymous_pipe_server.cpp, factory_client.cpp, factory_server.cpp, file_client.cpp, file_eof.cpp, file_server.cpp, ipv4_multicast_client.cpp, ipv4_multicast_server.cpp, ipv4_tcp_client.cpp, ipv4_tcp_echo_client.cpp, ipv4_tcp_echo_server.cpp, ipv4_tcp_server.cpp, ipv4_udp_client.cpp, ipv4_udp_server.cpp, ipv4_udpposet_server.cpp, ipv6_multicast_client.cpp, ipv6_multicast_server.cpp, ipv6_tcp_client.cpp, ipv6_tcp_echo_client.cpp, ipv6_tcp_echo_server.cpp, ipv6_tcp_server.cpp, ipv6_udp_client.cpp, ipv6_udp_server.cpp, ipv6_udpposet_server.cpp, ll_client.cpp, ll_server.cpp, messagequeue_server.cpp, miniterm.cpp, registry_client.cpp, registry_server.cpp, and serial_send.cpp.
Conexus::Data::Data | ( | size_t | s = 0 , |
|
unsigned | priority = 0 | |||
) | throw (std::bad_alloc) |
Constructor initializes buffer to a specific size.
Conexus::Data::Data | ( | const void * | d, | |
size_t | s, | |||
unsigned | priority = 0 , |
|||
DataMode | mode = COPY | |||
) | throw (std::bad_alloc) |
Constructor initializes buffer with a copy of specific data.
References Conexus::COPY, Conexus::MANAGED, and Conexus::UNMANAGED.
Conexus::Data::Data | ( | const Data & | other | ) |
Copy constructor.
Conexus::Data::~Data | ( | ) |
Destructor.
bool Conexus::Data::append | ( | const Data & | other | ) |
Appends a copy of the other data object to this data object.
References data(), resize(), and size().
Referenced by operator+(), and operator+=().
void Conexus::Data::clear | ( | ) |
Data Conexus::Data::clone | ( | ) | const |
Performs a deep copy of this data object.
This method allocates a new memory chunk, copies the existing data into that data chunk, and returns an object containing a smart pointer to the underlying data.
References Conexus::COPY, and m_storage.
Referenced by operator+().
int Conexus::Data::compare | ( | const Data & | other | ) | const |
Similar to memcmp.
Compares the memory areas of two data items. If the two data items are of different sizes (s1 and s2) only the first n bytes will be compared, where n is the lesser of s1 and s2.
Unlike memcmp, 0 will be returned only if the memory areas are identical and s1 is equal to s2.
If memcmp would return 0 for the first n bytes and s1 != s2, the an integer less than 0 is returned if s1 < s2 and an integer greater than 0 is returned if s1 > s2.
References m_storage.
Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().
const uint8_t * Conexus::Data::data | ( | ) | const |
uint8_t * Conexus::Data::data | ( | ) |
Pointer to the actual data.
References m_storage.
Referenced by append().
std::string Conexus::Data::hex_string | ( | std::string | separator = std::string() |
) | const |
Returns a hex string representation of the data.
References m_storage.
Conexus::Data::operator bool | ( | ) | const |
References m_storage.
Conexus::Data::operator bool | ( | ) |
References m_storage.
Conexus::Data::operator char * | ( | ) |
References m_storage.
Conexus::Data::operator const char * | ( | ) | const |
References m_storage.
Conexus::Data::operator const uint8_t * | ( | ) | const |
Conexus::Data::operator const void * | ( | ) | const |
References m_storage.
Conexus::Data::operator uint8_t * | ( | ) |
Conexus::Data::operator void * | ( | ) |
References m_storage.
const uint8_t & Conexus::Data::operator[] | ( | const ssize_t | offset | ) | const |
References m_storage.
uint8_t & Conexus::Data::operator[] | ( | const ssize_t | offset | ) |
References m_storage.
unsigned Conexus::Data::priority | ( | ) | const |
bool Conexus::Data::resize | ( | size_t | s | ) | throw (std::bad_alloc) |
Resize buffer to size s.
Referenced by append(), Conexus::MessageQueue::read_data(), Conexus::SSL::IPv6::TCP::read_data(), Conexus::SSL::IPv4::UDP::read_data(), Conexus::SSL::IPv4::TCP::read_data(), Conexus::NSPR::FileDescriptor::read_data(), and Conexus::SSL::SSL::ssl_read().
void Conexus::Data::set_current_time | ( | ) |
Sets the timeval associated with this data item to the current time.
References m_storage.
Referenced by Conexus::MessageQueue::read_data(), Conexus::SSL::IPv6::TCP::read_data(), Conexus::SSL::IPv4::UDP::read_data(), Conexus::SSL::IPv4::TCP::read_data(), and Conexus::NSPR::FileDescriptor::read_data().
bool Conexus::Data::set_data | ( | const void * | newdata, | |
size_t | newsize, | |||
DataMode | mode = COPY | |||
) | throw (std::bad_alloc) |
Sets the buffer to specific data.
newdata + newsize must not be within the current storage region if a copy is performed
References Conexus::COPY, Conexus::MANAGED, and Conexus::UNMANAGED.
void Conexus::Data::set_priority | ( | unsigned | p | ) |
void Conexus::Data::set_time | ( | const TimeVal & | t | ) |
size_t Conexus::Data::size | ( | ) | const |
Current buffer size.
References m_storage.
Referenced by append(), Conexus::Endpoint::emit_received_data(), Conexus::NSPR::Socket::read_data(), Conexus::Socket::read_data(), Conexus::MessageQueue::read_data(), Conexus::SSL::IPv6::TCP::read_data(), Conexus::SSL::IPv4::UDP::read_data(), Conexus::SSL::IPv4::TCP::read_data(), Conexus::NSPR::FileDescriptor::read_data(), Conexus::Endpoint::read_delivery_thread_main(), Conexus::SSL::SSL::ssl_read(), Conexus::SSL::SSL::ssl_write(), and Conexus::Endpoint::write().
const TimeVal & Conexus::Data::time | ( | ) | const |
Storage::pointer Conexus::Data::m_storage [protected] |
Referenced by clear(), clone(), compare(), data(), hex_string(), operator bool(), operator char *(), operator const char *(), operator const uint8_t *(), operator const void *(), operator uint8_t *(), operator void *(), operator[](), priority(), set_current_time(), set_priority(), set_time(), size(), and time().