dune-grid
3.0-git
dune
grid
io
file
vtk
b64enc.hh
Go to the documentation of this file.
1
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
// vi: set et ts=4 sw=2 sts=2:
3
4
#ifndef DUNE_GRID_IO_FILE_VTK_B64ENC_HH
5
#define DUNE_GRID_IO_FILE_VTK_B64ENC_HH
6
7
#include <assert.h>
8
9
namespace
Dune
{
10
21
const
char
base64table
[] =
22
{
23
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
24
'N'
,
'O'
,
'P'
,
'Q'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'W'
,
'X'
,
'Y'
,
'Z'
,
25
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'l'
,
'm'
,
26
'n'
,
'o'
,
'p'
,
'q'
,
'r'
,
's'
,
't'
,
'u'
,
'v'
,
'w'
,
'x'
,
'y'
,
'z'
,
27
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'+'
,
'/'
28
};
29
31
struct
b64txt
32
{
33
typedef
unsigned
char
size_type
;
34
size_type
size
;
35
char
txt
[3];
36
int
read
(
const
char
* t,
size_type
s)
37
{
38
size
= s>=3 ? 3 : s;
39
txt
[2] = s>0 ? t[0] : 0;
40
txt
[1] = s>1 ? t[1] : 0;
41
txt
[0] = s>2 ? t[2] : 0;
42
return
size
;
43
}
44
void
put
(
const
char
c)
45
{
46
assert (
size
< 3);
47
txt
[2-
size
++] = c;
48
}
49
};
50
52
struct
b64data
53
{
54
typedef
unsigned
char
size_type
;
55
size_type
size
;
56
unsigned
A
: 6;
57
unsigned
B
: 6;
58
unsigned
C
: 6;
59
unsigned
D
: 6;
60
void
write
(
char
* t)
61
{
62
t[3] =
size
>2 ?
base64table
[
A
] :
'='
;
63
t[2] =
size
>1 ?
base64table
[
B
] :
'='
;
64
t[1] =
size
>0 ?
base64table
[
C
] :
'='
;
65
t[0] =
size
>0 ?
base64table
[
D
] :
'='
;
66
size
= 0;
67
}
68
};
69
71
union
b64chunk
72
{
73
b64txt
txt
;
74
b64data
data
;
75
};
76
79
}
// namespace Dune
80
81
#endif // DUNE_GRID_IO_FILE_VTK_B64ENC_HH
Dune::b64txt
struct with three bytes of text
Definition:
b64enc.hh:31
Dune::b64chunk::txt
b64txt txt
Definition:
b64enc.hh:73
Dune::base64table
const char base64table[]
endoing table
Definition:
b64enc.hh:21
Dune
Include standard header files.
Definition:
agrid.hh:59
Dune::b64data::A
unsigned A
Definition:
b64enc.hh:56
Dune::b64txt::txt
char txt[3]
Definition:
b64enc.hh:35
Dune::b64txt::put
void put(const char c)
Definition:
b64enc.hh:44
Dune::b64data::size
size_type size
Definition:
b64enc.hh:55
Dune::b64data::D
unsigned D
Definition:
b64enc.hh:59
Dune::b64txt::size_type
unsigned char size_type
Definition:
b64enc.hh:33
Dune::b64data::write
void write(char *t)
Definition:
b64enc.hh:60
Dune::b64data::size_type
unsigned char size_type
Definition:
b64enc.hh:54
Dune::b64txt::size
size_type size
Definition:
b64enc.hh:34
Dune::b64txt::read
int read(const char *t, size_type s)
Definition:
b64enc.hh:36
Dune::b64chunk::data
b64data data
Definition:
b64enc.hh:74
Dune::b64data
Definition:
b64enc.hh:52
Dune::b64data::B
unsigned B
Definition:
b64enc.hh:57
Dune::b64chunk
union representing the three byte text as well as the four 6 bit chunks
Definition:
b64enc.hh:71
Dune::b64data::C
unsigned C
Definition:
b64enc.hh:58
Generated by
1.8.16