reSIProcate/rutil  9694
CountStream.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_COUNTSTREAM_HXX)
00002 #define RESIP_COUNTSTREAM_HXX 
00003 
00004 #ifdef HAVE_CONFIG_H
00005 #include "config.h"
00006 #endif
00007 
00008 #include <iostream>
00009 #include "rutil/Data.hxx"
00010 
00011 namespace resip
00012 {
00013 
00018 class CountBuffer : 
00019 #ifdef RESIP_USE_STL_STREAMS
00020    public std::streambuf
00021 #else
00022    public ResipStreamBuf
00023 #endif
00024 {
00025    public:
00029       CountBuffer(size_t& count);
00030       virtual ~CountBuffer();
00031 
00032    protected:      
00033 #ifdef RESIP_USE_STL_STREAMS
00034       virtual int sync();
00035       virtual int overflow(int c = -1);
00036 #else
00037       virtual size_t writebuf(const char *s, size_t count);
00038       virtual size_t putbuf(char ch);
00039       virtual void flushbuf(void){}
00040       virtual size_t readbuf(char *buf, size_t count)
00041       {
00042          assert(0);
00043          return 0;
00044       }
00045 
00046       virtual UInt64 tellpbuf(void);
00047 #endif
00048 
00049    private:
00050       size_t& mCount;
00051 };
00052 
00061 class CountStream : private CountBuffer, public EncodeStream
00062 {
00063    public:
00069       CountStream(size_t& count);
00073       ~CountStream();
00074 
00075 };
00076 
00077 }
00078 
00079 #endif
00080 
00081 /* ====================================================================
00082  * The Vovida Software License, Version 1.0 
00083  * 
00084  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00085  * 
00086  * Redistribution and use in source and binary forms, with or without
00087  * modification, are permitted provided that the following conditions
00088  * are met:
00089  * 
00090  * 1. Redistributions of source code must retain the above copyright
00091  *    notice, this list of conditions and the following disclaimer.
00092  * 
00093  * 2. Redistributions in binary form must reproduce the above copyright
00094  *    notice, this list of conditions and the following disclaimer in
00095  *    the documentation and/or other materials provided with the
00096  *    distribution.
00097  * 
00098  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00099  *    and "Vovida Open Communication Application Library (VOCAL)" must
00100  *    not be used to endorse or promote products derived from this
00101  *    software without prior written permission. For written
00102  *    permission, please contact vocal@vovida.org.
00103  *
00104  * 4. Products derived from this software may not be called "VOCAL", nor
00105  *    may "VOCAL" appear in their name, without prior written
00106  *    permission of Vovida Networks, Inc.
00107  * 
00108  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00109  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00110  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00111  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00112  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00113  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00114  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00115  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00116  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00117  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00118  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00119  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00120  * DAMAGE.
00121  * 
00122  * ====================================================================
00123  * 
00124  * This software consists of voluntary contributions made by Vovida
00125  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00126  * Inc.  For more information on Vovida Networks, Inc., please see
00127  * <http://www.vovida.org/>.
00128  *
00129  */