source: trunk/libdjvu/DjVuErrorList.h @ 209

Last change on this file since 209 was 206, checked in by Eugene Romanenko, 14 years ago

DJVU plugin: djvulibre updated to version 3.5.19

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