base64stream.h revision 8a6cdb1b534b7b6101222bcf53d47465a0bd7a91
1117N/A#ifndef __DOM_IO_BASE64STREAM_H__
1117N/A#define __DOM_IO_BASE64STREAM_H__
1117N/A
1117N/A/**
1117N/A * Phoebe DOM Implementation.
1117N/A *
1117N/A * Base64-enabled input and output streams
1117N/A *
1117N/A * This class allows easy encoding and decoding
1117N/A * of Base64 data with a stream interface, hiding
1117N/A * the implementation from the user.
1117N/A *
1117N/A * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
1117N/A *
1117N/A * Authors:
1117N/A * Bob Jamison
1117N/A *
1117N/A * Copyright (C) 2006 Bob Jamison
1117N/A *
1117N/A * This library is free software; you can redistribute it and/or
1117N/A * modify it under the terms of the GNU Lesser General Public
1117N/A * License as published by the Free Software Foundation; either
1117N/A * version 2.1 of the License, or (at your option) any later version.
1117N/A *
1117N/A * This library is distributed in the hope that it will be useful,
1117N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
1117N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1117N/A * Lesser General Public License for more details.
1117N/A *
1117N/A * You should have received a copy of the GNU Lesser General Public
1117N/A * License along with this library; if not, write to the Free Software
1117N/A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1117N/A */
1117N/A
1117N/A
1117N/A
1117N/A#include "domstream.h"
1117N/A
1117N/A
1117N/Anamespace org
1117N/A{
1117N/Anamespace w3c
1117N/A{
1117N/Anamespace dom
1117N/A{
1117N/Anamespace io
1117N/A{
1117N/A
1117N/A
1117N/A
1117N/A//#########################################################################
1117N/A//# B A S E 6 4 I N P U T S T R E A M
1117N/A//#########################################################################
/**
* This class is for decoding a Base-64 encoded InputStream source
*
*/
class Base64InputStream : public BasicInputStream
{
public:
Base64InputStream(InputStream &sourceStream);
virtual ~Base64InputStream();
virtual int available();
virtual void close();
virtual int get();
private:
int outBytes[3];
int outCount;
int padCount;
bool done;
}; // class Base64InputStream
//#########################################################################
//# B A S E 6 4 O U T P U T S T R E A M
//#########################################################################
/**
* This class is for Base-64 encoding data going to the
* destination OutputStream
*
*/
class Base64OutputStream : public BasicOutputStream
{
public:
Base64OutputStream(OutputStream &destinationStream);
virtual ~Base64OutputStream();
virtual void close();
virtual void flush();
virtual int put(XMLCh ch);
/**
* Sets the maximum line length for base64 output. If
* set to <=0, then there will be no line breaks;
*/
virtual void setColumnWidth(int val)
{ columnWidth = val; }
private:
void putCh(int ch);
int column;
int columnWidth;
unsigned long outBuf;
int bitCount;
}; // class Base64OutputStream
} //namespace io
} //namespace dom
} //namespace w3c
} //namespace org
#endif /* __INKSCAPE_IO_BASE64STREAM_H__ */