libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
Base64.h
Go to the documentation of this file.
1 /*
2  base64.cpp and base64.h
3 
4  Copyright (C) 2004-2008 RenĂ© Nyffenegger
5 
6  This source code is provided 'as-is', without any express or implied
7  warranty. In no event will the author be held liable for any damages
8  arising from the use of this software.
9 
10  Permission is granted to anyone to use this software for any purpose,
11  including commercial applications, and to alter it and redistribute it
12  freely, subject to the following restrictions:
13 
14  1. The origin of this source code must not be misrepresented; you must not
15  claim that you wrote the original source code. If you use this source code
16  in a product, an acknowledgment in the product documentation would be
17  appreciated but is not required.
18 
19  2. Altered source versions must be plainly marked as such, and must not be
20  misrepresented as being the original source code.
21 
22  3. This notice may not be removed or altered from any source distribution.
23 
24  RenĂ© Nyffenegger rene.nyffenegger@adp-gmbh.ch
25 
26 */
27 
28 #ifndef BASE64_H_
29 #define BASE64_H_
30 
31 #include <string>
32 #include <vector>
33 
34 namespace BaseLib {
35 
36 class Base64 {
37  public:
38  //For backwards compatibility
39  ~Base64() {}
40 
47  template<typename DataIn>
48  static void encode(const DataIn &in, std::string &out);
49 
57  template<typename DataIn>
58  static std::string encode(const DataIn &in);
59 
66  template<typename DataOut>
67  static void decode(const std::string &in, DataOut &out);
68 
75  template<typename DataOut>
76  static DataOut decode(const std::string &in);
77  private:
78  static const std::string base64_chars;
79 
80  Base64() {}
81 
88  static inline bool isBase64(unsigned char c) {
89  return (isalnum(c) || (c == '+') || (c == '/'));
90  }
91 };
92 
93 }
94 #endif
~Base64()
Definition: Base64.h:39
static void encode(const DataIn &in, std::string &out)
Encodes a string to Base64.
Definition: Base64.cpp:37
Definition: BaseLib.cpp:34
static void decode(const std::string &in, DataOut &out)
Decodes a Base64 encoded string.
Definition: Base64.cpp:139
Definition: Base64.h:36