1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. |
2 | |
3 | Licensed under the Apache License, Version 2.0 (the "License"); |
4 | you may not use this file except in compliance with the License. |
5 | You may obtain a copy of the License at |
6 | |
7 | http://www.apache.org/licenses/LICENSE-2.0 |
8 | |
9 | Unless required by applicable law or agreed to in writing, software |
10 | distributed under the License is distributed on an "AS IS" BASIS, |
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | See the License for the specific language governing permissions and |
13 | limitations under the License. |
14 | ==============================================================================*/ |
15 | |
16 | #ifndef TENSORFLOW_TSL_PLATFORM_BASE64_H_ |
17 | #define TENSORFLOW_TSL_PLATFORM_BASE64_H_ |
18 | |
19 | #include <string> |
20 | |
21 | #include "tensorflow/tsl/platform/status.h" |
22 | #include "tensorflow/tsl/platform/stringpiece.h" |
23 | |
24 | namespace tsl { |
25 | |
26 | /// \brief Converts data into web-safe base64 encoding. |
27 | /// |
28 | /// See https://en.wikipedia.org/wiki/Base64 |
29 | template <typename T> |
30 | Status Base64Encode(StringPiece source, bool with_padding, T* encoded); |
31 | template <typename T> |
32 | Status Base64Encode(StringPiece source, |
33 | T* encoded); // with_padding=false. |
34 | |
35 | /// \brief Converts data from web-safe base64 encoding. |
36 | /// |
37 | /// See https://en.wikipedia.org/wiki/Base64 |
38 | template <typename T> |
39 | Status Base64Decode(StringPiece data, T* decoded); |
40 | |
41 | // Explicit instantiations defined in base64.cc. |
42 | extern template Status Base64Decode<std::string>(StringPiece data, |
43 | std::string* decoded); |
44 | extern template Status Base64Encode<std::string>(StringPiece source, |
45 | std::string* encoded); |
46 | extern template Status Base64Encode<std::string>(StringPiece source, |
47 | bool with_padding, |
48 | std::string* encoded); |
49 | |
50 | extern template Status Base64Decode<tstring>(StringPiece data, |
51 | tstring* decoded); |
52 | extern template Status Base64Encode<tstring>(StringPiece source, |
53 | tstring* encoded); |
54 | extern template Status Base64Encode<tstring>(StringPiece source, |
55 | bool with_padding, |
56 | tstring* encoded); |
57 | |
58 | } // namespace tsl |
59 | |
60 | #endif // TENSORFLOW_TSL_PLATFORM_BASE64_H_ |
61 | |