Blame libdjvu/DjVuErrorList.h

Packit df99a1
//C-  -*- C++ -*-
Packit df99a1
//C- -------------------------------------------------------------------
Packit df99a1
//C- DjVuLibre-3.5
Packit df99a1
//C- Copyright (c) 2002  Leon Bottou and Yann Le Cun.
Packit df99a1
//C- Copyright (c) 2001  AT&T
Packit df99a1
//C-
Packit df99a1
//C- This software is subject to, and may be distributed under, the
Packit df99a1
//C- GNU General Public License, either Version 2 of the license,
Packit df99a1
//C- or (at your option) any later version. The license should have
Packit df99a1
//C- accompanied the software or you may obtain a copy of the license
Packit df99a1
//C- from the Free Software Foundation at http://www.fsf.org .
Packit df99a1
//C-
Packit df99a1
//C- This program is distributed in the hope that it will be useful,
Packit df99a1
//C- but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit df99a1
//C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit df99a1
//C- GNU General Public License for more details.
Packit df99a1
//C- 
Packit df99a1
//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library from
Packit df99a1
//C- Lizardtech Software.  Lizardtech Software has authorized us to
Packit df99a1
//C- replace the original DjVu(r) Reference Library notice by the following
Packit df99a1
//C- text (see doc/lizard2002.djvu and doc/lizardtech2007.djvu):
Packit df99a1
//C-
Packit df99a1
//C-  ------------------------------------------------------------------
Packit df99a1
//C- | DjVu (r) Reference Library (v. 3.5)
Packit df99a1
//C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
Packit df99a1
//C- | The DjVu Reference Library is protected by U.S. Pat. No.
Packit df99a1
//C- | 6,058,214 and patents pending.
Packit df99a1
//C- |
Packit df99a1
//C- | This software is subject to, and may be distributed under, the
Packit df99a1
//C- | GNU General Public License, either Version 2 of the license,
Packit df99a1
//C- | or (at your option) any later version. The license should have
Packit df99a1
//C- | accompanied the software or you may obtain a copy of the license
Packit df99a1
//C- | from the Free Software Foundation at http://www.fsf.org .
Packit df99a1
//C- |
Packit df99a1
//C- | The computer code originally released by LizardTech under this
Packit df99a1
//C- | license and unmodified by other parties is deemed "the LIZARDTECH
Packit df99a1
//C- | ORIGINAL CODE."  Subject to any third party intellectual property
Packit df99a1
//C- | claims, LizardTech grants recipient a worldwide, royalty-free, 
Packit df99a1
//C- | non-exclusive license to make, use, sell, or otherwise dispose of 
Packit df99a1
//C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the 
Packit df99a1
//C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU 
Packit df99a1
//C- | General Public License.   This grant only confers the right to 
Packit df99a1
//C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to 
Packit df99a1
//C- | the extent such infringement is reasonably necessary to enable 
Packit df99a1
//C- | recipient to make, have made, practice, sell, or otherwise dispose 
Packit df99a1
//C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to 
Packit df99a1
//C- | any greater extent that may be necessary to utilize further 
Packit df99a1
//C- | modifications or combinations.
Packit df99a1
//C- |
Packit df99a1
//C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
Packit df99a1
//C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
Packit df99a1
//C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
Packit df99a1
//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Packit df99a1
//C- +------------------------------------------------------------------
Packit df99a1
Packit df99a1
#ifndef _DJVUERRORLIST_H
Packit df99a1
#define _DJVUERRORLIST_H
Packit df99a1
#ifdef HAVE_CONFIG_H
Packit df99a1
#include "config.h"
Packit df99a1
#endif
Packit df99a1
#if NEED_GNUG_PRAGMAS
Packit df99a1
# pragma interface
Packit df99a1
#endif
Packit df99a1
Packit df99a1
Packit df99a1
#include "DjVuPort.h"
Packit df99a1
Packit df99a1
#ifdef HAVE_NAMESPACES
Packit df99a1
namespace DJVU {
Packit df99a1
# ifdef NOT_DEFINED // Just to fool emacs c++ mode
Packit df99a1
}
Packit df99a1
#endif
Packit df99a1
#endif
Packit df99a1
Packit df99a1
class ByteStream;
Packit df99a1
Packit df99a1
/** @name DjVuErrorList.h
Packit df99a1
    This file implements a very simple class for redirecting port caster
Packit df99a1
    messages that would normally end up on stderr to a double linked list.
Packit df99a1
Packit df99a1
    @memo DjVuErrorList class.
Packit df99a1
    @author Bill C Riemers <docbill@sourceforge.net>
Packit df99a1
*/
Packit df99a1
Packit df99a1
//@{
Packit df99a1
Packit df99a1
/** #DjVuErrorList# provides a convenient way to redirect error messages
Packit df99a1
    from classes derived from DjVuPort to a list that can be accessed at
Packit df99a1
    any time. */
