13
#include "rutil/compat.hxx"
14
#include "rutil/DataStream.hxx"
15
#include "rutil/HeapInstanceCounter.hxx"
16
#include "rutil/HashMap.hxx"
18
#ifndef RESIP_DATA_LOCAL_SIZE
19
#define RESIP_DATA_LOCAL_SIZE 16
28
This template is here to help diagnose API/ABI mismatches. Say you build
29
librutil. A single Data::init(DataLocalSize<RESIP_DATA_LOCAL_SIZE>)
30
function is implemented in Data.cxx, with the default
31
value. (Data::init(DataLocalSize<16>) ends up being defined,
32
Data::init(DataLocalSize<15>) does not) If, later, another build using
33
that librutil tries to tweak the local alloc size to 24, it will end
34
up attempting to call Data::init(DataLocalSize<24>); this will result
35
in a link-time error, that while opaque, is less opaque than the stack
36
corruption that would result otherwise.
41
explicit DataLocalSize(size_t) {}
44
// .bwc. Pack class Data; has to come before doxygen block though.
48
@brief An alternative to std::string, encapsulates an arbitrary buffer of
51
It has a variety of memory management styles that can be
52
established at contruction time and changed later via setBuf().
54
Three modes of allocation are currently available:
56
@li 'Borrow' - The Data instance is borrowing the memory from the passed
57
in buffer. It will modify its contents as necessary,
58
but will not deallocate it.
60
@li 'Share' - The Data instance will use the buffer in a read-only mode.
61
If any attempt is made to modify the contents of
62
the Data, it will copy the buffer and modify it.
64
@li 'Take' - The Data instance takes complete ownership of the
65
buffer. The buffer is deallocated using delete[].
67
Additionally, Data has a small locally-allocated buffer (member buffer) that
68
it will use to hold small amounts of data. By default, this buffer can
69
contain 16 bytes, meaning that Data will not use the heap unless it
70
needs more than 16 bytes of space. The tradeoff here, of course, is that
71
instances of Data will be larger than instances of std::string. Generally
72
speaking, if you expect to need more than 16 bytes of room, and you cannot
73
make good use of the flexible memory management offered by Data, you may want
74
to use a std::string instead.
78
@todo It might be worthwhile examining the heap usage of this
79
class in the context of using realloc everywhere appropriate.
80
(realloc is defined in ANSI C, SVID, and the OpenGroup "Single
89
RESIP_HeapCount(Data);
91
typedef UInt32 size_type;
96
mCapacity(LocalAlloc),
105
class PreallocateType
108
explicit PreallocateType(int);
111
@brief used only to disambiguate constructors
113
static const PreallocateType Preallocate;
116
Creates a data with a specified initial capacity.
118
@param capacity The initial capacity of the buffer
120
@param foo This parameter is ignored; it is merely
121
used to disambuguate this constructor
122
from the constructor that takes a single
123
int. Always pass Data::Preallocate.
125
Data(size_type capacity, const PreallocateType&);
127
//#define DEPRECATED_PREALLOC
128
#ifdef DEPRECATED_PREALLOC
130
Creates a data with a specified initial capacity.
132
@deprecated This constructor shouldn't really exist;
133
it would be far better to add a value
134
to "ShareEnum" (e.g. "Allocate") which
135
indicates that the Data should allocated
138
@param capacity The initial capacity of the buffer
140
@param foo This parameter is ignored; it is merely
141
used to disambuguate this constructor
142
from the constructor that takes a single
143
int. Yes, it's ugly -- that's why it's
146
@todo Remove this constructor
148
Data(size_type capacity, bool foo);
152
Creates a data with a copy of the contents of the
153
null-terminated string.
155
@warning Passing a non-null-terminated string to this
156
method would be a Really Bad Thing.
158
Data(const char* str);
161
Creates a data with the contents of the buffer.
163
@param length Number of bytes in the buffer
165
Data(const char* buffer, size_type length);
168
Creates a data with the contents of the buffer.
170
@param length Number of bytes in the buffer
172
Data(const unsigned char* buffer, size_type length);
174
Data(const Data& data);
176
#ifdef RESIP_HAS_RVALUE_REFS
180
Creates a data with the contents of the string.
182
explicit Data(const std::string& str);
185
Converts the passed in value into ascii-decimal
186
representation, and then creates a "Data" containing
187
that value. (E.g. "Data(75)" will create a Data
188
with length=2, and contents of 0x37 0x35).
190
explicit Data(int value);
193
Converts the passed in value into ascii-decimal
194
representation, and then creates a "Data" containing
195
that value. (E.g. "Data(75)" will create a Data
196
with length=2, and contents of 0x37 0x35).
198
explicit Data(unsigned long value);
201
Converts the passed in value into ascii-decimal
202
representation, and then creates a "Data" containing
203
that value. (E.g. "Data(75)" will create a Data
204
with length=2, and contents of 0x37 0x35).
206
explicit Data(unsigned int value);
209
Converts the passed in value into ascii-decimal
210
representation, and then creates a "Data" containing
211
that value. (E.g. "Data(75)" will create a Data
212
with length=2, and contents of 0x37 0x35).
214
explicit Data(UInt64 value);
216
#ifndef RESIP_FIXED_POINT
217
enum DoubleDigitPrecision
219
ZeroDigitPrecision = 0, OneDigitPrecision,
220
TwoDigitPrecision, ThreeDigitPrecision,
221
FourDigitPrecision, FiveDigitPrecision,
222
SixDigitPrecision, SevenDigitPrecision,
223
EightDigitPrecision, NineDigitPrecision,
224
TenDigitPrecision, MaxDigitPrecision
227
Converts the passed in value into ascii-decimal
228
representation, and then creates a "Data" containing
229
that value. (E.g. "Data(75.4,2)" will create a Data
230
with length=4, and contents of 0x37 0x35 0x2E 0x34).
232
@param precision Number of digits after the decimal point.
233
Trailing zeros will be removed.
235
explicit Data(double value,
236
Data::DoubleDigitPrecision precision = FourDigitPrecision);
240
Creates a buffer containing "true" or "false", depending
241
on the value of "value".
243
explicit Data(bool value);
246
Creates a buffer containing a single character. Is this silly?
247
Maybe. Perhaps it can be removed.
249
explicit Data(char c);
252
The various memory management behaviors.
256
/** The Data instance is borrowing the memory from the passed
257
in buffer. It will modify its contents as necessary,
258
but will not deallocate it.
262
/** The Data instance will use the buffer in a read-only mode.
263
If any attempt is made to modify the contents of
264
the Data, it will copy the buffer and modify it.
268
/** The Data instance takes complete ownership of the
269
buffer. The buffer must have been allocate using
270
"new char[]" so that it can be freed with "delete char[]".
276
Creates a Data from the passed-in buffer.
281
Data(ShareEnum, const char* buffer, size_type length);
284
Takes a null-terminated string and creates a buffer.
288
@warning Passing a non-null-terminated string to this
289
method would be a Really Bad Thing.
291
Data(ShareEnum, const char* buffer);
294
Lazily creates a Data from the passed-in Data.
298
@warning Calling this with "Take" or "Borrow" is invalid and will
299
cause an assertion or crash.
301
@todo This implementation has some confusing and conflicting
302
comments. (e.g. is Borrow actually okay? Can there be some
303
way to use it with Take as long as you play with mShareEnum
306
Data(ShareEnum, const Data& staticData); // Cannot call with 'Take'
310
if (mShareEnum == Take)
317
Set the Data to hold {buf} using share type {se}, which may be any
318
of Share (read-only, no-free), Borrow (read-write, no-free)
319
or Take (read-write, yes-free). Both the capacity
320
and current length are set to {length}; you can call truncate2()
321
afterwords to shorten. The provided buffer (and its current
322
contents) will be used going forward; any currently owned buffer
324
NOTE: The {buf} param is declared const to support Share type; for
325
Borrow and Take the buffer may be written (e.g., treated non-const).
327
Data& setBuf(ShareEnum se, const char *buf, size_type length);
330
Convience function to call setBuf() with a NULL-terminated string.
331
This is in-lined for case where compiler knows strlen statically.
333
Data& setBuf(ShareEnum se, const char *str)
335
return setBuf(se, str, (size_type)strlen(str));
340
Take the data from {other}. Any current buffer is released.
341
{this} will have the same storage mode as {other} and steal
342
its buffer. All storage modes of {other} (Share,Borrow,Take)
343
are legal. When done, {other} will be empty (it will ref its
346
Data& takeBuf(Data& other);
349
Functional equivalent of: *this = Data(buf, length)
350
but avoid the intermediate allocation and free. Also,
351
will never decrease capacity. Safe to call even if {buf}
354
@note The result is always NULL terminated. Unfortunately,
355
this requires a buffer allocation even if capacity exactly
358
Data& copy(const char *buf, size_type length);
361
Set size to be exactly {length}, extending buffer if needed.
362
Also, reallocate buffer if needed so that it is writable.
363
Buffer contents is NOT initialized, and existing contents
364
may or may not be preserved.
366
@note Purpose of this function is to provide a working buffer
367
of fixed size that the application fills in after this call.
369
@note If you want just the buffer without changing the size,
370
use data() and cast-away the const-ness.
372
@note The result may or may not be NULL terminated. The buffer
373
is NULL terminated only when safe to do so without extra reallocation.
375
char* getBuf(size_type length);
378
Converts from arbitrary other type to Data. Requires the other
379
type to have an operator<<.
382
static Data from(const T& x)
392
friend bool operator==(const Data& lhs, const Data& rhs);
393
friend bool operator==(const Data& lhs, const char* rhs);
395
friend bool operator<(const Data& lhs, const Data& rhs);
396
friend bool operator<(const Data& lhs, const char* rhs);
397
friend bool operator<(const char* lhs, const Data& rhs);
399
Data& operator=(const Data& data)
403
return copy(data.mBuf,data.mSize);
406
#ifdef RESIP_HAS_RVALUE_REFS
407
Data& operator=(Data &&data);
411
Assigns a null-terminated string to the buffer.
413
@warning Passing a non-null-terminated string to this
414
method would be a Really Bad Thing.
415
The strlen() inlined to take advantages of cases where
416
the compiler knows the length statically.
418
Data& operator=(const char* str)
420
return copy(str, (size_type)strlen(str));
424
Concatenates two Data objects.
426
Data operator+(const Data& rhs) const;
429
Concatenates a null-terminated string after the Data object.
431
@warning Passing a non-null-terminated string to this
432
method would be a Really Bad Thing.
434
Data operator+(const char* str) const;
437
Concatenates a single byte after Data object.
439
Data operator+(char c) const;
442
Appends a data object to this one.
444
inline Data& operator+=(const Data& rhs)
446
return append(rhs.data(), rhs.size());
450
Appends a null-terminated string to the end of the Data
453
@warning Passing a non-null-terminated string to this
454
method would be a Really Bad Thing.
456
inline Data& operator+=(const char* str)
459
return append(str, (size_type)strlen(str));
464
Appends a single byte to the Data object.
466
inline Data& operator+=(char c)
468
return append(&c, 1);
473
Performs an in-place exclusive-or of this buffer
474
buffer with the specified buffer. If the specifed
475
buffer is longer than this buffer, then this buffer
476
will first be expanded and zero-padded.
478
Data& operator^=(const Data& rhs);
481
Returns the character at the specified position. Ensures that ownership of
482
the buffer is taken, since the character could be modified by the caller.
484
inline char& operator[](size_type p)
492
Returns the character at the specified position.
494
inline char operator[](size_type p) const
501
Returns the character at the specified position.
503
char& at(size_type p);
506
Guarantees that the underlying buffer used by the Data
507
is at least the number of bytes specified. May cause
508
reallocation of the buffer.
510
void reserve(size_type capacity);
513
Appends the specified number of bytes to the end of
516
Data& append(const char* str, size_type len);
519
Shortens the size of this Data. Does not
520
impact the size of the allocated buffer.
521
This owns() the buffer (undoes Share) so as to write
522
terminating NULL. See truncate2() as alternative.
524
@deprecated dlb says that no one uses this and
525
it should be removed.
527
@todo Remove this at some point.
529
size_type truncate(size_type len);
532
Shortens the size of this Data so length is at most of {len}.
533
(If already shorter, doesn't increase length).
534
Does not affect buffer allocation, and doesn't impact writing
535
terminating NULL. Thus is safe to use with Share'd or external
538
Data& truncate2(size_type len);
541
Checks whether the Data is empty.
543
bool empty() const { return mSize == 0; }
546
Returns the number of bytes in this Data.
548
@note This does NOT indicate the capacity of the
551
size_type size() const { return mSize; }
554
Returns a pointer to the contents of this Data. This
555
is the preferred mechanism for accessing the bytes inside
558
@note The value returned is NOT necessarily null-terminated.
560
inline const char* data() const
566
Returns a null-terminated string representing
568
@note Depending on the memory management scheme being used,
569
this method often copies the contents of the Data;
570
consequently, this method is rather expensive and should
571
be avoided when possible.
573
@warning Calling this method is a pretty bad idea if the
574
contents of Data are binary (i.e. may contain
575
a null in the middle of the Data).
577
const char* c_str() const;
580
Returns a pointer to the beginning of the buffer used by the Data.
582
inline const char* begin() const
588
Returns a pointer to the end of the buffer used by the Data.
590
inline const char* end() const
603
Computes the MD5 hash of the current data.
604
@param type The encoding of the return (default is HEX)
605
@return The MD5 hash, in the encoding specified by type.
607
Data md5(EncodingType type=HEX) const;
610
Converts this Data to lowercase.
612
@note This is silly unless the contents are ASCII.
617
Converts this Data to uppercase.
619
@note This is silly unless the contents are ASCII.
624
Converts this Data to lowercase, assuming this Data only consists of
627
@note Assuming scheme contents allows the use of a bitmask instead of
628
tolower(), which is faster. Why, you ask? A bitmask is sufficient to
629
perform a lowercase operation on alphabetical data, since 'a' and 'A'
630
only differ on bit 6; it is set for 'a', but not for 'A'. Digits always
631
have bit 6 set, so setting it is a no-op. The last three characters in
632
the scheme character set are '+', '-', and '.'; all of these have bit 6
633
set as well. Note that there is no corresponding efficient uppercase
634
function; clearing bit 6 on either a digit or the the three remaining
635
characters (+=.) will change them.
637
Data& schemeLowercase();
640
Returns a hexadecimal representation of the contents of
646
Returns a representation of the contents of the data
647
with any non-printable characters escaped.
649
@warning This is extremely slow, and should not be called
650
except for debugging purposes.
652
Data escaped() const;
655
Performs RFC 3261 escaping of SIP URIs.
657
@note This method is relatively inefficient
659
@deprecated Use escapeToStream instead
661
@todo This method should be removed
665
Data charEncoded() const;
668
Performs RFC 3261 un-escaping of SIP URIs.
670
@note This method is relatively inefficient
672
@bug This method can assert if a "%00" comes
673
in off the wire. That's really bad form.
675
@deprecated Use something more in the spirit of escapeToStream instead
677
@todo This method should be removed
681
Data charUnencoded() const;
684
Performs in-place HTTP URL escaping of a Data.
686
Data urlEncoded() const;
689
Performs in-place HTTP URL un-escaping of a Data.
691
Data urlDecoded() const;
694
Escapes a Data to a stream according to HTTP URL encoding rules.
696
EncodeStream& urlEncode(EncodeStream& s) const;
699
Un-escapes a Data to a stream according to HTTP URL encoding rules.
701
EncodeStream& urlDecode(EncodeStream& s) const;
704
Performs in-place XML Character Data escaping of a Data.
706
Data xmlCharDataEncode() const;
709
Performs in-place XML Character Data un-escaping of a Data.
711
Data xmlCharDataDecode() const;
714
Escapes a Data to a stream according to XML Character Data encoding rules.
716
EncodeStream& xmlCharDataEncode(EncodeStream& s) const;
719
Un-escapes a Data to a stream according to XML Character Data encoding rules.
721
EncodeStream& xmlCharDataDecode(EncodeStream& s) const;
724
Shortens the size of this Data. If the contents are truncated,
725
this method appends two dot ('.') characters to the end.
726
Presumably, this is used for output purposes.
728
Data trunc(size_type trunc) const;
731
Clears the contents of this Data. This call does not modify
732
the capacity of the Data. It does not write terminating NULL,
733
and thus is safe to use with external buffers.
735
Data& clear() { return truncate2(0); };
738
Takes the contents of the Data and converts them to an
739
integer. Will strip leading whitespace. This method stops
740
upon encountering the first non-decimal digit (with exceptions
741
made for leading negative signs).
743
int convertInt() const;
744
unsigned long convertUnsignedLong() const;
747
Takes the contents of the Data and converts them to a
748
size_t. Will strip leading whitespace. This method stops
749
upon encountering the first non-decimal digit.
751
size_t convertSize() const;
753
#ifndef RESIP_FIXED_POINT
755
Takes the contents of the Data and converts them to a
756
double precision floating point value. Will strip leading
757
whitespace. This method stops upon encountering the first
758
non-decimal digit (with exceptions made for decimal points
759
and leading negative signs).
761
double convertDouble() const;
765
Takes the contents of the Data and converts them to an
766
unsigned 64-bit integer. Will strip leading whitespace.
767
This method stops upon encountering the first non-decimal digit.
769
UInt64 convertUInt64() const;
772
Returns true if this Data starts with the bytes indicated by
773
the passed-in Data. For example, if this Data is "abc", then
774
prefix(Data("ab")) would be true; however, prefix(Data("abcd"))
777
bool prefix(const Data& pre) const;
780
Returns true if this Data ends with the bytes indicated by
781
the passed-in Data. For example, if this Data is "abc", then
782
postfix(Data("bc")) would be true; however, postfix(Data("ab"))
785
bool postfix(const Data& post) const;
788
Copies a portion of this Data into a new Data.
790
@param first Index of the first byte to copy
791
@param count Number of bytes to copy
793
Data substr(size_type first, size_type count = Data::npos) const;
796
Finds a specified sequence of bytes in this Data.
798
@param match The bytes to be found
800
@param start Offset into this Data to start the search
802
@returns An index to the start of the found bytes.
804
size_type find(const Data& match, size_type start = 0) const;
807
Replaces up to max occurrences of the bytes match with
808
target. Returns the number of matches.
810
int replace(const Data& match, const Data& target, int max=INT_MAX);
813
Constant that represents a zero-length data.
815
static const Data Empty;
818
Represents an impossible position; returned to indicate failure to find.
820
static const size_type npos;
823
Initializes Data class.
825
@note This method is a link time constraint. Don't remove it.
827
static bool init(DataLocalSize<RESIP_DATA_LOCAL_SIZE> arg);
830
Performs RFC 3548 Base 64 decoding of the contents of this data.
832
@returns A new buffer containing the unencoded representation
834
Data base64decode() const;
837
Performs RFC 3548 Base 64 encoding of the contents of this data.
839
@returns A new buffer containing the base64 representation
841
Data base64encode(bool useUrlSafe=false) const;
844
Creates a 32-bit hash based on the contents of the indicated
847
@param c Pointer to the buffer to hash
848
@param size Number of bytes to be hashed
850
static size_t rawHash(const unsigned char* c, size_t size);
853
Creates a 32-bit hash based on the contents of this Data.
858
Creates a 32-bit hash based on the contents of the indicated
859
buffer, after normalizing any alphabetic characters to lowercase.
861
@param c Pointer to the buffer to hash
862
@param size Number of bytes to be hashed
864
static size_t rawCaseInsensitiveHash(const unsigned char* c, size_t size);
867
A faster version of rawCaseInsensitiveHash that has the same collision
868
properties if this Data is made up of RFC 3261 token characters.
870
@param c Pointer to the buffer to hash
871
@param size Number of bytes to be hashed
872
@note This is not guaranteed to return the same value as
873
rawCaseInsensitiveHash.
875
static size_t rawCaseInsensitiveTokenHash(const unsigned char* c, size_t size);
878
Creates a 32-bit hash based on the contents of this Data, after
879
normalizing any alphabetic characters to lowercase.
881
size_t caseInsensitivehash() const;
884
A faster version of caseInsensitiveHash that has the same collision
885
properties if this Data is made up of RFC 3261 token characters.
886
@note This is not guaranteed to return the same value as
887
rawCaseInsensitiveHash.
889
size_t caseInsensitiveTokenHash() const;
891
inline bool caseInsensitiveTokenCompare(const Data& rhs) const
895
return sizeEqualCaseInsensitiveTokenCompare(rhs);
900
bool sizeEqualCaseInsensitiveTokenCompare(const Data& rhs) const;
903
Creates a bitset reflecting the contents of this data (as a set)
904
ie. "15eo" would have the bits 49, 53, 101, and 111 set to true, and
905
all others set to false
907
static std::bitset<256> toBitset(const resip::Data& chars);
910
Performs escaping of this Data according to the indicated
913
@param str A stream to which the escaped representation
916
@param shouldEscape A functor which takes a single character
917
as a parameter, and returns true if the
918
character should be escaped, false if
921
@deprecated dlb -- pass a 256 array of bits rather than a function.
923
template<class Predicate> EncodeStream&
924
escapeToStream(EncodeStream& str,
925
Predicate shouldEscape) const;
928
Performs escaping of this Data according to a bitset.
930
@param str A stream to which the escaped representation
933
@param shouldEscape A bitset representing which chars should be escaped.
935
std::ostream& escapeToStream(std::ostream& str,
936
const std::bitset<256>& shouldEscape) const;
940
@deprecated use Data(ShareEnum ...)
942
Data(const char* buffer, size_type length, bool);
945
Copies the contents of this data to a new buffer if the
946
Data does not own the current buffer.
951
@note Always allocates a new buffer
953
void resize(size_type newSize, bool copy);
955
static bool isHex(unsigned char c);
957
/** Trade off between in-object and heap allocation
958
Larger LocalAlloc makes for larger objects that have Data members but
959
bulk allocation/deallocation of Data members. */
960
enum {LocalAlloc = RESIP_DATA_LOCAL_SIZE };
965
char mPreBuffer[LocalAlloc];
966
// Null terminator for mPreBuffer when mSize==LocalAlloc lands here; this
967
// is ok, because Borrow==0.
968
// Note: we could use a char here, and expand mPreBuffer by 3 bytes, but
969
// this imposes a performance penalty since it requires operating on a
970
// memory location smaller than a word (requires masking and such).
971
size_type mShareEnum;
973
friend std::ostream& operator<<(std::ostream& strm, const Data& d);
974
#ifndef RESIP_USE_STL_STREAMS
975
friend EncodeStream& operator<<(EncodeStream& strm, const Data& d);
977
friend class ParseBuffer;
978
friend class DataBuffer;
979
friend class DataStream;
980
friend class oDataStream;
981
friend class ::TestData;
982
friend class MD5Buffer;
984
// reset alignment to default
990
static const bool isCharHex[256];
993
static bool invokeDataInit = Data::init(DataLocalSize<RESIP_DATA_LOCAL_SIZE>(0));
995
inline bool Data::isHex(unsigned char c)
997
return DataHelper::isCharHex[c];
1000
inline bool isEqualNoCase(const Data& left, const Data& right)
1002
return ( (left.size() == right.size()) &&
1003
(strncasecmp(left.data(), right.data(), left.size()) == 0) );
1006
inline bool isTokenEqualNoCase(const Data& left, const Data& right)
1008
return left.caseInsensitiveTokenCompare(right);
1011
inline bool isLessThanNoCase(const Data& left, const Data& right)
1013
size_t minsize = resipMin( left.size(), right.size() );
1014
int res = strncasecmp(left.data(), right.data(), minsize);
1026
return left.size() < right.size();
1030
template<class Predicate> EncodeStream&
1031
Data::escapeToStream(EncodeStream& str, Predicate shouldEscape) const
1033
static char hex[] = "0123456789ABCDEF";
1040
const unsigned char* p = (unsigned char*)mBuf;
1041
const unsigned char* e = (unsigned char*)mBuf + mSize;
1045
// ?abr? Why is this special cased? Removing this code
1046
// does not change the behavior of this method.
1052
str.write((char*)p, 3);
1055
else if (shouldEscape[*p])
1057
int hi = (*p & 0xF0)>>4;
1058
int low = (*p & 0x0F);
1060
str << '%' << hex[hi] << hex[low];
1071
inline bool operator!=(const Data& lhs, const Data& rhs) { return !(lhs == rhs); }
1072
inline bool operator>(const Data& lhs, const Data& rhs) { return rhs < lhs; }
1073
inline bool operator<=(const Data& lhs, const Data& rhs) { return !(rhs < lhs); }
1074
inline bool operator>=(const Data& lhs, const Data& rhs) { return !(lhs < rhs); }
1075
inline bool operator!=(const Data& lhs, const char* rhs) { return !(lhs == rhs); }
1076
inline bool operator>(const Data& lhs, const char* rhs) { return rhs < lhs; }
1077
inline bool operator<=(const Data& lhs, const char* rhs) { return !(rhs < lhs); }
1078
inline bool operator>=(const Data& lhs, const char* rhs) { return !(lhs < rhs); }
1079
inline bool operator==(const char* lhs, const Data& rhs) { return rhs == lhs; }
1080
inline bool operator!=(const char* lhs, const Data& rhs) { return !(rhs == lhs); }
1081
inline bool operator>(const char* lhs, const Data& rhs) { return rhs < lhs; }
1082
inline bool operator<=(const char* lhs, const Data& rhs) { return !(rhs < lhs); }
1083
inline bool operator>=(const char* lhs, const Data& rhs) { return !(lhs < rhs); }
1084
#ifndef RESIP_USE_STL_STREAMS
1085
EncodeStream& operator<<(EncodeStream& strm, const Data& d);
1087
inline std::ostream& operator<<(std::ostream& strm, const Data& d)
1089
return strm.write(d.mBuf, d.mSize);
1094
operator+(const char* c, const Data& d)
1101
HashValue(resip::Data);
1105
/* ====================================================================
1106
* The Vovida Software License, Version 1.0
1108
* Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
1110
* Redistribution and use in source and binary forms, with or without
1111
* modification, are permitted provided that the following conditions
1114
* 1. Redistributions of source code must retain the above copyright
1115
* notice, this list of conditions and the following disclaimer.
1117
* 2. Redistributions in binary form must reproduce the above copyright
1118
* notice, this list of conditions and the following disclaimer in
1119
* the documentation and/or other materials provided with the
1122
* 3. The names "VOCAL", "Vovida Open Communication Application Library",
1123
* and "Vovida Open Communication Application Library (VOCAL)" must
1124
* not be used to endorse or promote products derived from this
1125
* software without prior written permission. For written
1126
* permission, please contact vocal@vovida.org.
1128
* 4. Products derived from this software may not be called "VOCAL", nor
1129
* may "VOCAL" appear in their name, without prior written
1130
* permission of Vovida Networks, Inc.
1132
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
1133
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1134
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
1135
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
1136
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
1137
* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
1138
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1139
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1140
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
1141
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1142
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
1143
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
1146
* ====================================================================
1148
* This software consists of voluntary contributions made by Vovida
1149
* Networks, Inc. and many individuals on behalf of Vovida Networks,
1150
* Inc. For more information on Vovida Networks, Inc., please see
1151
* <http://www.vovida.org/>.
1153
* vi: set shiftwidth=3 expandtab: