~ubuntu-branches/debian/squeeze/djvulibre/squeeze

« back to all changes in this revision

Viewing changes to libdjvu/DjVuErrorList.h

  • Committer: Bazaar Package Importer
  • Author(s): Barak A. Pearlmutter
  • Date: 2004-11-01 16:49:49 UTC
  • Revision ID: james.westby@ubuntu.com-20041101164949-fm4bl2hmkvkseoqw
Tags: upstream-3.5.14
ImportĀ upstreamĀ versionĀ 3.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//C-  -*- C++ -*-
 
2
//C- -------------------------------------------------------------------
 
3
//C- DjVuLibre-3.5
 
4
//C- Copyright (c) 2002  Leon Bottou and Yann Le Cun.
 
5
//C- Copyright (c) 2001  AT&T
 
6
//C-
 
7
//C- This software is subject to, and may be distributed under, the
 
8
//C- GNU General Public License, Version 2. The license should have
 
9
//C- accompanied the software or you may obtain a copy of the license
 
10
//C- from the Free Software Foundation at http://www.fsf.org .
 
11
//C-
 
12
//C- This program is distributed in the hope that it will be useful,
 
13
//C- but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
//C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
//C- GNU General Public License for more details.
 
16
//C- 
 
17
//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library
 
18
//C- distributed by Lizardtech Software.  On July 19th 2002, Lizardtech 
 
19
//C- Software authorized us to replace the original DjVu(r) Reference 
 
20
//C- Library notice by the following text (see doc/lizard2002.djvu):
 
21
//C-
 
22
//C-  ------------------------------------------------------------------
 
23
//C- | DjVu (r) Reference Library (v. 3.5)
 
24
//C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
 
25
//C- | The DjVu Reference Library is protected by U.S. Pat. No.
 
26
//C- | 6,058,214 and patents pending.
 
27
//C- |
 
28
//C- | This software is subject to, and may be distributed under, the
 
29
//C- | GNU General Public License, Version 2. The license should have
 
30
//C- | accompanied the software or you may obtain a copy of the license
 
31
//C- | from the Free Software Foundation at http://www.fsf.org .
 
32
//C- |
 
33
//C- | The computer code originally released by LizardTech under this
 
34
//C- | license and unmodified by other parties is deemed "the LIZARDTECH
 
35
//C- | ORIGINAL CODE."  Subject to any third party intellectual property
 
36
//C- | claims, LizardTech grants recipient a worldwide, royalty-free, 
 
37
//C- | non-exclusive license to make, use, sell, or otherwise dispose of 
 
38
//C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the 
 
39
//C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU 
 
40
//C- | General Public License.   This grant only confers the right to 
 
41
//C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to 
 
42
//C- | the extent such infringement is reasonably necessary to enable 
 
43
//C- | recipient to make, have made, practice, sell, or otherwise dispose 
 
44
//C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to 
 
45
//C- | any greater extent that may be necessary to utilize further 
 
46
//C- | modifications or combinations.
 
47
//C- |
 
48
//C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
 
49
//C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 
50
//C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
 
51
//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
 
52
//C- +------------------------------------------------------------------
 
53
// 
 
54
// $Id: DjVuErrorList.h,v 1.9 2003/11/07 22:08:20 leonb Exp $
 
55
// $Name: release_3_5_14 $
 
56
 
 
57
#ifndef _DJVUERRORLIST_H
 
58
#define _DJVUERRORLIST_H
 
59
#ifdef HAVE_CONFIG_H
 
60
#include "config.h"
 
61
#endif
 
62
#if NEED_GNUG_PRAGMAS
 
63
# pragma interface
 
64
#endif
 
65
 
 
66
 
 
67
#include "DjVuPort.h"
 
68
 
 
69
#ifdef HAVE_NAMESPACES
 
70
namespace DJVU {
 
71
# ifdef NOT_DEFINED // Just to fool emacs c++ mode
 
72
}
 
73
#endif
 
74
#endif
 
75
 
 
76
class ByteStream;
 
77
 
 
78
/** @name DjVuErrorList.h
 
79
    This file implements a very simple class for redirecting port caster
 
80
    messages that would normally end up on stderr to a double linked list.
 
81
 
 
82
    @memo DjVuErrorList class.
 
83
    @author Bill C Riemers <docbill@sourceforge.net>
 
84
    @version #$Id: DjVuErrorList.h,v 1.9 2003/11/07 22:08:20 leonb Exp $#
 
85
*/
 
