libUTL++
|
Various general-purpose functions. More...
Classes | |
struct | utl::PointerLikeTraits< PtrT > |
Pointer-like traits. More... | |
class | utl::PointerIntPairBase |
Non-template base class for PointerIntPair. More... | |
class | utl::PointerIntPair< PtrT, IntBits, IntT, PtrTraits > |
(Pointer,Int) pair. More... | |
class | utl::BoolToggle |
Toggle a boolean value RAII-style. More... | |
struct | utl::comparisonFunctor< T > |
Object comparison evaluator. More... | |
struct | utl::equals< T > |
Object comparison predicate evaluator that returns the value of (lhs == rhs). More... | |
struct | utl::lessThan< T > |
Object comparison predicate evaluator that returns the value of (lhs < rhs). More... | |
Enumerations | |
enum | utl::cmp_t { utl::cmp_lessThan, utl::cmp_lessThanOrEqualTo, utl::cmp_equalTo, utl::cmp_greaterThan, utl::cmp_greaterThanOrEqualTo } |
Comparison operators. More... | |
enum | utl::find_t { utl::find_any = 0, utl::find_first = 1, utl::find_last = 2, utl::find_ip = 3 } |
Find strategy. More... | |
enum | utl::io_t { utl::io_null = 0, utl::io_rd = 1, utl::io_wr = 2, utl::io_rdwr = 3 } |
I/O flags. More... | |
enum | utl::serialize_t { utl::ser_readable = 1, utl::ser_compact = 2, utl::ser_nonportable = 4, utl::ser_default = 8 } |
Specifies a serialization mode. More... | |
Functions | |
void | utl::init () |
Initialize UTL++. More... | |
void | utl::deInit () |
De-initialize UTL++. More... | |
void | utl::abort (const char *filename, int lineNo, const char *text=nullptr) |
Abort the process. More... | |
void | utl::abort (const char *text) |
Abort the process. More... | |
int | utl::compare (bool lhs, bool rhs) |
Compare two boolean values. More... | |
void | utl::die (const char *filename, int lineNo, const char *text=nullptr, int exitCode=1) |
Exit the process with an error code. More... | |
void | utl::die (const char *text, int exitCode=1) |
Exit the process with an error code. More... | |
uint_t | utl::getSerializeMode () |
Get the default serialization mode (see utl::serialize_t). More... | |
void | utl::setSerializeMode (uint_t mode) |
Set the default serialization mode (see utl::serialize_t). More... | |
void * | utl::realloc (void *ptr, size_t size, size_t newSize) |
Re-allocate the given block. More... | |
char * | utl::strdup (const char *str) |
Duplicate the given string. More... | |
SSL_CTX * | utl::sslContext () |
Get a pointer to the global SSL context. More... | |
bool | utl::sslVerifyLocations (const char *caFile, const char *caPath) |
Set default locations for trusted CA certificates. More... | |
void | utl::serialize (bool &b, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize a boolean. More... | |
void | utl::serialize (int8_t &i, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize an 8-bit integer. More... | |
void | utl::serialize (char &c, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize a character. More... | |
void | utl::serialize (uint8_t &i, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize an 8-bit unsigned character. More... | |
void | utl::serialize (int16_t &i, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize a 16-bit integer. More... | |
void | utl::serialize (uint16_t &i, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize an unsigned 16-bit integer. More... | |
void | utl::serialize (int32_t &i, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize a 32-bit integer. More... | |
void | utl::serialize (uint32_t &i, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize an unsigned 32-bit integer. More... | |
void | utl::serialize (long &i, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize a long integer. More... | |
void | utl::serialize (ulong_t &i, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize an unsigned long integer. More... | |
void | utl::serialize (double &n, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize a double-precision floating point number. More... | |
void | utl::serialize (Object &object, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize an object. More... | |
template<typename T , typename... R> | |
const T & | utl::min (const T &a, const T &b, const R &... args) |
Return the smallest value among two or more provided values of the same type. More... | |
template<typename T , typename... R> | |
const T & | utl::max (const T &a, const T &b, const R &... args) |
Return the largest value among two or more provided values of the same type. More... | |
size_t | utl::allocatedSize (const Object *object) |
Compute the allocated size of an object. More... | |
template<typename T > | |
void | utl::arrayGrow (T *&array, size_t &arraySize, size_t minSize=size_t_max, size_t growthIncrement=size_t_max, const T *defVal=nullptr) |
Grow an array. More... | |
template<typename T > | |
void | utl::arrayGrow (T *&array, T *&arrayPtr, T *&arrayLim, size_t minSize=size_t_max, size_t growthIncrement=size_t_max) |
Grow an array. More... | |
template<typename T > | |
const T & | utl::cast (const utl::Object &object) |
Safely cast an object to the desired type. More... | |
template<typename T > | |
T & | utl::cast (utl::Object &object) |
Safely cast an object to the desired type. More... | |
template<typename T > | |
const T * | utl::cast (const utl::Object *object) |
Safely cast an object pointer to the desired type. More... | |
template<typename T > | |
T * | utl::cast (utl::Object *object) |
Safely cast an object pointer to the desired type. More... | |
template<typename T > | |
T & | utl::cast_const (const utl::Object &object) |
Safely cast an object reference to the desired type (remove const-qualifier). More... | |
template<typename T > | |
T * | utl::cast_const (const utl::Object *object) |
Safely cast an object pointer to the desired type (remove const-qualifier). More... | |
template<typename T > | |
T * | utl::clone (const T *object) |
Create a clone of the given object. More... | |
template<typename T > | |
int | utl::compare (const T &lhs, const T &rhs) |
Compare two objects of the same type. More... | |
int | utl::compare (const Object *lhs, const Object *rhs, const Ordering *ordering=nullptr) |
Compare two objects. More... | |
int | utl::compareNullable (const Object *lhs, const Object *rhs, const Ordering *ordering=nullptr) |
Compare two objects. More... | |
template<typename T > | |
int | utl::compare (const T *lhs, const T *rhs, size_t len) |
Compare two same-length arrays of objects of the same type. More... | |
template<typename T > | |
int | utl::compare (const T *lhs, size_t lhsLen, const T *rhs, size_t rhsLen) |
Compare two arrays of objects of the same type. More... | |
template<typename InputCont1 , typename InputCont2 > | |
int | utl::compare (typename InputCont1::const_iterator lhsBegin, typename InputCont1::const_iterator lhsEnd, typename InputCont2::const_iterator rhsBegin, typename InputCont2::const_iterator rhsEnd, std::function< int(typename InputCont1::value_type, typename InputCont2::value_type)> comp) |
Compare two sequences. More... | |
bool | utl::comparisonResultMatchesOp (int cmpRes, uint_t cmpOp) |
Determine whether the given comparison result is consistent with the given comparison operator. More... | |
template<typename T > | |
void | utl::copy (T *dest, const T *src, size_t len) |
Copy one array of objects to another. More... | |
template<typename T > | |
T | utl::roundUp (const T &v, const T &m) |
Round the given value v up to the nearest multiple of m. More... | |
template<typename T > | |
T | utl::roundDown (const T &v, const T &m) |
Round the given value v down to the nearest multiple of m. More... | |
template<typename T > | |
void | utl::serialize (T *array, size_t len, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize an array. More... | |
template<typename T > | |
void | utl::serialize (T *&object, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize an object (boxed). More... | |
template<typename T > | |
void | utl::serialize (T &object, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize an object (non-boxed). More... | |
template<typename T > | |
void | utl::serializeNullable (T *&object, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize a nullable object. More... | |
template<typename T > | |
void | utl::serializeBoxed (T *&object, Stream &stream, uint_t io, uint_t mode=ser_default) |
Serialize a boxed object. More... | |
uint16_t | utl::reverseBytes (uint16_t n) |
Reverse the byte ordering of a 16-bit unsigned integer. More... | |
uint32_t | utl::reverseBytes (uint32_t n) |
Reverse the byte ordering of a 32-bit unsigned integer. More... | |
uint64_t | utl::reverseBytes (uint64_t n) |
Reverse the byte ordering of a 64-bit unsigned integer. More... | |
template<typename T > | |
void | utl::swap (T *array, size_t lhsIdx, size_t rhsIdx) |
Swap two elements of the given array. More... | |
template<typename T > | |
void | utl::swap (T *array, size_t lhsIdx, size_t rhsIdx, size_t size) |
Swap two sections of the given array. More... | |
void | utl::clobber () |
Fake read/write access to all memory. More... | |
void | utl::escape (void *ptr) |
Fake read/write access to all memory, and require the object at address ptr to exist. More... | |
constexpr size_t | utl::KB (size_t n) |
Convert size in kilobytes to size in bytes. More... | |
constexpr size_t | utl::MB (size_t n) |
Convert size in megabytes to size in bytes. More... | |
constexpr size_t | utl::GB (size_t n) |
Convert size in gigabytes to size in bytes. More... | |
Various general-purpose functions.
enum utl::cmp_t |
enum utl::find_t |
enum utl::io_t |
enum utl::serialize_t |
Specifies a serialization mode.
Enumerator | |
---|---|
ser_readable | human-readable and portable representation |
ser_compact | space-efficient and portable representation |
ser_nonportable | nonportable space- and time-efficient representation |
ser_default | default representation (via getSerializeMode()) |
void utl::init | ( | ) |
Initialize UTL++.
This function is called by utl::Application's constructor, so when your application class inherits from Application (as recommended) you won't need to worry about calling this function.
Referenced by utl::Stream::_indentIfBOL(), utl::SpanAllocator< T, D >::alloc(), utl::AutoPtr< T >::AutoPtr(), utl::Base64decode::Base64decode(), utl::Base64encode::Base64encode(), utl::Base64encoder::Base64encoder(), utl::BinaryData::BinaryData(), utl::BinTreeBfsIt::BinTreeBfsIt(), utl::BinTreeNode::BinTreeNode(), utl::BitArray::BitArray(), utl::FDstream::blockingIO(), utl::HttpResponse::body(), utl::BoyerMooreSearch< T >::BoyerMooreSearch(), utl::BufferedStream::BufferedStream(), utl::BWTencoder::BWTencoder(), utl::Thread::cancel(), utl::DBconnection::clearResult(), utl::CmdLineArgs::CmdLineArgs(), utl::StringVars::container(), utl::DBresultIterator::DBresultIterator(), utl::Directory::Directory(), utl::StringTranslator::dump(), utl::DBresult::errorMsg(), utl::IsA::eval(), utl::ExtArray::ExtArray(), utl::ServerSocket::fd(), utl::FileSpec::FileSpec(), utl::Decimal::floor(), utl::FSobject::FSobject(), utl::CRC32::get(), utl::HeapIt::getIdx(), utl::CachedObject::getKey(), utl::Heap::getMax(), utl::HashtableIt::getNode(), utl::Hashtable::Hashtable(), utl::HttpRequest::header(), utl::Heap::Heap(), utl::HttpRequest::HttpRequest(), utl::HuffmanEncoder::HuffmanEncoder(), utl::IOmux::IOmux(), utl::MultiKeyOrdering::isDescending(), utl::ListNode::ListNode(), utl::LZencoder::LZencoder(), utl::MemStream::MemStream(), utl::NetServer::NetServer(), utl::ObjectCache::ObjectCache(), utl::ObjectRegistry::ObjectRegistry(), utl::RDparser::ok(), utl::Regex::ok(), utl::Bool::operator bool(), utl::String::operator const void *(), utl::Number< T >::operator T(), utl::AutoPtr< T >::operator T*(), utl::CmdLineArgs::operator()(), utl::Collection::operator()(), utl::Array::operator()(), utl::Vector< uint_t >::operator+(), utl::DBresultIterator::operator++(), utl::Span< Time, Duration >::operator+=(), utl::URI::operator+=(), utl::ArrayIt::operator-(), utl::TFwdIt< T >::operator=(), utl::TBidIt< T >::operator=(), utl::TRandIt< T >::operator=(), utl::ExtArray::operator[](), utl::BitArray::operator[](), utl::FwdIt::owner(), utl::Deque::pushBack(), utl::List::pushBack(), utl::LogMgr::putLine(), utl::Regex::Regex(), utl::SpanAllocator< T, D >::remove(), utl::SpanCol< T, D >::remove(), utl::RLencoder::RLencoder(), utl::Semaphore::Semaphore(), utl::BinTree::serializeFast(), utl::BoyerMooreSearch< T >::set(), utl::DequeIt::set(), utl::SlistNode::set(), utl::ListNode::set(), utl::ArithmeticEncoder::setContext(), utl::ObjectCache::setFrozen(), utl::Hashtable::setHashFunction(), utl::MemStream::setIncrement(), utl::Encoder::setLastBlock(), utl::BufferedStream::setLineBuffered(), utl::Translator::setMapping(), utl::InetHostAddress::setNil(), utl::BinTreeBfsIt::setNode(), utl::ListIt::setNode(), utl::BinTreeIt::setNode(), utl::SkipListIt::setNode(), utl::Vertex::setObject(), utl::UnaryPredicate::setObject(), utl::ComparisonPredicate::setOrdering(), utl::Base64encode::setOutputStream(), utl::Base64decode::setOutputStream(), utl::BoyerMooreSearch< T >::setOwner(), utl::BinaryPredicate::setRHS(), utl::BinTreeNode::setRight(), utl::Pair::setSecondOwner(), utl::Graph::setStart(), utl::ParseNode::setToken(), utl::DBfield::size(), utl::SkipList::SkipList(), utl::SlistNode::SlistNode(), utl::IOmux::streams(), utl::Vector< uint_t >::swap(), utl::SyslogStream::SyslogStream(), utl::Exception::takeObject(), utl::Token::Token(), utl::TCollection< Vertex >::toString(), utl::ArithContext::totFreq(), utl::RWlock::trylock(), utl::RWlockLF::trylock(), utl::SyslogStream::underflow(), utl::URI::URI(), utl::Semaphore::V(), utl::Vector< uint_t >::Vector(), and utl::Vertex::Vertex().
void utl::deInit | ( | ) |
De-initialize UTL++.
This function is called by utl::Application's destructor, so when your application class inherits from Application (as recommended) you won't need to worry about calling this function.
Referenced by utl::Stream::_indentIfBOL(), utl::Base64encoder::Base64encoder(), utl::BinaryData::BinaryData(), utl::FDstream::blockingIO(), utl::HttpResponse::body(), utl::BWTencoder::BWTencoder(), utl::Thread::cancel(), utl::DBconnection::clearResult(), utl::StringVars::container(), utl::StringTranslator::dump(), utl::DBresult::errorMsg(), utl::IsA::eval(), utl::ServerSocket::fd(), utl::FileSpec::FileSpec(), utl::Decimal::floor(), utl::CRC32::get(), utl::HeapIt::getIdx(), utl::CachedObject::getKey(), utl::Heap::getMax(), utl::HashtableIt::getNode(), utl::HttpRequest::header(), utl::HuffmanEncoder::HuffmanEncoder(), utl::MultiKeyOrdering::isDescending(), utl::LZencoder::LZencoder(), utl::NetServer::NetServer(), utl::RDparser::ok(), utl::Regex::ok(), utl::Bool::operator bool(), utl::String::operator const void *(), utl::Number< T >::operator T(), utl::AutoPtr< T >::operator T*(), utl::CmdLineArgs::operator()(), utl::Collection::operator()(), utl::Array::operator()(), utl::Vector< uint_t >::operator+(), utl::DBresultIterator::operator++(), utl::Span< Time, Duration >::operator+=(), utl::URI::operator+=(), utl::ArrayIt::operator-(), utl::TFwdIt< T >::operator=(), utl::TBidIt< T >::operator=(), utl::TRandIt< T >::operator=(), utl::ExtArray::operator[](), utl::BitArray::operator[](), utl::FwdIt::owner(), utl::Deque::pushBack(), utl::List::pushBack(), utl::LogMgr::putLine(), utl::SpanAllocator< T, D >::remove(), utl::SpanCol< T, D >::remove(), utl::RLencoder::RLencoder(), utl::BinTree::serializeFast(), utl::DequeIt::set(), utl::ArithmeticEncoder::setContext(), utl::ObjectCache::setFrozen(), utl::Hashtable::setHashFunction(), utl::MemStream::setIncrement(), utl::Encoder::setLastBlock(), utl::BufferedStream::setLineBuffered(), utl::Translator::setMapping(), utl::InetHostAddress::setNil(), utl::BinTreeBfsIt::setNode(), utl::ListIt::setNode(), utl::BinTreeIt::setNode(), utl::SkipListIt::setNode(), utl::Vertex::setObject(), utl::UnaryPredicate::setObject(), utl::ComparisonPredicate::setOrdering(), utl::Base64encode::setOutputStream(), utl::Base64decode::setOutputStream(), utl::BoyerMooreSearch< T >::setOwner(), utl::BinaryPredicate::setRHS(), utl::BinTreeNode::setRight(), utl::Pair::setSecondOwner(), utl::Graph::setStart(), utl::ParseNode::setToken(), utl::DBfield::size(), utl::SkipList::SkipList(), utl::IOmux::streams(), utl::Exception::takeObject(), utl::Token::Token(), utl::TCollection< Vertex >::toString(), utl::ArithContext::totFreq(), utl::RWlock::trylock(), utl::RWlockLF::trylock(), utl::SyslogStream::underflow(), utl::Semaphore::V(), and utl::AutoPtr< T >::~AutoPtr().
void utl::abort | ( | const char * | filename, |
int | lineNo, | ||
const char * | text = nullptr |
||
) |
Abort the process.
filename | filename where abortion occurred |
lineNo | line number where abortion occurred |
text | message explaining the reason for the failure |
void utl::abort | ( | const char * | text | ) |
Abort the process.
text | message explaining the reason for the failure |
int utl::compare | ( | bool | lhs, |
bool | rhs | ||
) |
Compare two boolean values.
lhs | left-hand-side boolean value |
rhs | right-hand-side boolean value |
Referenced by utl::ArrayIt::ArrayIt(), utl::BinTreeBfsIt::BinTreeBfsIt(), utl::BinTreeIt::BinTreeIt(), utl::BitArray::BitArray(), utl::Bool::Bool(), utl::BWTencoder::BWTencoder(), utl::NamedObjectMI::clear(), utl::Pair::clear(), utl::VectorMD< T >::compare(), utl::Number< double >::compare(), utl::Span< Time, Duration >::compare(), utl::Vector< uint_t >::compare(), utl::compare(), utl::Decimal::Decimal(), utl::DequeIt::DequeIt(), utl::Directory::Directory(), utl::FileSpec::FileSpec(), utl::Float::Float(), utl::FSobject::FSobject(), utl::HashtableIt::HashtableIt(), utl::HeapIt::HeapIt(), utl::HttpRequest::HttpRequest(), utl::HttpResponse::HttpResponse(), utl::ListIt::ListIt(), utl::Number< double >::Number(), utl::String::operator const void *(), utl::Object::operator!=(), utl::Object::operator<(), utl::Object::operator<=(), utl::Object::operator==(), utl::Object::operator>(), utl::Object::operator>=(), utl::Regex::Regex(), utl::Predicate::setOwner(), utl::SkipListIt::SkipListIt(), utl::String::String(), utl::Symlink::Symlink(), utl::TBidIt< T >::TBidIt(), utl::TFwdIt< T >::TFwdIt(), utl::Time::Time(), utl::TimeSpan::TimeSpan(), utl::Token::Token(), utl::TRandIt< T >::TRandIt(), utl::UnixModeMask::UnixModeMask(), and utl::URI::URI().
void utl::die | ( | const char * | filename, |
int | lineNo, | ||
const char * | text = nullptr , |
||
int | exitCode = 1 |
||
) |
Exit the process with an error code.
filename | filename where failure occurred |
lineNo | line number where failure occurred |
text | message explaining the reason for the failure |
exitCode | exit code |
void utl::die | ( | const char * | text, |
int | exitCode = 1 |
||
) |
Exit the process with an error code.
text | message explaining the reason for the failure |
exitCode | exit code |
uint_t utl::getSerializeMode | ( | ) |
Get the default serialization mode (see utl::serialize_t).
Referenced by utl::serialize().
void utl::setSerializeMode | ( | uint_t | mode | ) |
Set the default serialization mode (see utl::serialize_t).
void* utl::realloc | ( | void * | ptr, |
size_t | size, | ||
size_t | newSize | ||
) |
Re-allocate the given block.
ptr | address of block to re-allocate |
size | current size of block |
newSize | new size of block |
Referenced by utl::Vector< uint_t >::swap().
char* utl::strdup | ( | const char * | str | ) |
Duplicate the given string.
str | string to duplicate |
SSL_CTX* utl::sslContext | ( | ) |
Get a pointer to the global SSL context.
bool utl::sslVerifyLocations | ( | const char * | caFile, |
const char * | caPath | ||
) |
Set default locations for trusted CA certificates.
caFile | path to a file of CA certificates in PEM format |
caPath | path to a directory containing CA certificates in PEM format |
void utl::serialize | ( | bool & | b, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize a boolean.
b | boolean to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
Referenced by utl::BinaryData::BinaryData(), utl::BitArray::BitArray(), utl::Bool::Bool(), utl::Char::Char(), utl::NamedObjectMI::clear(), utl::Pair::clear(), utl::UnaryPredicate::clear(), utl::BinaryPredicate::clear(), utl::FlagsMI::copyFlags(), utl::Decimal::Decimal(), utl::Directory::Directory(), utl::FileSpec::FileSpec(), utl::Float::Float(), utl::FSobject::getKey(), utl::Graph::Graph(), utl::Int::Int(), utl::Vector< uint_t >::move(), utl::Number< double >::Number(), utl::ObjectSpan< Time, Duration >::ObjectSpan(), utl::VectorMD< T >::serialize(), utl::Number< double >::serialize(), utl::PointerIntPairBase::serialize(), utl::Span< Time, Duration >::serialize(), utl::TCollection< Vertex >::serialize(), utl::Collection::serialize(), utl::Vector< uint_t >::serialize(), utl::Object::serializeIn(), utl::Object::serializeOut(), utl::String::String(), utl::Symlink::Symlink(), utl::Time::Time(), utl::Uint::Uint(), and utl::UnixModeMask::UnixModeMask().
void utl::serialize | ( | int8_t & | i, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize an 8-bit integer.
i | integer to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
void utl::serialize | ( | char & | c, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize a character.
c | character to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
void utl::serialize | ( | uint8_t & | i, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize an 8-bit unsigned character.
i | integer to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
void utl::serialize | ( | int16_t & | i, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize a 16-bit integer.
i | integer to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
void utl::serialize | ( | uint16_t & | i, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize an unsigned 16-bit integer.
i | integer to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
void utl::serialize | ( | int32_t & | i, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize a 32-bit integer.
i | integer to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
void utl::serialize | ( | uint32_t & | i, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize an unsigned 32-bit integer.
i | integer to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
void utl::serialize | ( | long & | i, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize a long integer.
i | integer to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
void utl::serialize | ( | ulong_t & | i, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize an unsigned long integer.
i | integer to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
void utl::serialize | ( | double & | n, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize a double-precision floating point number.
n | double to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
void utl::serialize | ( | Object & | object, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize an object.
object | object to serialize to/from stream |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
const T& utl::min | ( | const T & | a, |
const T & | b, | ||
const R &... | args | ||
) |
Return the smallest value among two or more provided values of the same type.
a | first object |
b | second object |
args | additional objects (if any) |
Definition at line 61 of file util_inl.h.
References utl::min().
Referenced by utl::Vector< uint_t >::assertOwner(), utl::Vector< uint_t >::copy(), utl::ArithmeticEncoder::decode(), utl::Time::get(), utl::Span< Time, Duration >::merge(), utl::Vector< uint_t >::move(), utl::multiKeyQuickSort(), utl::Span< Time, Duration >::overlap(), utl::BoyerMooreSearch< T >::set(), utl::Time::set(), utl::Vector< uint_t >::swap(), and utl::Time::Time().
const T& utl::max | ( | const T & | a, |
const T & | b, | ||
const R &... | args | ||
) |
Return the largest value among two or more provided values of the same type.
a | first object |
b | second object |
args | additional objects (if any) |
Definition at line 89 of file util_inl.h.
References utl::max().
Referenced by utl::BoyerMooreSearch< T >::find(), utl::Span< Time, Duration >::merge(), utl::Span< Time, Duration >::overlap(), and utl::BoyerMooreSearch< T >::set().
|
inline |
Compute the allocated size of an object.
object | object to invoke utl::Object::allocatedSize() on |
Definition at line 191 of file util_inl.h.
Referenced by utl::Object::serializeBoxed().
void utl::arrayGrow | ( | T *& | array, |
size_t & | arraySize, | ||
size_t | minSize = size_t_max , |
||
size_t | growthIncrement = size_t_max , |
||
const T * | defVal = nullptr |
||
) |
Grow an array.
array | array to grow |
arraySize | array size |
minSize | grow to at least this size |
growthIncrement | (optional) growth increment |
defVal | (optional) default value for new objects |
Definition at line 211 of file util_inl.h.
References ASSERTD, utl::nextMultipleOfPow2(), utl::nextPow2(), and utl::size_t_max.
void utl::arrayGrow | ( | T *& | array, |
T *& | arrayPtr, | ||
T *& | arrayLim, | ||
size_t | minSize = size_t_max , |
||
size_t | growthIncrement = size_t_max |
||
) |
Grow an array.
array | array to grow |
arrayPtr | index into array |
arrayLim | end of array |
minSize | minimum size |
growthIncrement | limit growth |
Definition at line 284 of file util_inl.h.
|
inline |
Safely cast an object to the desired type.
In a DEBUG build, trigger an assertion failure if the cast cannot be done.
Definition at line 307 of file util_inl.h.
|
inline |
Safely cast an object to the desired type.
In a DEBUG build, trigger an assertion failure if the cast cannot be done.
Definition at line 323 of file util_inl.h.
|
inline |
Safely cast an object pointer to the desired type.
In a DEBUG build, trigger an assertion failure if the cast cannot be done.
Definition at line 339 of file util_inl.h.
References ASSERTD.
|
inline |
Safely cast an object pointer to the desired type.
In a DEBUG build, trigger an assertion failure if the cast cannot be done.
Definition at line 355 of file util_inl.h.
References ASSERTD.
|
inline |
Safely cast an object reference to the desired type (remove const-qualifier).
In a DEBUG build, trigger an assertion failure if the cast cannot be done.
Definition at line 371 of file util_inl.h.
|
inline |
Safely cast an object pointer to the desired type (remove const-qualifier).
In a DEBUG build, trigger an assertion failure if the cast cannot be done.
Definition at line 387 of file util_inl.h.
References ASSERTD.
T* utl::clone | ( | const T * | object | ) |
Create a clone of the given object.
object | object to clone |
Definition at line 404 of file util_inl.h.
Referenced by utl::Collection::add(), utl::Array::add(), utl::Collection::addOrFind(), utl::Collection::addOrUpdate(), utl::ComparisonPredicate::ComparisonPredicate(), utl::TRandIt< T >::copy(), utl::TFwdIt< T >::copy(), utl::TBidIt< T >::copy(), utl::SortedCollection::insert(), utl::Deque::pushBack(), utl::List::pushBack(), utl::Deque::pushFront(), utl::List::pushFront(), utl::UnaryPredicate::setObject(), utl::SpanCol< T, D >::totalSize(), and utl::HashFunction::~HashFunction().
|
inline |
Compare two objects of the same type.
lhs | left-hand-side object |
rhs | right-hand-side object |
Definition at line 422 of file util_inl.h.
|
inline |
Compare two objects.
If an Ordering is given it will be used, otherwise Object::compare() will perform the comparison.
lhs | left-hand-side object |
rhs | right-hand-side object |
ordering | (optional) ordering |
Definition at line 442 of file util_inl.h.
References ASSERTD, and utl::Object::compare().
|
inline |
Compare two objects.
This function is just like compare(), but it can deal with one or both of the object pointers being null. If exactly one object pointer is null, the object referenced by the other pointer is considered greater. If both object pointers are null, this function returns 0. Otherwise, its behavior is identical to compare().
lhs | left-hand-side object |
rhs | right-hand-side object |
ordering | (optional) ordering to use |
Definition at line 466 of file util_inl.h.
References utl::Object::compare().
Referenced by utl::ComparisonPredicate::cmp(), utl::TRandIt< T >::compare(), utl::TFwdIt< T >::compare(), and utl::TBidIt< T >::compare().
int utl::compare | ( | const T * | lhs, |
const T * | rhs, | ||
size_t | len | ||
) |
Compare two same-length arrays of objects of the same type.
lhs | left-hand-side sequence |
rhs | right-hand-side sequence |
len | lhs and rhs sequence length |
Definition at line 492 of file util_inl.h.
References utl::compare().
int utl::compare | ( | const T * | lhs, |
size_t | lhsLen, | ||
const T * | rhs, | ||
size_t | rhsLen | ||
) |
Compare two arrays of objects of the same type.
lhs | left-hand-side sequence |
lhsLen | lhs sequence length |
rhs | right-hand-side sequence |
rhsLen | rhs sequence length |
Definition at line 520 of file util_inl.h.
References utl::compare(), and utl::min().
int utl::compare | ( | typename InputCont1::const_iterator | lhsBegin, |
typename InputCont1::const_iterator | lhsEnd, | ||
typename InputCont2::const_iterator | rhsBegin, | ||
typename InputCont2::const_iterator | rhsEnd, | ||
std::function< int(typename InputCont1::value_type, typename InputCont2::value_type)> | comp | ||
) |
Compare two sequences.
lhsBegin | begin of lhs sequence |
lhsEnd | end of lhs sequence |
rhsBegin | begin of rhs sequence |
rhsEnd | end of rhs sequence |
comp | comparison function |
Definition at line 554 of file util_inl.h.
References ABORT.
|
inline |
Determine whether the given comparison result is consistent with the given comparison operator.
cmpRes | comparison result (see compare(), cmp(), etc.) |
cmpOp | comparison operator (see utl::cmp_t) |
Definition at line 587 of file util_inl.h.
References utl::cmp_greaterThan, and utl::cmp_lessThan.
void utl::copy | ( | T * | dest, |
const T * | src, | ||
size_t | len | ||
) |
Copy one array of objects to another.
dest | destination sequence |
src | source sequence |
len | source sequence length |
Definition at line 690 of file util_inl.h.
Referenced by utl::ArithContext::ArithContext(), utl::ArrayIt::ArrayIt(), utl::Vector< uint_t >::assertOwner(), utl::BinTreeBfsIt::BinTreeBfsIt(), utl::BinTreeIt::BinTreeIt(), utl::BitArray::BitArray(), utl::BitArrayElem::BitArrayElem(), utl::Bool::Bool(), utl::BufferedStream::BufferedStream(), utl::NamedObjectMI::clear(), utl::Pair::clear(), utl::UnaryPredicate::clear(), utl::Vector< uint_t >::clear(), utl::BinaryPredicate::clear(), utl::SpanAllocator< T, D >::copy(), utl::VectorMD< T >::copy(), utl::Number< double >::copy(), utl::Vector< uint_t >::copy(), utl::Decimal::Decimal(), utl::DequeIt::DequeIt(), utl::Directory::Directory(), utl::FileSpec::FileSpec(), utl::FSobject::FSobject(), utl::HashtableIt::HashtableIt(), utl::HeapIt::HeapIt(), utl::HttpRequest::HttpRequest(), utl::HttpResponse::HttpResponse(), utl::Vector< uint_t >::insert(), utl::IOmux::IOmux(), utl::ListIt::ListIt(), utl::Number< double >::Number(), utl::Regex::Regex(), utl::SkipListIt::SkipListIt(), utl::String::String(), utl::Symlink::Symlink(), utl::TBidIt< T >::TBidIt(), utl::TFwdIt< T >::TFwdIt(), utl::Time::Time(), utl::Token::Token(), utl::TRandIt< T >::TRandIt(), utl::UnixModeMask::UnixModeMask(), utl::URI::URI(), and utl::Vertex::Vertex().
|
inline |
Round the given value v up to the nearest multiple of m.
v | value to round up |
m | rounding factor |
Definition at line 728 of file util_inl.h.
Referenced by utl::Time::setCurrent().
|
inline |
Round the given value v down to the nearest multiple of m.
v | value to round down |
m | rounding factor |
Definition at line 747 of file util_inl.h.
Referenced by utl::Time::setCurrent().
void utl::serialize | ( | T * | array, |
size_t | len, | ||
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize an array.
array | array to serialize to/from stream |
len | array length |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
Definition at line 766 of file util_inl.h.
References utl::getSerializeMode(), utl::ser_default, and utl::serialize().
|
inline |
Serialize an object (boxed).
object | object to serialize |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
Definition at line 789 of file util_inl.h.
References utl::serializeBoxed().
|
inline |
Serialize an object (non-boxed).
object | object to serialize |
stream | stream to serialize to/from |
io | see utl::io_t |
mode | see utl::serialize_t |
Definition at line 807 of file util_inl.h.
Referenced by utl::serialize().
void utl::serializeNullable | ( | T *& | object, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize a nullable object.
object | object pointer (by reference) |
stream | stream to serialize to/from |
io | io_rd or io_wr |
mode | (optional : ser_default) serialization mode |
Definition at line 825 of file util_inl.h.
References utl::io_rd.
Referenced by utl::Object::serializeOut().
void utl::serializeBoxed | ( | T *& | object, |
Stream & | stream, | ||
uint_t | io, | ||
uint_t | mode = ser_default |
||
) |
Serialize a boxed object.
object | object pointer (by reference) |
stream | stream to serialize to/from |
io | io_rd or io_wr |
mode | (optional : ser_default) serialization mode |
Definition at line 853 of file util_inl.h.
References utl::io_rd.
Referenced by utl::serialize().
Reverse the byte ordering of a 16-bit unsigned integer.
n | the integer to be byte-reversed |
Definition at line 878 of file util_inl.h.
Reverse the byte ordering of a 32-bit unsigned integer.
n | the integer to be byte-reversed |
Definition at line 893 of file util_inl.h.
Reverse the byte ordering of a 64-bit unsigned integer.
n | the integer to be byte-reversed |
Definition at line 910 of file util_inl.h.
|
inline |
Swap two elements of the given array.
array | given array |
lhsIdx | index of lhs element |
rhsIdx | index of rhs element |
Definition at line 930 of file util_inl.h.
Referenced by utl::BWTencoder::BWTencoder(), utl::multiKeyQuickSort(), utl::Vector< uint_t >::reverse(), utl::Vector< uint_t >::setIncrement(), and utl::Vector< uint_t >::swap().
void utl::swap | ( | T * | array, |
size_t | lhsIdx, | ||
size_t | rhsIdx, | ||
size_t | size | ||
) |
Swap two sections of the given array.
array | given array |
lhsIdx | index of lhs segment |
rhsIdx | index of rhs segment |
size | size of segments to be swapped |
Definition at line 950 of file util_inl.h.
|
inline |
Fake read/write access to all memory.
You can invoke clobber() to force the compiler to assume prior writes will be observed.
Definition at line 973 of file util_inl.h.
|
inline |
Fake read/write access to all memory, and require the object at address ptr to exist.
The compiler can't optimize away *ptr (regardless of size or type) if its address will be used.
ptr | the address of an object we want to not be optimized away |
Definition at line 990 of file util_inl.h.
constexpr size_t utl::KB | ( | size_t | n | ) |
Convert size in kilobytes to size in bytes.
n | number of kilobytes |
Definition at line 1008 of file util_inl.h.
Referenced by utl::BWTencoder::BWTencoder(), utl::Bytes::Bytes(), utl::BufferedStream::getStream(), utl::Encoder::setCRC(), utl::MemStream::setIncrement(), utl::BufferedStream::setLineBuffered(), and utl::Stream::unindent().
constexpr size_t utl::MB | ( | size_t | n | ) |
Convert size in megabytes to size in bytes.
n | number of kilobytes |
Definition at line 1023 of file util_inl.h.
Referenced by utl::Bytes::Bytes().
constexpr size_t utl::GB | ( | size_t | n | ) |
Convert size in gigabytes to size in bytes.
n | number of kilobytes |
Definition at line 1038 of file util_inl.h.