Main | License | Installation | FAQ | Screenshots | Contact | Links | Sf.net | Freshmeat.net | KDE-Apps.org
Requirements | Design | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

Recoder Class Reference
[Compilers]

#include <recoder.hpp>

Inheritance diagram for Recoder:

Inheritance graph
[legend]

Public Member Functions

 Recoder (const std::string &_request) throw (Error)
 Constructor.
virtual ~Recoder (void)
 Destructor.
virtual void translate (std::istream &inputStream, std::ostream &outputStream) const throw (Error)

Static Public Attributes

static RECODE_OUTER outer = NULL

Protected Attributes

RECODE_REQUEST request

Detailed Description

Character recoding. Compiler using the recode library to perform a character recoding. Before instantiating this class, the global variable for the recode library has to be initialised:
    Recoder::outer = recode_new_outer( false );
    ERRORMACRO( Recoder::outer != NULL, Error, ,
                "Failure initialising recoder library." );
    
When terminating, the destructing function has to be called:
    if ( Recoder::outer != NULL ) {
      recoder_delete_outer( Recoder::outer );
      Recoder::outer = NULL;
    };
    
Date:
Thu Jan 10 2006
Author:
Jan Wedekind (wedesoft@users.sourceforge.net)

Definition at line 51 of file recoder.hpp.


Constructor & Destructor Documentation

Recoder::Recoder ( const std::string &  _request  )  throw (Error)

Constructor.

Definition at line 26 of file recoder.cpp.

References ERRORMACRO.

00026                                                          :
00027   request(NULL)
00028 {
00029   assert( outer != NULL );
00030   request = recode_new_request( outer );
00031   ERRORMACRO( request, Error, , "Error allocating recoding request." );
00032 #ifndef NDEBUG
00033   request->verbose_flag = true;
00034 #endif
00035   request->ascii_graphics = true;
00036   if ( !recode_scan_request( request, _request.c_str() ) ) {
00037     recode_delete_request( request );
00038     ERRORMACRO( false, Error, ,
00039                 "Error requesting " << _request << " recoder." );
00040   };
00041 }

Recoder::~Recoder ( void   )  [virtual]

Destructor.

Definition at line 43 of file recoder.cpp.

References request.

00044 {
00045   recode_delete_request (request);
00046 }


Member Function Documentation

void Recoder::translate ( std::istream &  inputStream,
std::ostream &  outputStream 
) const throw (Error) [virtual]

Implements Compiler.

Definition at line 48 of file recoder.cpp.

References ERRORMACRO, and request.

00051 {
00052   streampos pos = inputStream.tellg();
00053   inputStream.seekg( 0, ios::end );
00054   int filesize = inputStream.tellg() - pos;
00055   inputStream.seekg( pos, ios::beg );
00056   
00057   shared_array< char > inputData( new char[filesize] );
00058   inputStream.read( inputData.get(), filesize );
00059   
00060   char *outputData = NULL;
00061   size_t
00062     outputLength = 0,
00063     outputAllocated = 0;
00064 
00065   bool retVal =
00066     recode_buffer_to_buffer( request, inputData.get(), filesize,
00067                              &outputData, &outputLength, &outputAllocated );
00068 
00069   inputData.reset();
00070 
00071   ERRORMACRO( retVal, Error, , "Error while recoding stream." );
00072   outputStream.write( outputData, outputLength );
00073 
00074   if ( outputData != NULL )
00075     free( outputData );
00076 }


Field Documentation

RECODE_OUTER Recoder::outer = NULL [static]

Definition at line 63 of file recoder.hpp.

Referenced by gui().

RECODE_REQUEST Recoder::request [protected]

Definition at line 66 of file recoder.hpp.

Referenced by translate(), and ~Recoder().


The documentation for this class was generated from the following files:

anymeal 0.30 - recipe management software - Make the most of your food! - © Jan Wedekind Sun Sep 14 16:01:29 2008 - GNU Free Documentation License