reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
CountStream.cxx
Go to the documentation of this file.
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
6
7// Remove warning about 'this' use in initiator list - pointer is only stored
8#if defined(WIN32) && !defined(__GNUC__)
9#pragma warning( disable : 4355 ) // using this in base member initializer list
10#endif
11
12using namespace resip;
13
14#ifdef RESIP_USE_STL_STREAMS
15static const int BuffSize(2048);
16// singleton buffer -- not really used
17static char Buffer[BuffSize];
18#endif
19
21 : mCount(count)
22{
23 mCount = 0;
24#ifdef RESIP_USE_STL_STREAMS
25 setp(Buffer, Buffer+BuffSize);
26#endif
27}
28
31
32#ifdef RESIP_USE_STL_STREAMS
33int
34CountBuffer::sync()
35{
36 size_t len = pptr() - pbase();
37 if (len > 0)
38 {
39 mCount += len;
40 // reset the put buffer
41 setp(Buffer, Buffer + BuffSize);
42 }
43 return 0;
44}
45
46int
47CountBuffer::overflow(int c)
48{
49 sync();
50 if (c != -1)
51 {
52 pbump(1);
53 return c;
54 }
55 return 0;
56}
57#else
59{
60 return mCount;
61}
62
63
64size_t CountBuffer::writebuf(const char *str, size_t count)
65{
66 mCount += count;
67 return count;
68}
69size_t CountBuffer::putbuf(char ch)
70{
71 mCount++;
72
73 return 1;
74}
75#endif
76
78 : CountBuffer(count), EncodeStream(this)
79{
80}
81
83{
84#ifdef RESIP_USE_STL_STREAMS
85 flush();
86#endif
87}
88
89/* ====================================================================
90 * The Vovida Software License, Version 1.0
91 *
92 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
93 *
94 * Redistribution and use in source and binary forms, with or without
95 * modification, are permitted provided that the following conditions
96 * are met:
97 *
98 * 1. Redistributions of source code must retain the above copyright
99 * notice, this list of conditions and the following disclaimer.
100 *
101 * 2. Redistributions in binary form must reproduce the above copyright
102 * notice, this list of conditions and the following disclaimer in
103 * the documentation and/or other materials provided with the
104 * distribution.
105 *
106 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
107 * and "Vovida Open Communication Application Library (VOCAL)" must
108 * not be used to endorse or promote products derived from this
109 * software without prior written permission. For written
110 * permission, please contact vocal@vovida.org.
111 *
112 * 4. Products derived from this software may not be called "VOCAL", nor
113 * may "VOCAL" appear in their name, without prior written
114 * permission of Vovida Networks, Inc.
115 *
116 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
117 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
118 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
119 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
120 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
121 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
122 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
123 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
124 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
125 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
126 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
127 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
128 * DAMAGE.
129 *
130 * ====================================================================
131 *
132 * This software consists of voluntary contributions made by Vovida
133 * Networks, Inc. and many individuals on behalf of Vovida Networks,
134 * Inc. For more information on Vovida Networks, Inc., please see
135 * <http://www.vovida.org/>.
136 *
137 */
Implementation of std::streambuf used to back CountStream.
virtual size_t putbuf(char ch)
virtual uint64_t tellpbuf(void)
virtual size_t writebuf(const char *s, size_t count)
CountBuffer(size_t &count)
Constructs a CountBuffer with the reference to the size_t where the count should be written after flu...
~CountStream()
Calls flush on itself to force the update to the count reference passed into the constructor.
CountStream(size_t &count)
Constructs a CountStream with a reference to where the count of bytes written to the stream should be...
dcm! – add UnusedChecking(_enum) below;
unsigned long long uint64_t
Definition Stun.hxx:39
#define EncodeStream