Coverage Report

Created: 2025-12-31 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/resiprocate/resip/stack/QValue.hxx
Line
Count
Source
1
#if !defined(RESIP_QVALUE_HXX)
2
#define RESIP_QVALUE_HXX 
3
4
#include "rutil/Data.hxx"
5
#include "rutil/ParseBuffer.hxx"
6
7
#ifndef RESIP_FIXED_POINT
8
#include <math.h>
9
// Required due to float point inaccuracies and platform dependent issues (ie. rounding)
10
0
static int doubleToInt(const double d) { double f = floor(d); double c = ceil(d); return (((c-d) >= (d-f)) ? (int)f :(int)c); }
Unexecuted instantiation: fuzzStack.cxx:doubleToInt(double)
Unexecuted instantiation: TestSupport.cxx:doubleToInt(double)
Unexecuted instantiation: Auth.cxx:doubleToInt(double)
Unexecuted instantiation: CSeqCategory.cxx:doubleToInt(double)
Unexecuted instantiation: CallId.cxx:doubleToInt(double)
Unexecuted instantiation: DateCategory.cxx:doubleToInt(double)
Unexecuted instantiation: DayOfWeekHash.cxx:doubleToInt(double)
Unexecuted instantiation: DtmfPayloadContents.cxx:doubleToInt(double)
Unexecuted instantiation: ExpiresCategory.cxx:doubleToInt(double)
Unexecuted instantiation: GenericUri.cxx:doubleToInt(double)
Unexecuted instantiation: IntegerCategory.cxx:doubleToInt(double)
Unexecuted instantiation: Mime.cxx:doubleToInt(double)
Unexecuted instantiation: NameAddr.cxx:doubleToInt(double)
Unexecuted instantiation: RequestLine.cxx:doubleToInt(double)
Unexecuted instantiation: Contents.cxx:doubleToInt(double)
Unexecuted instantiation: ContentsFactoryBase.cxx:doubleToInt(double)
Unexecuted instantiation: CpimContents.cxx:doubleToInt(double)
Unexecuted instantiation: DialogInfoContents.cxx:doubleToInt(double)
Unexecuted instantiation: QValueParameter.cxx:doubleToInt(double)
Unexecuted instantiation: GenericPidfContents.cxx:doubleToInt(double)
Unexecuted instantiation: HeaderFieldValue.cxx:doubleToInt(double)
Unexecuted instantiation: Headers.cxx:doubleToInt(double)
Unexecuted instantiation: LazyParser.cxx:doubleToInt(double)
Unexecuted instantiation: MessageWaitingContents.cxx:doubleToInt(double)
Unexecuted instantiation: MonthHash.cxx:doubleToInt(double)
Unexecuted instantiation: MsgHeaderScanner.cxx:doubleToInt(double)
Unexecuted instantiation: MultipartMixedContents.cxx:doubleToInt(double)
Unexecuted instantiation: OctetContents.cxx:doubleToInt(double)
Unexecuted instantiation: ParameterTypes.cxx:doubleToInt(double)
Unexecuted instantiation: ParserCategory.cxx:doubleToInt(double)
Unexecuted instantiation: ParserContainerBase.cxx:doubleToInt(double)
Unexecuted instantiation: Pkcs7Contents.cxx:doubleToInt(double)
Unexecuted instantiation: Pkcs8Contents.cxx:doubleToInt(double)
Unexecuted instantiation: PlainContents.cxx:doubleToInt(double)
Unexecuted instantiation: PrivacyCategory.cxx:doubleToInt(double)
Unexecuted instantiation: RAckCategory.cxx:doubleToInt(double)
Unexecuted instantiation: Rlmi.cxx:doubleToInt(double)
Unexecuted instantiation: SdpContents.cxx:doubleToInt(double)
Unexecuted instantiation: SipFrag.cxx:doubleToInt(double)
Unexecuted instantiation: SipMessage.cxx:doubleToInt(double)
Unexecuted instantiation: Transport.cxx:doubleToInt(double)
Unexecuted instantiation: TrickleIceContents.cxx:doubleToInt(double)
Unexecuted instantiation: Uri.cxx:doubleToInt(double)
Unexecuted instantiation: X509Contents.cxx:doubleToInt(double)
Unexecuted instantiation: InvalidContents.cxx:doubleToInt(double)
Unexecuted instantiation: UInt32Category.cxx:doubleToInt(double)
Unexecuted instantiation: StatusLine.cxx:doubleToInt(double)
Unexecuted instantiation: StringCategory.cxx:doubleToInt(double)
Unexecuted instantiation: Token.cxx:doubleToInt(double)
Unexecuted instantiation: TokenOrQuotedStringCategory.cxx:doubleToInt(double)
Unexecuted instantiation: Via.cxx:doubleToInt(double)
Unexecuted instantiation: WarningCategory.cxx:doubleToInt(double)
Unexecuted instantiation: QValue.cxx:doubleToInt(double)
Unexecuted instantiation: HeaderFieldValueList.cxx:doubleToInt(double)
Unexecuted instantiation: Helper.cxx:doubleToInt(double)
Unexecuted instantiation: MultipartAlternativeContents.cxx:doubleToInt(double)
Unexecuted instantiation: MultipartSignedContents.cxx:doubleToInt(double)
Unexecuted instantiation: NonceHelper.cxx:doubleToInt(double)
Unexecuted instantiation: ParameterHash.cxx:doubleToInt(double)
Unexecuted instantiation: BasicNonceHelper.cxx:doubleToInt(double)
11
#endif
12
13
namespace resip
14
{
15
   class QValue 
16
   {
17
   public:
18
0
      explicit QValue() : mValue(0) { }
19
3.44k
      explicit QValue(int val) : mValue(val) { }
20
0
      explicit QValue(const Data& data) { setValue(data); }
21
22
0
      operator int() const { return mValue; }
23
24
0
      bool operator<(const QValue& rhs) const { return mValue < rhs.mValue; }
25
0
      bool operator>(const QValue& rhs) const { return mValue > rhs.mValue; }
26
0
      bool operator<=(const QValue& rhs) const { return mValue <= rhs.mValue; }
27
0
      bool operator>=(const QValue& rhs) const { return mValue >= rhs.mValue; }
28
0
      bool operator==(const QValue& rhs) const { return mValue == rhs.mValue; }
29
0
      bool operator!=(const QValue& rhs) const { return mValue != rhs.mValue; }      
30
31
0
      bool operator<(const int rhs) const { return mValue < rhs; }
32
0
      bool operator>(const int rhs) const { return mValue > rhs; }
33
0
      bool operator<=(const int rhs) const { return mValue <= rhs; }
34
0
      bool operator>=(const int rhs) const { return mValue >= rhs; }
35
0
      bool operator==(const int rhs) const { return mValue == rhs; }
36
0
      bool operator!=(const int rhs) const { return mValue != rhs; }      
37
38
0
      bool operator<(const long rhs) const { return mValue < rhs; }
39
0
      bool operator>(const long rhs) const { return mValue > rhs; }
40
0
      bool operator<=(const long rhs) const { return mValue <= rhs; }
41
0
      bool operator>=(const long rhs) const { return mValue >= rhs; }
42
0
      bool operator==(const long rhs) const { return mValue == rhs; }
43
0
      bool operator!=(const long rhs) const { return mValue != rhs; }      
44
45
0
      QValue& operator=(const QValue& rhs) { mValue = rhs.mValue;  return (*this); }
46
0
      QValue& operator=(const int rhs) { setValue(rhs); return (*this); }      
47
0
      QValue& operator=(const long rhs) { setValue(rhs); return (*this); }      
48
49
#ifndef RESIP_FIXED_POINT
50
51
0
      float floatVal() const { return mValue/float(1000.0); }
52
53
0
      operator float() const { return floatVal(); }
54
0
      operator double() const { return (double) floatVal(); }    
55
56
0
      bool operator<(const float rhs) const { return mValue < doubleToInt(rhs*1000.0); }
57
0
      bool operator>(const float rhs) const { return mValue > doubleToInt(rhs*1000.0); }
58
0
      bool operator<=(const float rhs) const { return mValue <= doubleToInt(rhs*1000.0); }
59
0
      bool operator>=(const float rhs) const { return mValue >= doubleToInt(rhs*1000.0); }
60
0
      bool operator==(const float rhs) const { return mValue == doubleToInt(rhs*1000.0); }
61
0
      bool operator!=(const float rhs) const { return mValue != doubleToInt(rhs*1000.0); }
62
63
0
      bool operator<(const double rhs) const { return mValue < doubleToInt(rhs*1000.0); }
64
0
      bool operator>(const double rhs) const { return mValue > doubleToInt(rhs*1000.0); }
65
0
      bool operator<=(const double rhs) const { return mValue <= doubleToInt(rhs*1000.0); }
66
0
      bool operator>=(const double rhs) const { return mValue >= doubleToInt(rhs*1000.0); }
67
0
      bool operator==(const double rhs) const { return mValue == doubleToInt(rhs*1000.0); }
68
0
      bool operator!=(const double rhs) const { return mValue != doubleToInt(rhs*1000.0); }
69
70
0
      QValue& operator=(const float rhs) { setValue(doubleToInt(rhs*1000.0)); return (*this); }      
71
0
      QValue& operator=(const double rhs) { setValue(doubleToInt(rhs*1000.0)); return (*this); }      
72
#endif    
73
3.10k
      void setValue(int val) { mValue = (val<0) || (val>1000) ? 1000 : val; }
74
0
      void setValue(const Data& data) { ParseBuffer pb(data); mValue = pb.qVal(); }
75
0
      int getValue() const { return mValue; }
76
      const Data& getData() const;
77
      EncodeStream& encode(EncodeStream& stream) const;
78
79
   private:
80
      int mValue;
81
      mutable Data mDataValue;
82
   };
83
}
84
85
#endif
86
87
/* ====================================================================
88
 * The Vovida Software License, Version 1.0 
89
 * 
90
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
91
 * 
92
 * Redistribution and use in source and binary forms, with or without
93
 * modification, are permitted provided that the following conditions
94
 * are met:
95
 * 
96
 * 1. Redistributions of source code must retain the above copyright
97
 *    notice, this list of conditions and the following disclaimer.
98
 * 
99
 * 2. Redistributions in binary form must reproduce the above copyright
100
 *    notice, this list of conditions and the following disclaimer in
101
 *    the documentation and/or other materials provided with the
102
 *    distribution.
103
 * 
104
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
105
 *    and "Vovida Open Communication Application Library (VOCAL)" must
106
 *    not be used to endorse or promote products derived from this
107
 *    software without prior written permission. For written
108
 *    permission, please contact vocal@vovida.org.
109
 *
110
 * 4. Products derived from this software may not be called "VOCAL", nor
111
 *    may "VOCAL" appear in their name, without prior written
112
 *    permission of Vovida Networks, Inc.
113
 * 
114
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
115
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
116
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
117
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
118
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
119
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
120
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
121
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
122
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
123
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
124
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
125
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
126
 * DAMAGE.
127
 * 
128
 * ====================================================================
129
 * 
130
 * This software consists of voluntary contributions made by Vovida
131
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
132
 * Inc.  For more information on Vovida Networks, Inc., please see
133
 * <http://www.vovida.org/>.
134
 *
135
 */