86
 
 
87
//@{
 
88
 
 
89
/** #DjVuErrorList# provides a convenient way to redirect error messages
 
90
    from classes derived from DjVuPort to a list that can be accessed at
 
91
    any time. */
 
92
 
 
93
class DjVuErrorList : public DjVuSimplePort
 
94
{
 
95
protected:
 
96
     /// The normal port caster constructor. 
 
97
  DjVuErrorList(void);
 
98
public:
 
99
  static GP<DjVuErrorList> create(void) {return new DjVuErrorList();}
 
100
 
 
101
     /// This constructor allows the user to specify the ByteStream.
 
102
  GURL set_stream(GP<ByteStream>);
 
103
 
 
104
     /// Append all error messages to the list
 
105
  virtual bool notify_error(const DjVuPort * source, const GUTF8String & msg);
 
106
 
 
107
     /// Append all status messages to the list
 
108
  virtual bool notify_status(const DjVuPort * source, const GUTF8String & msg);
 
109
 
 
110
     /// Add a new class to have its messages redirected here.
 
111
  inline void connect( const DjVuPort &port);
 
112
 
 
113
     /// Get the listing of errors, and clear the list.
 
114
  inline GList<GUTF8String> GetErrorList(void);
 
115
 
 
116
     /// Just clear the list.
 
117
  inline void ClearError(void);
 
118
 
 
119
     /// Get one error message and clear that message from the list.
 
120
  GUTF8String GetError(void);
 
121
 
 
122
     /// Check if there are anymore error messages.
 
123
  inline bool HasError(void) const;
 
124
 
 
125
     /// Get the listing of status messages, and clear the list.
 
126
  inline GList<GUTF8String> GetStatusList(void);
 
127
 
 
128
     /// Just clear the list.
 
129
  inline void ClearStatus(void);
 
130
 
 
131
     /// Get one status message and clear that message from the list.
 
132
  GUTF8String GetStatus(void);
 
133
 
 
134
     /// Check if there are any more status messages.
 
135
  inline bool HasStatus(void) const;
 
136
 
 
137
     /** This gets the data.  We can't use the simple port's request
 
138
       data since we want to allow the user to specify the ByteStream. */
 
139
  virtual GP<DataPool> request_data (
 
140
    const DjVuPort * source, const GURL & url );
 
141
 
 
142
private:
 
143
  GURL pool_url;
 
144
  GP<DataPool> pool;
 
145
  GList<GUTF8String> Errors;
 
146
  GList<GUTF8String> Status;
 
147
private: //dummy stuff
 
148
  static GURL set_stream(ByteStream *);
 
149
};
 
150
 
 
151
inline void
 
152
DjVuErrorList::connect( const DjVuPort &port )
 
153
{ get_portcaster()->add_route(&port, this); }
 
154
 
 
155
inline GList<GUTF8String>
 
156
DjVuErrorList::GetErrorList(void)
 
157
{
 
158
  GList<GUTF8String> retval=(const GList<GUTF8String>)Errors;
 
159
  Errors.empty();
 
160
  return retval;
 
161
}
 
162
 
 
163
inline void
 
164
DjVuErrorList::ClearError(void)
 
165
{ Errors.empty(); }
 
166
 
 
167
inline GList<GUTF8String>
 
168
DjVuErrorList::GetStatusList(void)
 
169
{
 
170
  GList<GUTF8String> retval=(const GList<GUTF8String>)Status;
 
171
  Status.empty();
 
172
  return retval;
 
173
}
 
174
 
 
175
inline void
 
176
DjVuErrorList::ClearStatus(void)
 
177
{ Status.empty(); }
 
178
 
 
179
inline bool
 
180
DjVuErrorList::HasError(void) const
 
181
{ return !Errors.isempty(); }
 
182
 
 
183
inline bool
 
184
DjVuErrorList::HasStatus(void) const
 
185
{ return !Status.isempty(); }
 
186
 
 
187
 
 
188
#ifdef HAVE_NAMESPACES
 
189
}
 
190
# ifndef NOT_USING_DJVU_NAMESPACE
 
191
using namespace DJVU;
 
192
# endif
 
193
#endif
 
194
#endif