reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Data.hxx
Go to the documentation of this file.
1#ifndef RESIP_Data_hxx
2#define RESIP_Data_hxx
3
4#ifdef HAVE_CONFIG_H
5#include "config.h"
6#endif
7
8#include <iostream>
9#include <string>
10#include <bitset>
11#if RESIP_HAVE_STRING_VIEW
12#include <string_view>
13#endif
14#include "rutil/ResipAssert.h"
15
16#include "rutil/compat.hxx"
17#include "rutil/DataStream.hxx"
19#include "rutil/HashMap.hxx"
20
21#ifndef RESIP_DATA_LOCAL_SIZE
22#define RESIP_DATA_LOCAL_SIZE 16
23#endif
24
25class TestData;
26namespace resip
27{
28
41template <int S>
43{
44 explicit DataLocalSize(size_t) noexcept {}
45};
46
47// .bwc. Pack class Data; has to come before doxygen block though.
48#pragma pack(push, 4)
49
89class Data
90{
91 public:
93
94 typedef size_t size_type;
95
96 inline Data()
97 : mBuf(mPreBuffer),
98 mSize(0),
99 mCapacity(LocalAlloc),
100 mShareEnum(Borrow)
101 {
102 mBuf[mSize] = 0;
103 }
104
109 {
110 friend class Data;
111 explicit PreallocateType(int);
112 };
117
128 Data(size_type capacity, const PreallocateType&);
129
130//#define DEPRECATED_PREALLOC
131#ifdef DEPRECATED_PREALLOC
151 Data(size_type capacity, bool foo);
152#endif
153
161 Data(const char* str);
162
168 Data(const char* buffer, size_type length);
169
175 Data(const unsigned char* buffer, size_type length);
176
177 Data(const Data& data);
178
179 Data(Data &&data) noexcept;
183 Data(const std::string& str);
184
185#if RESIP_HAVE_STRING_VIEW
189 Data(const std::string_view sv);
190#endif
191
198 explicit Data(int32_t value);
199
206 explicit Data(uint32_t value);
207
214 explicit Data(uint64_t value);
215
216#ifndef RESIP_FIXED_POINT
235 explicit Data(double value,
237#endif
238
243 explicit Data(bool value);
244
249 explicit Data(char c);
250
255 {
261
267
272 Take=2
273 };
274
281 Data(ShareEnum, const char* buffer, size_type length);
282
289 Data(ShareEnum, const char* buffer, size_type length, size_type capacity);
290
299 Data(ShareEnum, const char* buffer);
300
314 Data(ShareEnum, const Data& staticData); // Cannot call with 'Take'
315
316 inline ~Data()
317 {
318 if (mShareEnum == Take)
319 {
320 delete[] mBuf;
321 }
322 }
323
335 Data& setBuf(ShareEnum se, const char *buf, size_type length);
336
341 Data& setBuf(ShareEnum se, const char *str)
342 {
343 return setBuf(se, str, (size_type)strlen(str));
344 };
345
346
354 Data& takeBuf(Data& other) noexcept;
355
362 Data& duplicate(const Data& other);
363
374 Data& copy(const char *buf, size_type length);
375
391 char* getBuf(size_type length);
392
397 template<class T>
398 static Data from(const T& x)
399 {
400 Data d;
401 {
402 DataStream s(d);
403 s << x;
404 }
405 return d;
406 }
407
408 friend bool operator==(const Data& lhs, const Data& rhs);
409 friend bool operator==(const Data& lhs, const char* rhs);
410 friend bool operator==(const Data& lhs, const std::string& rhs) noexcept;
411#if RESIP_HAVE_STRING_VIEW
412 friend bool operator==(const Data& lhs, const std::string_view rhs) noexcept;
413#endif
414
415 friend bool operator<(const Data& lhs, const Data& rhs);
416 friend bool operator<(const Data& lhs, const char* rhs);
417 friend bool operator<(const char* lhs, const Data& rhs);
418 friend bool operator<(const Data& lhs, const std::string& rhs) noexcept;
419 friend bool operator<(const std::string& lhs, const Data& rhs) noexcept;
420#if RESIP_HAVE_STRING_VIEW
421 friend bool operator<(const Data& lhs, const std::string_view rhs) noexcept;
422 friend bool operator<(const std::string_view lhs, const Data& rhs) noexcept;
423#endif
424
426 {
427 if (&data==this)
428 return *this;
429 return copy(data.mBuf,data.mSize);
430 }
431
432 Data& operator=(Data &&data) noexcept;
433
434 operator std::string() const
435 {
436 return std::string(c_str(), size());
437 }
438
447 Data& operator=(const char* str)
448 {
449 return copy(str, (size_type)strlen(str));
450 }
451
452
453 Data& operator=(const std::string& str)
454 {
455 return copy(str.c_str(), static_cast<size_type>(str.size()));
456 }
457
458#if RESIP_HAVE_STRING_VIEW
459
460 operator std::string_view() const
461 {
462 return std::string_view(c_str(), size());
463 }
464
465 Data& operator=(const std::string_view sv)
466 {
467 return copy(sv.data(), static_cast<size_type>(sv.size()));
468 }
469#endif
470
474 Data operator+(const Data& rhs) const;
475
482 Data operator+(const char* str) const;
483
487 Data operator+(char c) const;
488
492 inline Data& operator+=(const Data& rhs)
493 {
494 return append(rhs.data(), rhs.size());
495 }
496
504 inline Data& operator+=(const char* str)
505 {
507 return append(str, (size_type)strlen(str));
508 }
509
510
514 inline Data& operator+=(char c)
515 {
516 return append(&c, 1);
517 }
518
519
526 Data& operator^=(const Data& rhs);
527
532 inline char& operator[](size_type p)
533 {
534 resip_assert(p < mSize);
535 own();
536 return mBuf[p];
537 }
538
542 inline char operator[](size_type p) const
543 {
544 resip_assert(p < mSize);
545 return mBuf[p];
546 }
547
551 char& at(size_type p);
552
558 void reserve(size_type capacity);
559
564 Data& append(const char* str, size_type len);
565
578
587
591 bool empty() const noexcept { return mSize == 0; }
592
599 size_type size() const noexcept { return mSize; }
600
608 const char* data() const noexcept
609 {
610 return mBuf;
611 }
612
625 const char* c_str() const;
626
630 std::string toString() const;
631
632#if RESIP_HAVE_STRING_VIEW
636 std::string_view toStringView() const;
637#endif
638
642 const char* begin() const noexcept
643 {
644 return mBuf;
645 }
646
650 const char* end() const noexcept
651 {
652 return mBuf + mSize;
653 }
654
655 typedef enum
656 {
659 HEX
661
667 Data md5(EncodingType type=HEX) const;
668
674 Data& lowercase();
675
681 Data& uppercase();
682
698
703 Data hex() const;
704
708 Data fromHex() const;
709
717 Data escaped() const;
718
730 Data charEncoded() const;
731
746 Data charUnencoded() const;
747
751 Data urlEncoded() const;
752
756 Data urlDecoded() const;
757
762
767
771 Data xmlCharDataEncode() const;
772
776 Data xmlCharDataDecode() const;
777
782
787
793 Data trunc(size_type trunc) const;
794
800 Data& clear() { return truncate2(0); };
801
808 int convertInt() const;
809 unsigned long convertUnsignedLong() const;
810
816 size_t convertSize() const;
817
818#ifndef RESIP_FIXED_POINT
826 double convertDouble() const;
827#endif
828
834 uint64_t convertUInt64() const;
835
842 bool prefix(const Data& pre) const noexcept;
843 bool prefixNoCase(const Data& pre) const noexcept;
844
851 bool postfix(const Data& post) const noexcept;
852 bool postfixNoCase(const Data& post) const noexcept;
853
861
871 size_type find(const Data& match, size_type start = 0) const;
872
877 int replace(const Data& match, const Data& target, int max=INT_MAX);
878
882 static const Data Empty;
883
887 static const size_type npos;
888
895
901 Data base64decode() const;
902
908 Data base64encode(bool useUrlSafe=false) const;
909
917 static size_t rawHash(const unsigned char* c, size_t size);
918
926 size_t hash() const;
927
935 static size_t rawCaseInsensitiveHash(const unsigned char* c, size_t size);
936
946 static size_t rawCaseInsensitiveTokenHash(const unsigned char* c, size_t size);
947
952 size_t caseInsensitivehash() const;
953
960 size_t caseInsensitiveTokenHash() const;
961
973 static size_t rawKeyedHash(const unsigned char* c, size_t size);
974
982 static size_t rawKeyedCaseInsensitiveHash(const unsigned char* c, size_t size);
983
988 size_t keyedHash() const;
989
995 size_t keyedCaseInsensitiveHash() const;
996
997 inline bool caseInsensitiveTokenCompare(const Data& rhs) const
998 {
999 if(mSize==rhs.mSize)
1000 {
1002 }
1003 return false;
1004 }
1005
1007
1013 static std::bitset<256> toBitset(const resip::Data& chars);
1014
1029 template<class Predicate> EncodeStream&
1031 Predicate shouldEscape) const;
1032
1041 std::ostream& escapeToStream(std::ostream& str,
1042 const std::bitset<256>& shouldEscape) const;
1043
1044 static Data fromFile(const Data& filename);
1045
1046 private:
1050 Data(const char* buffer, size_type length, bool);
1051
1055 inline void initFromString(const char* str, size_type len);
1056
1061 void own() const;
1062
1066 void resize(size_type newSize, bool copy);
1067
1068 static bool isHex(unsigned char c);
1069
1073 enum {LocalAlloc = RESIP_DATA_LOCAL_SIZE };
1074
1075 char* mBuf;
1076 size_type mSize;
1077 size_type mCapacity;
1078 char mPreBuffer[LocalAlloc];
1079 // Null terminator for mPreBuffer when mSize==LocalAlloc lands here; this
1080 // is ok, because Borrow==0.
1081 // Note: we could use a char here, and expand mPreBuffer by 3 bytes, but
1082 // this imposes a performance penalty since it requires operating on a
1083 // memory location smaller than a word (requires masking and such).
1084 size_type mShareEnum;
1085
1086 friend std::ostream& operator<<(std::ostream& strm, const Data& d);
1087#ifndef RESIP_USE_STL_STREAMS
1089#endif
1090 friend class ParseBuffer;
1091 friend class DataBuffer;
1092 friend class DataStream;
1093 friend class oDataStream;
1094 friend class ::TestData;
1095 friend class MD5Buffer;
1096};
1097// reset alignment to previous value
1098#pragma pack(pop)
1099
1100
1102 public:
1103 static const bool isCharHex[256];
1104};
1105
1107
1108inline bool Data::isHex(unsigned char c)
1109{
1110 // Shut up the warning about invokeDataInit defined, but not used
1111 if(0){(void) invokeDataInit;}
1112
1113 return DataHelper::isCharHex[c];
1114}
1115
1116inline bool isEqualNoCase(const Data& left, const Data& right)
1117{
1118 return ( (left.size() == right.size()) &&
1119 (strncasecmp(left.data(), right.data(), left.size()) == 0) );
1120}
1121
1122inline bool isTokenEqualNoCase(const Data& left, const Data& right)
1123{
1124 return left.caseInsensitiveTokenCompare(right);
1125}
1126
1127inline bool isLessThanNoCase(const Data& left, const Data& right)
1128{
1129 size_t minsize = resipMin( left.size(), right.size() );
1130 int res = strncasecmp(left.data(), right.data(), minsize);
1131
1132 if (res < 0)
1133 {
1134 return true;
1135 }
1136 else if (res > 0)
1137 {
1138 return false;
1139 }
1140 else
1141 {
1142 return left.size() < right.size();
1143 }
1144}
1145
1146template<class Predicate> EncodeStream&
1147Data::escapeToStream(EncodeStream& str, Predicate shouldEscape) const
1148{
1149 constexpr char hex[] = "0123456789ABCDEF";
1150
1151 if (empty())
1152 {
1153 return str;
1154 }
1155
1156 const unsigned char* p = (unsigned char*)mBuf;
1157 const unsigned char* e = (unsigned char*)mBuf + mSize;
1158
1159 while (p < e)
1160 {
1161 // ?abr? Why is this special cased? Removing this code
1162 // does not change the behavior of this method.
1163 if (*p == '%'
1164 && e - p > 2
1165 && isHex(*(p+1))
1166 && isHex(*(p+2)))
1167 {
1168 str.write((char*)p, 3);
1169 p+=3;
1170 }
1171 else if (shouldEscape[*p])
1172 {
1173 int hi = (*p & 0xF0)>>4;
1174 int low = (*p & 0x0F);
1175
1176 str << '%' << hex[hi] << hex[low];
1177 p++;
1178 }
1179 else
1180 {
1181 str.put(*p++);
1182 }
1183 }
1184 return str;
1185}
1186
1187inline bool operator!=(const Data& lhs, const Data& rhs) { return !(lhs == rhs); }
1188inline bool operator>(const Data& lhs, const Data& rhs) { return rhs < lhs; }
1189inline bool operator<=(const Data& lhs, const Data& rhs) { return !(rhs < lhs); }
1190inline bool operator>=(const Data& lhs, const Data& rhs) { return !(lhs < rhs); }
1191
1192inline bool operator!=(const Data& lhs, const char* rhs) { return !(lhs == rhs); }
1193inline bool operator>(const Data& lhs, const char* rhs) { return rhs < lhs; }
1194inline bool operator<=(const Data& lhs, const char* rhs) { return !(rhs < lhs); }
1195inline bool operator>=(const Data& lhs, const char* rhs) { return !(lhs < rhs); }
1196
1197inline bool operator==(const char* lhs, const Data& rhs) { return rhs == lhs; }
1198inline bool operator!=(const char* lhs, const Data& rhs) { return !(rhs == lhs); }
1199inline bool operator>(const char* lhs, const Data& rhs) { return rhs < lhs; }
1200inline bool operator<=(const char* lhs, const Data& rhs) { return !(rhs < lhs); }
1201inline bool operator>=(const char* lhs, const Data& rhs) { return !(lhs < rhs); }
1202
1203inline bool operator!=(const Data& lhs, const std::string& rhs) noexcept { return !(lhs == rhs); }
1204inline bool operator>(const Data& lhs, const std::string& rhs) { return rhs < lhs; }
1205inline bool operator<=(const Data& lhs, const std::string& rhs) { return !(rhs < lhs); }
1206inline bool operator>=(const Data& lhs, const std::string& rhs) { return !(lhs < rhs); }
1207
1208inline bool operator==(const std::string& lhs, const Data& rhs) noexcept { return rhs == lhs; }
1209inline bool operator!=(const std::string& lhs, const Data& rhs) noexcept { return !(rhs == lhs); }
1210inline bool operator>(const std::string& lhs, const Data& rhs) { return rhs < lhs; }
1211inline bool operator<=(const std::string& lhs, const Data& rhs) { return !(rhs < lhs); }
1212inline bool operator>=(const std::string& lhs, const Data& rhs) { return !(lhs < rhs); }
1213
1214#if RESIP_HAVE_STRING_VIEW
1215inline bool operator!=(const Data& lhs, const std::string_view rhs) noexcept { return !(lhs == rhs); }
1216inline bool operator>(const Data& lhs, const std::string_view rhs) { return rhs < lhs; }
1217inline bool operator<=(const Data& lhs, const std::string_view rhs) { return !(rhs < lhs); }
1218inline bool operator>=(const Data& lhs, const std::string_view rhs) { return !(lhs < rhs); }
1219
1220inline bool operator==(const std::string_view lhs, const Data& rhs) noexcept { return rhs == lhs; }
1221inline bool operator!=(const std::string_view lhs, const Data& rhs) noexcept { return !(rhs == lhs); }
1222inline bool operator>(const std::string_view lhs, const Data& rhs) { return rhs < lhs; }
1223inline bool operator<=(const std::string_view lhs, const Data& rhs) { return !(rhs < lhs); }
1224inline bool operator>=(const std::string_view lhs, const Data& rhs) { return !(lhs < rhs); }
1225#endif
1226
1227#ifndef RESIP_USE_STL_STREAMS
1228EncodeStream& operator<<(EncodeStream& strm, const Data& d);
1229#endif
1230inline std::ostream& operator<<(std::ostream& strm, const Data& d)
1231{
1232 return strm.write(d.mBuf, d.mSize);
1233}
1234
1235
1236inline Data
1237operator+(const char* c, const Data& d)
1238{
1239 return Data(c) + d;
1240}
1241
1242bool operator==(const Data& lhs, const Data& rhs);
1243bool operator==(const Data& lhs, const char* rhs);
1244bool operator==(const Data& lhs, const std::string& rhs) noexcept;
1245#if RESIP_HAVE_STRING_VIEW
1246bool operator==(const Data& lhs, const std::string_view rhs) noexcept;
1247#endif
1248
1249bool operator<(const Data& lhs, const Data& rhs);
1250bool operator<(const Data& lhs, const char* rhs);
1251bool operator<(const char* lhs, const Data& rhs);
1252bool operator<(const Data& lhs, const std::string& rhs) noexcept;
1253bool operator<(const std::string& lhs, const Data& rhs) noexcept;
1254#if RESIP_HAVE_STRING_VIEW
1255bool operator<(const Data& lhs, const std::string_view rhs) noexcept;
1256bool operator<(const std::string_view lhs, const Data& rhs) noexcept;
1257#endif
1258
1284{
1285 size_t operator()(const Data& data) const { return data.keyedHash(); }
1286};
1287
1296inline size_t hashCombine(size_t seed, size_t hash)
1297{
1298 return seed ^ (hash + (size_t)0x9e3779b97f4a7c15ULL + (seed << 6) + (seed >> 2));
1299}
1300}
1301
1303
1304#endif
1305
1306/* ====================================================================
1307 * The Vovida Software License, Version 1.0
1308 *
1309 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
1310 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
1311 *
1312 * Redistribution and use in source and binary forms, with or without
1313 * modification, are permitted provided that the following conditions
1314 * are met:
1315 *
1316 * 1. Redistributions of source code must retain the above copyright
1317 * notice, this list of conditions and the following disclaimer.
1318 *
1319 * 2. Redistributions in binary form must reproduce the above copyright
1320 * notice, this list of conditions and the following disclaimer in
1321 * the documentation and/or other materials provided with the
1322 * distribution.
1323 *
1324 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
1325 * and "Vovida Open Communication Application Library (VOCAL)" must
1326 * not be used to endorse or promote products derived from this
1327 * software without prior written permission. For written
1328 * permission, please contact vocal@vovida.org.
1329 *
1330 * 4. Products derived from this software may not be called "VOCAL", nor
1331 * may "VOCAL" appear in their name, without prior written
1332 * permission of Vovida Networks, Inc.
1333 *
1334 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
1335 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1336 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
1337 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
1338 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
1339 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
1340 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1341 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1342 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
1343 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1344 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
1345 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
1346 * DAMAGE.
1347 *
1348 * ====================================================================
1349 *
1350 * This software consists of voluntary contributions made by Vovida
1351 * Networks, Inc. and many individuals on behalf of Vovida Networks,
1352 * Inc. For more information on Vovida Networks, Inc., please see
1353 * <http://www.vovida.org/>.
1354 *
1355 * vi: set shiftwidth=3 expandtab:
1356 */
#define RESIP_DATA_LOCAL_SIZE
Definition Data.hxx:22
#define max(x, y)
Wraps your platform's implementation of hash_map, hash_multimap, and hash_set.
#define HashValue(type)
Definition HashMap.hxx:18
#define resip_assert(x)
This file needs to work for both C and C++ code.
Implementation of std::streambuf used to back the DataStream, iDataStream, and oDataStream.
static const bool isCharHex[256]
Definition Data.hxx:1103
An iostream that operates on an existing Data.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
EncodeStream & escapeToStream(EncodeStream &str, Predicate shouldEscape) const
Performs escaping of this Data according to the indicated Predicate.
Definition Data.hxx:1147
Data xmlCharDataDecode() const
Performs in-place XML Character Data un-escaping of a Data.
Definition Data.cxx:1464
Data & uppercase()
Converts this Data to uppercase.
Definition Data.cxx:1648
Data base64decode() const
Performs RFC 3548 Base 64 decoding of the contents of this data.
Definition Data.cxx:2607
friend bool operator<(const Data &lhs, const Data &rhs)
DoubleDigitPrecision
Definition Data.hxx:218
@ FourDigitPrecision
Definition Data.hxx:221
@ EightDigitPrecision
Definition Data.hxx:223
@ ZeroDigitPrecision
Definition Data.hxx:219
@ TenDigitPrecision
Definition Data.hxx:224
@ FiveDigitPrecision
Definition Data.hxx:221
@ ThreeDigitPrecision
Definition Data.hxx:220
@ NineDigitPrecision
Definition Data.hxx:223
@ OneDigitPrecision
Definition Data.hxx:219
@ TwoDigitPrecision
Definition Data.hxx:220
@ SevenDigitPrecision
Definition Data.hxx:222
@ MaxDigitPrecision
Definition Data.hxx:224
@ SixDigitPrecision
Definition Data.hxx:222
static size_t rawCaseInsensitiveTokenHash(const unsigned char *c, size_t size)
A faster version of rawCaseInsensitiveHash that has the same collision properties if this Data is mad...
Definition Data.cxx:2251
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
const char * c_str() const
Returns a null-terminated string representing.
Definition Data.cxx:1097
Data & operator+=(char c)
Appends a single byte to the Data object.
Definition Data.hxx:514
ShareEnum
The various memory management behaviors.
Definition Data.hxx:255
@ Share
The Data instance will use the buffer in a read-only mode.
Definition Data.hxx:266
@ Borrow
The Data instance is borrowing the memory from the passed in buffer.
Definition Data.hxx:260
@ Take
The Data instance takes complete ownership of the buffer.
Definition Data.hxx:272
Data base64encode(bool useUrlSafe=false) const
Performs RFC 3548 Base 64 encoding of the contents of this data.
Definition Data.cxx:2682
static size_t rawKeyedCaseInsensitiveHash(const unsigned char *c, size_t size)
As rawKeyedHash, after normalizing ASCII alphabetic characters to lowercase; consistent with isEqualN...
Definition Data.cxx:2202
char & at(size_type p)
Returns the character at the specified position.
Definition Data.cxx:988
Data & operator^=(const Data &rhs)
Performs an in-place exclusive-or of this buffer buffer with the specified buffer.
Definition Data.cxx:964
Data & operator=(const std::string &str)
Definition Data.hxx:453
char & operator[](size_type p)
Returns the character at the specified position.
Definition Data.hxx:532
int replace(const Data &match, const Data &target, int max=INT_MAX)
Replaces up to max occurrences of the bytes match with target.
Definition Data.cxx:1964
bool postfixNoCase(const Data &post) const noexcept
Definition Data.cxx:1921
const char * end() const noexcept
Returns a pointer to the end of the buffer used by the Data.
Definition Data.hxx:650
static Data fromFile(const Data &filename)
Definition Data.cxx:2539
Data charUnencoded() const
Performs RFC 3261 un-escaping of SIP URIs.
Definition Data.cxx:1289
friend bool operator==(const Data &lhs, const std::string &rhs) noexcept
RESIP_HeapCount(Data)
unsigned long convertUnsignedLong() const
Definition Data.cxx:1724
bool sizeEqualCaseInsensitiveTokenCompare(const Data &rhs) const
Definition Data.cxx:2416
char * getBuf(size_type length)
Set size to be exactly {length}, extending buffer if needed.
Definition Data.cxx:723
char operator[](size_type p) const
Returns the character at the specified position.
Definition Data.hxx:542
Data xmlCharDataEncode() const
Performs in-place XML Character Data escaping of a Data.
Definition Data.cxx:1454
Data & operator=(const Data &data)
Definition Data.hxx:425
size_t keyedCaseInsensitiveHash() const
Creates a keyed hash based on the contents of this Data, after normalizing ASCII alphabetic character...
Definition Data.cxx:2379
uint64_t convertUInt64() const
Takes the contents of the Data and converts them to an unsigned 64-bit integer.
Definition Data.cxx:1758
static const PreallocateType Preallocate
used only to disambiguate constructors
Definition Data.hxx:116
std::string toString() const
Convert to a C++ string.
Definition Data.cxx:1109
bool prefix(const Data &pre) const noexcept
Returns true if this Data starts with the bytes indicated by the passed-in Data.
Definition Data.cxx:1888
Data & append(const char *str, size_type len)
Appends the specified number of bytes to the end of this Data.
Definition Data.cxx:1058
Data & duplicate(const Data &other)
Functional equivalent of: *this = Data(buf, length) and Data& copy(const char *buf,...
Definition Data.cxx:675
size_t caseInsensitivehash() const
Creates a 32-bit hash based on the contents of this Data, after normalizing any alphabetic characters...
Definition Data.cxx:2361
friend bool operator==(const Data &lhs, const Data &rhs)
friend bool operator<(const char *lhs, const Data &rhs)
Data substr(size_type first, size_type count=Data::npos) const
Copies a portion of this Data into a new Data.
Definition Data.cxx:1932
Data & takeBuf(Data &other) noexcept
Take the data from {other}.
Definition Data.cxx:641
bool empty() const noexcept
Checks whether the Data is empty.
Definition Data.hxx:591
Data charEncoded() const
Performs RFC 3261 escaping of SIP URIs.
Definition Data.cxx:1243
Data & lowercase()
Converts this Data to lowercase.
Definition Data.cxx:1635
Data urlDecoded() const
Performs in-place HTTP URL un-escaping of a Data.
Definition Data.cxx:1341
size_t size_type
Definition Data.hxx:94
size_type size() const noexcept
Returns the number of bytes in this Data.
Definition Data.hxx:599
EncodeStream & urlEncode(EncodeStream &s) const
Escapes a Data to a stream according to HTTP URL encoding rules.
Definition Data.cxx:1421
Data & operator=(const char *str)
Assigns a null-terminated string to the buffer.
Definition Data.hxx:447
static bool init(DataLocalSize< RESIP_DATA_LOCAL_SIZE > arg)
Initializes Data class.
Definition Data.cxx:215
friend std::ostream & operator<<(std::ostream &strm, const Data &d)
Definition Data.hxx:1230
EncodeStream & urlDecode(EncodeStream &s) const
Un-escapes a Data to a stream according to HTTP URL encoding rules.
Definition Data.cxx:1351
static Data from(const T &x)
Converts from arbitrary other type to Data.
Definition Data.hxx:398
size_type find(const Data &match, size_type start=0) const
Finds a specified sequence of bytes in this Data.
Definition Data.cxx:1947
static const size_type npos
Represents an impossible position; returned to indicate failure to find.
Definition Data.hxx:887
static size_t rawKeyedHash(const unsigned char *c, size_t size)
Creates a hash based on the contents of the indicated buffer, using SipHash-1-3 with a key chosen ran...
Definition Data.cxx:2196
Data operator+(const Data &rhs) const
Concatenates two Data objects.
Definition Data.cxx:951
Data urlEncoded() const
Performs in-place HTTP URL escaping of a Data.
Definition Data.cxx:1331
friend bool operator<(const Data &lhs, const std::string &rhs) noexcept
Data & schemeLowercase()
Converts this Data to lowercase, assuming this Data only consists of scheme characters.
Definition Data.cxx:1661
friend bool operator==(const Data &lhs, const char *rhs)
Data trunc(size_type trunc) const
Shortens the size of this Data.
Definition Data.cxx:1564
friend bool operator<(const std::string &lhs, const Data &rhs) noexcept
const char * begin() const noexcept
Returns a pointer to the beginning of the buffer used by the Data.
Definition Data.hxx:642
Data & operator+=(const Data &rhs)
Appends a data object to this one.
Definition Data.hxx:492
Data & setBuf(ShareEnum se, const char *str)
Convience function to call setBuf() with a NULL-terminated string.
Definition Data.hxx:341
Data fromHex() const
Returns the binary form of the hexadecimal string in this Data.
Definition Data.cxx:1599
size_t caseInsensitiveTokenHash() const
A faster version of caseInsensitiveHash that has the same collision properties if this Data is made u...
Definition Data.cxx:2367
size_type truncate(size_type len)
Shortens the size of this Data.
Definition Data.cxx:928
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,...
Definition Data.cxx:627
static size_t rawHash(const unsigned char *c, size_t size)
Creates a 32-bit hash based on the contents of the indicated buffer.
Definition Data.cxx:2027
Data & copy(const char *buf, size_type length)
Functional equivalent of: *this = Data(buf, length) but avoids the intermediate allocation and free.
Definition Data.cxx:701
Data hex() const
Returns a hexadecimal representation of the contents of this Data.
Definition Data.cxx:1577
size_t hash() const
Creates a 32-bit hash based on the contents of this Data.
Definition Data.cxx:2355
double convertDouble() const
Takes the contents of the Data and converts them to a double precision floating point value.
Definition Data.cxx:1827
friend bool operator<(const Data &lhs, const char *rhs)
int convertInt() const
Takes the contents of the Data and converts them to an integer.
Definition Data.cxx:1684
Data escaped() const
Returns a representation of the contents of the data with any non-printable characters escaped.
Definition Data.cxx:1199
bool postfix(const Data &post) const noexcept
Returns true if this Data ends with the bytes indicated by the passed-in Data.
Definition Data.cxx:1910
Data & clear()
Clears the contents of this Data.
Definition Data.hxx:800
static std::bitset< 256 > toBitset(const resip::Data &chars)
Creates a bitset reflecting the contents of this data (as a set) ie.
Definition Data.cxx:2477
size_t keyedHash() const
Creates a keyed hash based on the contents of this Data.
Definition Data.cxx:2373
friend EncodeStream & operator<<(EncodeStream &strm, const Data &d)
Data md5(EncodingType type=HEX) const
Computes the MD5 hash of the current data.
Definition Data.cxx:1174
size_t convertSize() const
Takes the contents of the Data and converts them to a size_t.
Definition Data.cxx:1792
const char * data() const noexcept
Returns a pointer to the contents of this Data.
Definition Data.hxx:608
bool prefixNoCase(const Data &pre) const noexcept
Definition Data.cxx:1899
void reserve(size_type capacity)
Guarantees that the underlying buffer used by the Data is at least the number of bytes specified.
Definition Data.cxx:1049
static size_t rawCaseInsensitiveHash(const unsigned char *c, size_t size)
Creates a 32-bit hash based on the contents of the indicated buffer, after normalizing any alphabetic...
Definition Data.cxx:2058
Data & truncate2(size_type len)
Shortens the size of this Data so length is at most of {len}.
Definition Data.cxx:940
Data & operator+=(const char *str)
Appends a null-terminated string to the end of the Data object.
Definition Data.hxx:504
bool caseInsensitiveTokenCompare(const Data &rhs) const
Definition Data.hxx:997
Implementation of std::streambuf used to back the MD5Stream.
Definition MD5Stream.hxx:44
Provides string-parsing functionality with protection from buffer overflow.
An ostream that operates on an existing Data.
This file is used to handle compatibility fixes/tweaks so reSIProcate can function on multiple platfo...
dcm! – add UnusedChecking(_enum) below;
const _Tp & resipMin(const _Tp &__a, const _Tp &__b)
Definition compat.hxx:182
bool isEqualNoCase(const Data &left, const Data &right)
Definition Data.hxx:1116
bool operator<=(const Data &lhs, const Data &rhs)
Definition Data.hxx:1189
size_t hashCombine(size_t seed, size_t hash)
Combines the hashes of the parts of a composite key, eg.
Definition Data.hxx:1296
bool isLessThanNoCase(const Data &left, const Data &right)
Definition Data.hxx:1127
bool operator>=(const Data &lhs, const Data &rhs)
Definition Data.hxx:1190
static bool invokeDataInit
Definition Data.hxx:1106
unsigned long long uint64_t
Definition Stun.hxx:39
unsigned int uint32_t
Definition Stun.hxx:34
bool operator<(const Data &lhs, const Data &rhs)
Definition Data.cxx:778
bool operator>(const Data &lhs, const Data &rhs)
Definition Data.hxx:1188
static void foo()
Data operator+(const char *c, const Data &d)
Definition Data.hxx:1237
bool isTokenEqualNoCase(const Data &left, const Data &right)
Definition Data.hxx:1122
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
bool operator==(const char *lhs, const Data &rhs)
Definition Data.hxx:1197
bool operator!=(const Data &lhs, const Data &rhs)
Definition Data.hxx:1187
#define EncodeStream
signed int int32_t
Definition stdint.h:82
DataLocalSize(size_t) noexcept
Definition Data.hxx:44
Hasher for hash containers keyed by data received from the network, e.g.
Definition Data.hxx:1284
size_t operator()(const Data &data) const
Definition Data.hxx:1285
void list()
Definition userAdmin.cxx:66