OpenSceneGraph 3.6.5
ConvertBase64
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14/* This file is derived from the libb64 project which itself was released to public domain.
15 * For details, see http://sourceforge.net/projects/libb64. Original code by Chris Venter
16 * c++ wrapper for a base64 encoding and decoding algorithm
17*/
18
19#ifndef OSGDB_CONVERTBASE64_H
20#define OSGDB_CONVERTBASE64_H 1
21
22#include <iostream>
23#include <string>
24#include <vector>
25
26#include <osgDB/Export>
27
28namespace osgDB
29{
30 const int BUFFERSIZE = 8192;
31
32 typedef enum
33 {
36
37 typedef enum
38 {
41
42 typedef struct
43 {
45 char result;
48
50 {
51 state_in->step = step_A;
52 state_in->result = 0;
53 state_in->stepcount = 0;
54 }
55
56
57 typedef struct
58 {
62
64 {
65 state_in->step = step_a;
66 state_in->plainchar = 0;
67 }
68
70 {
71 public:
72 Base64encoder(int buffersize_in = BUFFERSIZE):
73 _buffersize(buffersize_in)
74 {
76 }
77
78 int encode(char value_in);
79
80 int encode(const char* code_in, const int length_in, char* plaintext_out);
81
82 int encode_end(char* plaintext_out);
83
84 void encode(std::istream& istream_in, std::ostream& ostream_in);
85
86 void encode(const char* chars_in, int length_in, std::string& code_out);
87
88 private:
89 base64_encodestate _state;
90 int _buffersize;
91 };
92
94 {
95 public:
96 Base64decoder(int buffersize_in = BUFFERSIZE):
97 _buffersize(buffersize_in)
98 {
100 }
101
102 int decode(char value_in);
103
104 int decode(const char* code_in, const int length_in, char* plaintext_out);
105
106 void decode(std::istream& istream_in, std::ostream& ostream_in);
107
108 // Decode strings, returns one char* of appropriate size
109 // Note that deallocation of char* is up to the caller of this method
110 char* decode(const std::vector<std::string>& str_in, std::vector<unsigned int>& pos_out);
111
112 private:
113 base64_decodestate _state;
114 int _buffersize;
115 };
116
117} // namespace osgDB
118
119#endif // BASE64_DECODE_H
120
The osgDB library provides support for reading and writing scene graphs, providing a plugin framework...
Definition Archive:24
base64_encodestep
Definition ConvertBase64:38
@ step_B
Definition ConvertBase64:39
@ step_A
Definition ConvertBase64:39
@ step_C
Definition ConvertBase64:39
void base64_init_decodestate(base64_decodestate *state_in)
Definition ConvertBase64:63
base64_decodestep
Definition ConvertBase64:33
@ step_d
Definition ConvertBase64:34
@ step_b
Definition ConvertBase64:34
@ step_a
Definition ConvertBase64:34
@ step_c
Definition ConvertBase64:34
void base64_init_encodestate(base64_encodestate *state_in)
Definition ConvertBase64:49
const int BUFFERSIZE
Definition ConvertBase64:30
Definition ConvertBase64:43
int stepcount
Definition ConvertBase64:46
base64_encodestep step
Definition ConvertBase64:44
char result
Definition ConvertBase64:45
Definition ConvertBase64:58
base64_decodestep step
Definition ConvertBase64:59
char plainchar
Definition ConvertBase64:60
void encode(const char *chars_in, int length_in, std::string &code_out)
Base64encoder(int buffersize_in=BUFFERSIZE)
Definition ConvertBase64:72
void encode(std::istream &istream_in, std::ostream &ostream_in)
int encode_end(char *plaintext_out)
int encode(char value_in)
int encode(const char *code_in, const int length_in, char *plaintext_out)
int decode(char value_in)
void decode(std::istream &istream_in, std::ostream &ostream_in)
char * decode(const std::vector< std::string > &str_in, std::vector< unsigned int > &pos_out)
Base64decoder(int buffersize_in=BUFFERSIZE)
Definition ConvertBase64:96
int decode(const char *code_in, const int length_in, char *plaintext_out)
#define OSGDB_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.