Packit df99a1
Packit df99a1
class DjVuErrorList : public DjVuSimplePort
Packit df99a1
{
Packit df99a1
protected:
Packit df99a1
     /// The normal port caster constructor. 
Packit df99a1
  DjVuErrorList(void);
Packit df99a1
public:
Packit df99a1
  static GP<DjVuErrorList> create(void) {return new DjVuErrorList();}
Packit df99a1
Packit df99a1
     /// This constructor allows the user to specify the ByteStream.
Packit df99a1
  GURL set_stream(GP<ByteStream>);
Packit df99a1
Packit df99a1
     /// Append all error messages to the list
Packit df99a1
  virtual bool notify_error(const DjVuPort * source, const GUTF8String & msg);
Packit df99a1
Packit df99a1
     /// Append all status messages to the list
Packit df99a1
  virtual bool notify_status(const DjVuPort * source, const GUTF8String & msg);
Packit df99a1
Packit df99a1
     /// Add a new class to have its messages redirected here.
Packit df99a1
  inline void connect( const DjVuPort &port);
Packit df99a1
Packit df99a1
     /// Get the listing of errors, and clear the list.
Packit df99a1
  inline GList<GUTF8String> GetErrorList(void);
Packit df99a1
Packit df99a1
     /// Just clear the list.
Packit df99a1
  inline void ClearError(void);
Packit df99a1
Packit df99a1
     /// Get one error message and clear that message from the list.
Packit df99a1
  GUTF8String GetError(void);
Packit df99a1
Packit df99a1
     /// Check if there are anymore error messages.
Packit df99a1
  inline bool HasError(void) const;
Packit df99a1
Packit df99a1
     /// Get the listing of status messages, and clear the list.
Packit df99a1
  inline GList<GUTF8String> GetStatusList(void);
Packit df99a1
Packit df99a1
     /// Just clear the list.
Packit df99a1
  inline void ClearStatus(void);
Packit df99a1
Packit df99a1
     /// Get one status message and clear that message from the list.
Packit df99a1
  GUTF8String GetStatus(void);
Packit df99a1
Packit df99a1
     /// Check if there are any more status messages.
Packit df99a1
  inline bool HasStatus(void) const;
Packit df99a1
Packit df99a1
     /** This gets the data.  We can't use the simple port's request
Packit df99a1
       data since we want to allow the user to specify the ByteStream. */
Packit df99a1
  virtual GP<DataPool> request_data (
Packit df99a1
    const DjVuPort * source, const GURL & url );
Packit df99a1
Packit df99a1
private:
Packit df99a1
  GURL pool_url;
Packit df99a1
  GP<DataPool> pool;
Packit df99a1
  GList<GUTF8String> Errors;
Packit df99a1
  GList<GUTF8String> Status;
Packit df99a1
private: //dummy stuff
Packit df99a1
  static GURL set_stream(ByteStream *);
Packit df99a1
};
Packit df99a1
Packit df99a1
inline void
Packit df99a1
DjVuErrorList::connect( const DjVuPort &port )
Packit df99a1
{ get_portcaster()->add_route(&port, this); }
Packit df99a1
Packit df99a1
inline GList<GUTF8String>
Packit df99a1
DjVuErrorList::GetErrorList(void)
Packit df99a1
{
Packit df99a1
  GList<GUTF8String> retval=(const GList<GUTF8String>)Errors;
Packit df99a1
  Errors.empty();
Packit df99a1
  return retval;
Packit df99a1
}
Packit df99a1
Packit df99a1
inline void
Packit df99a1
DjVuErrorList::ClearError(void)
Packit df99a1
{ Errors.empty(); }
Packit df99a1
Packit df99a1
inline GList<GUTF8String>
Packit df99a1
DjVuErrorList::GetStatusList(void)
Packit df99a1
{
Packit df99a1
  GList<GUTF8String> retval=(const GList<GUTF8String>)Status;
Packit df99a1
  Status.empty();
Packit df99a1
  return retval;
Packit df99a1
}
Packit df99a1
Packit df99a1
inline void
Packit df99a1
DjVuErrorList::ClearStatus(void)
Packit df99a1
{ Status.empty(); }
Packit df99a1
Packit df99a1
inline bool
Packit df99a1
DjVuErrorList::HasError(void) const
Packit df99a1
{ return !Errors.isempty(); }
Packit df99a1
Packit df99a1
inline bool
Packit df99a1
DjVuErrorList::HasStatus(void) const
Packit df99a1
{ return !Status.isempty(); }
Packit df99a1
Packit df99a1
Packit df99a1
#ifdef HAVE_NAMESPACES
Packit df99a1
}
Packit df99a1
# ifndef NOT_USING_DJVU_NAMESPACE
Packit df99a1
using namespace DJVU;
Packit df99a1
# endif
Packit df99a1
#endif
Packit df99a1
#endif