IBR-DTNSuite  0.10
Base64.h
Go to the documentation of this file.
1 /*
2  * Base64.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef BASE64_H_
23 #define BASE64_H_
24 
25 #include <stdlib.h>
26 #include <stdint.h>
27 
28 namespace ibrcommon
29 {
30  class Base64
31  {
32  public:
33  static const char encodeCharacterTable[];
34  static const char decodeCharacterTable[];
35 
36  static const int EQUAL_CHAR = -2;
37  static const int UNKOWN_CHAR = -1;
38 
39  static int getCharType(int val);
40 
46  static size_t getLength(size_t length);
47 
48  class Group
49  {
50  public:
51  Group();
52  virtual ~Group();
53 
54  void zero();
55  uint8_t get_0() const;
56  uint8_t get_1() const;
57  uint8_t get_2() const;
58 
59  void set_0(uint8_t val);
60  void set_1(uint8_t val);
61  void set_2(uint8_t val);
62 
63  int b64_0() const;
64  int b64_1() const;
65  int b64_2() const;
66  int b64_3() const;
67 
68  void b64_0(int val);
69  void b64_1(int val);
70  void b64_2(int val);
71  void b64_3(int val);
72 
73  private:
74  uint8_t _data[3];
75  };
76  };
77 } /* namespace dtn */
78 #endif /* BASE64_H_ */