~ubuntu-branches/ubuntu/maverick/squid3/maverick-updates

« back to all changes in this revision

Viewing changes to src/StoreEntryStream.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2010-07-07 15:21:06 UTC
  • mfrom: (20.3.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100707152106-ozv23qjzn7q1jpaj
Tags: 3.1.5-2
* debian/control
  - Added build dependency on libltdl-dev fixing FTBFS on most archs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
1
/*
3
 
 * $Id: StoreEntryStream.h,v 1.5 2007/08/14 10:09:23 serassio Exp $
 
2
 * $Id$
4
3
 *
5
4
 *
6
5
 * SQUID Web Proxy Cache          http://www.squid-cache.org/
19
18
 *  it under the terms of the GNU General Public License as published by
20
19
 *  the Free Software Foundation; either version 2 of the License, or
21
20
 *  (at your option) any later version.
22
 
 *  
 
21
 *
23
22
 *  This program is distributed in the hope that it will be useful,
24
23
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25
24
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
25
 *  GNU General Public License for more details.
27
 
 *  
 
26
 *
28
27
 *  You should have received a copy of the GNU General Public License
29
28
 *  along with this program; if not, write to the Free Software
30
29
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
36
35
 
37
36
#include "Store.h"
38
37
 
 
38
#if HAVE_OSTREAM
39
39
#include <ostream>
 
40
#endif
40
41
 
41
42
/*
42
43
 * This class provides a streambuf interface for writing
48
49
{
49
50
 
50
51
public:
51
 
    StoreEntryStreamBuf(StoreEntry *anEntry) : theEntry(anEntry)
52
 
    {
 
52
    StoreEntryStreamBuf(StoreEntry *anEntry) : theEntry(anEntry) {
53
53
 
54
54
        theEntry->lock();
55
55
        theEntry->buffer();
56
56
    }
57
57
 
58
 
    ~StoreEntryStreamBuf()
59
 
    {
 
58
    ~StoreEntryStreamBuf() {
60
59
        theEntry->unlock();
61
60
    }
62
61
 
64
63
    /* flush the current buffer and the character that is overflowing
65
64
     * to the store entry.
66
65
     */
67
 
    virtual int_type overflow(int_type aChar = traits_type::eof())
68
 
    {
 
66
    virtual int_type overflow(int_type aChar = traits_type::eof()) {
69
67
        std::streamsize pending(pptr() - pbase());
70
68
 
71
69
        if (pending && sync ())
83
81
    }
84
82
 
85
83
    /* push the buffer to the store */
86
 
    virtual int sync()
87
 
    {
 
84
    virtual int sync() {
88
85
        std::streamsize pending(pptr() - pbase());
89
86
 
90
87
        if (pending)
98
95
    /* write multiple characters to the store entry
99
96
     * - this is an optimisation method.
100
97
     */
101
 
    virtual std::streamsize xsputn(const char * chars, std::streamsize number)
102
 
    {
 
98
    virtual std::streamsize xsputn(const char * chars, std::streamsize number) {
103
99
        if (number)
104
100
            theEntry->append(chars, number);
105
101