ProteoWizard
Base64.hpp
Go to the documentation of this file.
1 //
2 // $Id: Base64.hpp 1195 2009-08-14 22:12:04Z chambm $
3 //
4 //
5 // Original author: Darren Kessner <darren@proteowizard.org>
6 //
7 // Copyright 2005 Louis Warschaw Prostate Cancer Center
8 // Cedars Sinai Medical Center, Los Angeles, California 90048
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 //
22 
23 
24 #ifndef _BASE64_HPP_
25 #define _BASE64_HPP_
26 
28 #include <cstddef> // for size_t
29 
30 
31 namespace pwiz {
32 namespace util {
33 
34 
35 /// Base-64 binary->text encoding
36 /// (maps 3 bytes <-> 4 chars)
37 namespace Base64
38 {
39  /// Returns buffer size required by binary->text conversion.
40  PWIZ_API_DECL size_t binaryToTextSize(size_t byteCount);
41 
42  /// binary -> text conversion
43  /// - Caller must allocate buffer
44  /// - Buffer will not be null-terminated
45  /// - Returns the actual number of bytes written
46  PWIZ_API_DECL size_t binaryToText(const void* from, size_t byteCount, char* to);
47 
48  /// Returns sufficient buffer size for text->binary conversion.
49  PWIZ_API_DECL size_t textToBinarySize(size_t charCount);
50 
51  /// text -> binary conversion
52  /// - Caller must allocate buffer
53  /// - Buffer will not be null-terminated
54  /// - Returns the actual number of bytes written
55  PWIZ_API_DECL size_t textToBinary(const char* from, size_t charCount, void* to);
56 
57 } // namespace Base64
58 
59 
60 } // namespace util
61 } // namespace pwiz
62 
63 
64 #endif // _BASE64_HPP_
65