decode.h
Go to the documentation of this file.
1 // :mode=c++:
2 /*
3 decode.h - c++ wrapper for a base64 decoding algorithm
4 
5 This is part of the libb64 project, and has been placed in the public domain.
6 For details, see http://sourceforge.net/projects/libb64
7 */
8 #ifndef BASE64_DECODE_H
9 #define BASE64_DECODE_H
10 
11 #include "xmlrpcpp/XmlRpcDecl.h"
12 
13 #include <iostream>
14 
15 namespace base64
16 {
17  extern "C"
18  {
19  #include "cdecode.h"
20  }
21 
23  {
26 
27  decoder(int buffersize_in = 512)
28  : _buffersize(buffersize_in)
29  {
30  base64_init_decodestate(&_state);
31  }
32 
33  int decode(char value_in)
34  {
35  return base64_decode_value(value_in);
36  }
37 
38  int decode(const char* code_in, const int length_in, char* plaintext_out)
39  {
40  return base64_decode_block(code_in, length_in, plaintext_out, &_state);
41  }
42 
43  void decode(std::istream& istream_in, std::ostream& ostream_in)
44  {
45  base64_init_decodestate(&_state);
46  //
47  const int N = _buffersize;
48  char* code = new char[N];
49  char* plaintext = new char[N];
50  int codelength;
51  int plainlength;
52 
53  do
54  {
55  istream_in.read((char*)code, N);
56  codelength = istream_in.gcount();
57  plainlength = decode(code, codelength, plaintext);
58  ostream_in.write((const char*)plaintext, plainlength);
59  }
60  while (istream_in.good() && codelength > 0);
61  //
62  base64_init_decodestate(&_state);
63 
64  delete [] code;
65  delete [] plaintext;
66  }
67  };
68 
69 } // namespace base64
70 
71 
72 
73 #endif // BASE64_DECODE_H
74 
base64::decoder::_state
base64_decodestate _state
Definition: decode.h:24
base64::decoder::decode
int decode(const char *code_in, const int length_in, char *plaintext_out)
Definition: decode.h:38
base64::decoder::decoder
decoder(int buffersize_in=512)
Definition: decode.h:27
base64::decoder::decode
void decode(std::istream &istream_in, std::ostream &ostream_in)
Definition: decode.h:43
base64_init_decodestate
void base64_init_decodestate(base64_decodestate *state_in)
Definition: cdecode.c:20
XmlRpcDecl.h
base64
Definition: decode.h:15
cdecode.h
base64_decodestate
Definition: cdecode.h:16
base64_decode_value
int base64_decode_value(char value_in)
Definition: cdecode.c:10
base64::decoder::decode
int decode(char value_in)
Definition: decode.h:33
base64_decode_block
int base64_decode_block(const char *code_in, const int length_in, char *plaintext_out, base64_decodestate *state_in)
Definition: cdecode.c:26
XMLRPCPP_DECL
#define XMLRPCPP_DECL
Definition: XmlRpcDecl.h:52
base64::decoder
Definition: decode.h:22
base64::decoder::_buffersize
int _buffersize
Definition: decode.h:25


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix, Dirk Thomas , Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:32