// // aegis - project change supervisor // Copyright (C) 2014 Peter Miller // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or (at // your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program. If not, see . // #ifndef LIBAEGIS_OUTPUT_FILTER_BASE85_H #define LIBAEGIS_OUTPUT_FILTER_BASE85_H #include /** * The output_filter_base85 class is used to represent the processing * necessary to pre-MIME BASE85 encode an output stream. */ class output_filter_base85: public output_filter { public: /** * The destructor. */ virtual ~output_filter_base85(); /** * The create class method is used to create new dynamically * allocated instances of this class. * * @param deeper * The deeper output, the place this filter writes the filtered * output. */ static pointer create(const output::pointer &deeper); protected: // See base class for documentation. nstring type_name(void) const; // See base class for documentation. long ftell_inner(void) const; // See base class for documentation. void write_inner(const void *data, size_t length); // See base class for documentation. void end_of_line_inner(void); private: /** * The constructor. It's private on purpose, use the "create" * class method instead. * * @param deeper * The deeper output, the place this filter writes the filtered * output. */ output_filter_base85(const output::pointer &deeper); /** * The accumulator instance variable is used to remember the * four bytes being encoded, as a single 32-bit number. */ unsigned long accumulator; /** * The accumulator_nbytes instance variable is used to remember * how many of the four bytes are present in the #accumulator * at the moment. */ unsigned accumulator_nbytes; /** * The column instance variable is used to remember the * character column of the output position, used to break long * lines. Position of the newline is not significant. */ unsigned column; /** * The content_length instance variable is used to remember how * many bytes of binary data have been presented so far. */ unsigned long content_length; /** * The check_xor instance variable is used to remember a * running XOR check of the data so far. */ unsigned long check_xor; /** * The check_sum instance variable is used to remember a * running total of all the bytes (plus one each) of the data * so far. */ unsigned long check_sum; /** * The check_rot instance variable is used to remember a cyclic * rum of all the data so far. */ unsigned long check_rot; /** * The bol instance variable is used to remember whether or not we * are positioned at the beginning of a line. */ bool bol; /** * The char_out method is used to write out a character, and * then also a newline if the line becomes too long (uses * #column to keep track). */ void char_out(unsigned char c); /** * The word_out method is used to encode and output the * #accumulator word, once there are 4 bytes present. */ void word_out(unsigned long word); /** * The encode method is used to remember the various sums, and * outpout a word every 4 bytes. */ void encode(unsigned char c); /** * The default constructor. Do not use. */ output_filter_base85(); /** * The copy constructor. Do not use. */ output_filter_base85(const output_filter_base85 &); /** * The assignment operator. Do not use. */ output_filter_base85 operator=(const output_filter_base85 &); }; // vim: set ts=8 sw=4 et : #endif // LIBAEGIS_OUTPUT_FILTER_BASE85_H