|
| | RESIP_HeapCount (Data) |
| |
| | Data () |
| |
| | Data (size_type capacity, const PreallocateType &) |
| | Creates a data with a specified initial capacity.
|
| |
| | Data (const char *str) |
| | Creates a data with a copy of the contents of the null-terminated string.
|
| |
| | Data (const char *buffer, size_type length) |
| | Creates a data with the contents of the buffer.
|
| |
| | Data (const unsigned char *buffer, size_type length) |
| | Creates a data with the contents of the buffer.
|
| |
| | Data (const Data &data) |
| |
| | Data (Data &&data) noexcept |
| |
| | Data (const std::string &str) |
| | Creates a data with the contents of the string.
|
| |
| | Data (int32_t value) |
| | Converts the passed in value into ascii-decimal representation, and then creates a "Data" containing that value.
|
| |
| | Data (uint32_t value) |
| | Converts the passed in value into ascii-decimal representation, and then creates a "Data" containing that value.
|
| |
| | Data (uint64_t value) |
| | Converts the passed in value into ascii-decimal representation, and then creates a "Data" containing that value.
|
| |
| | Data (double value, Data::DoubleDigitPrecision precision=FourDigitPrecision) |
| | Converts the passed in value into ascii-decimal representation, and then creates a "Data" containing that value.
|
| |
| | Data (bool value) |
| | Creates a buffer containing "true" or "false", depending on the value of "value".
|
| |
| | Data (char c) |
| | Creates a buffer containing a single character.
|
| |
| | Data (ShareEnum, const char *buffer, size_type length) |
| | Creates a Data from the passed-in buffer.
|
| |
| | Data (ShareEnum, const char *buffer, size_type length, size_type capacity) |
| | Creates a Data from the passed-in buffer.
|
| |
| | Data (ShareEnum, const char *buffer) |
| | Takes a null-terminated string and creates a buffer.
|
| |
| | Data (ShareEnum, const Data &staticData) |
| | Lazily creates a Data from the passed-in Data.
|
| |
| | ~Data () |
| |
| Data & | setBuf (ShareEnum se, const char *buf, size_type length) |
| | Set the Data to hold {buf} using share type {se}, which may be any of Share (read-only, no-free), Borrow (read-write, no-free) or Take (read-write, yes-free).
|
| |
| Data & | setBuf (ShareEnum se, const char *str) |
| | Convience function to call setBuf() with a NULL-terminated string.
|
| |
| Data & | takeBuf (Data &other) noexcept |
| | Take the data from {other}.
|
| |
| Data & | duplicate (const Data &other) |
| | Functional equivalent of: *this = Data(buf, length) and Data& copy(const char *buf, size_type length) but avoids an actual copy of the data if {other} is Shared or Borrowed.
|
| |
| Data & | copy (const char *buf, size_type length) |
| | Functional equivalent of: *this = Data(buf, length) but avoids the intermediate allocation and free.
|
| |
| char * | getBuf (size_type length) |
| | Set size to be exactly {length}, extending buffer if needed.
|
| |
| Data & | operator= (const Data &data) |
| |
| Data & | operator= (Data &&data) noexcept |
| |
| | operator std::string () const |
| |
| Data & | operator= (const char *str) |
| | Assigns a null-terminated string to the buffer.
|
| |
| Data & | operator= (const std::string &str) |
| |
| Data | operator+ (const Data &rhs) const |
| | Concatenates two Data objects.
|
| |
| Data | operator+ (const char *str) const |
| | Concatenates a null-terminated string after the Data object.
|
| |
| Data | operator+ (char c) const |
| | Concatenates a single byte after Data object.
|
| |
| Data & | operator+= (const Data &rhs) |
| | Appends a data object to this one.
|
| |
| Data & | operator+= (const char *str) |
| | Appends a null-terminated string to the end of the Data object.
|
| |
| Data & | operator+= (char c) |
| | Appends a single byte to the Data object.
|
| |
| Data & | operator^= (const Data &rhs) |
| | Performs an in-place exclusive-or of this buffer buffer with the specified buffer.
|
| |
| char & | operator[] (size_type p) |
| | Returns the character at the specified position.
|
| |
| char | operator[] (size_type p) const |
| | Returns the character at the specified position.
|
| |
| char & | at (size_type p) |
| | Returns the character at the specified position.
|
| |
| void | reserve (size_type capacity) |
| | Guarantees that the underlying buffer used by the Data is at least the number of bytes specified.
|
| |
| Data & | append (const char *str, size_type len) |
| | Appends the specified number of bytes to the end of this Data.
|
| |
| size_type | truncate (size_type len) |
| | Shortens the size of this Data.
|
| |
| Data & | truncate2 (size_type len) |
| | Shortens the size of this Data so length is at most of {len}.
|
| |
| bool | empty () const noexcept |
| | Checks whether the Data is empty.
|
| |
| size_type | size () const noexcept |
| | Returns the number of bytes in this Data.
|
| |
| const char * | data () const noexcept |
| | Returns a pointer to the contents of this Data.
|
| |
| const char * | c_str () const |
| | Returns a null-terminated string representing.
|
| |
| std::string | toString () const |
| | Convert to a C++ string.
|
| |
| const char * | begin () const noexcept |
| | Returns a pointer to the beginning of the buffer used by the Data.
|
| |
| const char * | end () const noexcept |
| | Returns a pointer to the end of the buffer used by the Data.
|
| |
| Data | md5 (EncodingType type=HEX) const |
| | Computes the MD5 hash of the current data.
|
| |
| Data & | lowercase () |
| | Converts this Data to lowercase.
|
| |
| Data & | uppercase () |
| | Converts this Data to uppercase.
|
| |
| Data & | schemeLowercase () |
| | Converts this Data to lowercase, assuming this Data only consists of scheme characters.
|
| |
| Data | hex () const |
| | Returns a hexadecimal representation of the contents of this Data.
|
| |
| Data | fromHex () const |
| | Returns the binary form of the hexadecimal string in this Data.
|
| |
| Data | escaped () const |
| | Returns a representation of the contents of the data with any non-printable characters escaped.
|
| |
| Data | charEncoded () const |
| | Performs RFC 3261 escaping of SIP URIs.
|
| |
| Data | charUnencoded () const |
| | Performs RFC 3261 un-escaping of SIP URIs.
|
| |
| Data | urlEncoded () const |
| | Performs in-place HTTP URL escaping of a Data.
|
| |
| Data | urlDecoded () const |
| | Performs in-place HTTP URL un-escaping of a Data.
|
| |
| EncodeStream & | urlEncode (EncodeStream &s) const |
| | Escapes a Data to a stream according to HTTP URL encoding rules.
|
| |
| EncodeStream & | urlDecode (EncodeStream &s) const |
| | Un-escapes a Data to a stream according to HTTP URL encoding rules.
|
| |
| Data | xmlCharDataEncode () const |
| | Performs in-place XML Character Data escaping of a Data.
|
| |
| Data | xmlCharDataDecode () const |
| | Performs in-place XML Character Data un-escaping of a Data.
|
| |
| EncodeStream & | xmlCharDataEncode (EncodeStream &s) const |
| | Escapes a Data to a stream according to XML Character Data encoding rules.
|
| |
| EncodeStream & | xmlCharDataDecode (EncodeStream &s) const |
| | Un-escapes a Data to a stream according to XML Character Data encoding rules.
|
| |
| Data | trunc (size_type trunc) const |
| | Shortens the size of this Data.
|
| |
| Data & | clear () |
| | Clears the contents of this Data.
|
| |
| int | convertInt () const |
| | Takes the contents of the Data and converts them to an integer.
|
| |
| unsigned long | convertUnsignedLong () const |
| |
| size_t | convertSize () const |
| | Takes the contents of the Data and converts them to a size_t.
|
| |
| double | convertDouble () const |
| | Takes the contents of the Data and converts them to a double precision floating point value.
|
| |
| uint64_t | convertUInt64 () const |
| | Takes the contents of the Data and converts them to an unsigned 64-bit integer.
|
| |
| bool | prefix (const Data &pre) const noexcept |
| | Returns true if this Data starts with the bytes indicated by the passed-in Data.
|
| |
| bool | prefixNoCase (const Data &pre) const noexcept |
| |
| bool | postfix (const Data &post) const noexcept |
| | Returns true if this Data ends with the bytes indicated by the passed-in Data.
|
| |
| bool | postfixNoCase (const Data &post) const noexcept |
| |
| Data | substr (size_type first, size_type count=Data::npos) const |
| | Copies a portion of this Data into a new Data.
|
| |
| size_type | find (const Data &match, size_type start=0) const |
| | Finds a specified sequence of bytes in this Data.
|
| |
| int | replace (const Data &match, const Data &target, int max=INT_MAX) |
| | Replaces up to max occurrences of the bytes match with target.
|
| |
| Data | base64decode () const |
| | Performs RFC 3548 Base 64 decoding of the contents of this data.
|
| |
| Data | base64encode (bool useUrlSafe=false) const |
| | Performs RFC 3548 Base 64 encoding of the contents of this data.
|
| |
| size_t | hash () const |
| | Creates a 32-bit hash based on the contents of this Data.
|
| |
| size_t | caseInsensitivehash () const |
| | Creates a 32-bit hash based on the contents of this Data, after normalizing any alphabetic characters to lowercase.
|
| |
| size_t | caseInsensitiveTokenHash () const |
| | A faster version of caseInsensitiveHash that has the same collision properties if this Data is made up of RFC 3261 token characters.
|
| |
| size_t | keyedHash () const |
| | Creates a keyed hash based on the contents of this Data.
|
| |
| size_t | keyedCaseInsensitiveHash () const |
| | Creates a keyed hash based on the contents of this Data, after normalizing ASCII alphabetic characters to lowercase.
|
| |
| bool | caseInsensitiveTokenCompare (const Data &rhs) const |
| |
| bool | sizeEqualCaseInsensitiveTokenCompare (const Data &rhs) const |
| |
| template<class Predicate > |
| EncodeStream & | escapeToStream (EncodeStream &str, Predicate shouldEscape) const |
| | Performs escaping of this Data according to the indicated Predicate.
|
| |
| std::ostream & | escapeToStream (std::ostream &str, const std::bitset< 256 > &shouldEscape) const |
| | Performs escaping of this Data according to a bitset.
|
| |
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
It has a variety of memory management styles that can be established at contruction time and changed later via setBuf().
Three modes of allocation are currently available:
- 'Borrow' - The Data instance is borrowing the memory from the passed in buffer. It will modify its contents as necessary, but will not deallocate it.
- 'Share' - The Data instance will use the buffer in a read-only mode. If any attempt is made to modify the contents of the Data, it will copy the buffer and modify it.
- 'Take' - The Data instance takes complete ownership of the buffer. The buffer is deallocated using delete[].
Additionally, Data has a small locally-allocated buffer (member buffer) that it will use to hold small amounts of data. By default, this buffer can contain 16 bytes, meaning that Data will not use the heap unless it needs more than 16 bytes of space. The tradeoff here, of course, is that instances of Data will be larger than instances of std::string. Generally speaking, if you expect to need more than 16 bytes of room, and you cannot make good use of the flexible memory management offered by Data, you may want to use a std::string instead.
- See also
- RESIP_HeapCount
- Todo:
- It might be worthwhile examining the heap usage of this class in the context of using realloc everywhere appropriate. (realloc is defined in ANSI C, SVID, and the OpenGroup "Single
Unix Specification").
Definition at line 89 of file Data.hxx.