Move base64 from core/lib/strings to core/platform

PiperOrigin-RevId: 283249015
Change-Id: I7600a1743d9c9680b8d1960cde96a1c75cc2cdcc
This commit is contained in:
Gunhan Gulsoy 2019-12-01 15:53:21 -08:00 committed by TensorFlower Gardener
parent 0a0c4d76e9
commit b82ab06d4b
5 changed files with 72 additions and 44 deletions

View File

@ -14,11 +14,9 @@ package(
cc_library(
name = "base64",
srcs = ["base64.cc"],
hdrs = ["base64.h"],
deps = [
"//tensorflow/core/lib/core:errors",
"//tensorflow/core/lib/core:status",
"//tensorflow/core/platform:base64",
],
)
@ -113,7 +111,6 @@ filegroup(
filegroup(
name = "legacy_lib_strings_all_srcs",
srcs = [
"base64.cc",
"ordered_code.cc",
"proto_serialization.cc",
"proto_text_util.cc",

View File

@ -16,43 +16,6 @@ limitations under the License.
#ifndef TENSORFLOW_CORE_LIB_STRINGS_BASE64_H_
#define TENSORFLOW_CORE_LIB_STRINGS_BASE64_H_
#include <string>
#include "tensorflow/core/lib/core/status.h"
namespace tensorflow {
/// \brief Converts data into web-safe base64 encoding.
///
/// See https://en.wikipedia.org/wiki/Base64
template <typename T>
Status Base64Encode(StringPiece source, bool with_padding, T* encoded);
template <typename T>
Status Base64Encode(StringPiece source,
T* encoded); // with_padding=false.
/// \brief Converts data from web-safe base64 encoding.
///
/// See https://en.wikipedia.org/wiki/Base64
template <typename T>
Status Base64Decode(StringPiece data, T* decoded);
// Explicit instantiations defined in base64.cc.
extern template Status Base64Decode<string>(StringPiece data, string* decoded);
extern template Status Base64Encode<string>(StringPiece source,
string* encoded);
extern template Status Base64Encode<string>(StringPiece source,
bool with_padding, string* encoded);
#ifdef USE_TSTRING
extern template Status Base64Decode<tstring>(StringPiece data,
tstring* decoded);
extern template Status Base64Encode<tstring>(StringPiece source,
tstring* encoded);
extern template Status Base64Encode<tstring>(StringPiece source,
bool with_padding,
tstring* encoded);
#endif // USE_TSTRING
} // namespace tensorflow
#include "tensorflow/core/platform/base64.h"
#endif // TENSORFLOW_CORE_LIB_STRINGS_BASE64_H_

View File

@ -83,6 +83,16 @@ cc_library(
deps = [":types"],
)
cc_library(
name = "base64",
srcs = ["base64.cc"],
hdrs = ["base64.h"],
deps = [
":errors",
":status",
],
)
cc_library(
name = "blocking_counter",
hdrs = ["blocking_counter.h"],

View File

@ -13,11 +13,11 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/core/lib/strings/base64.h"
#include "tensorflow/core/platform/base64.h"
#include <cstring>
#include <memory>
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/platform/errors.h"
namespace tensorflow {
namespace {

View File

@ -0,0 +1,58 @@
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_CORE_PLATFORM_BASE64_H_
#define TENSORFLOW_CORE_PLATFORM_BASE64_H_
#include <string>
#include "tensorflow/core/platform/status.h"
namespace tensorflow {
/// \brief Converts data into web-safe base64 encoding.
///
/// See https://en.wikipedia.org/wiki/Base64
template <typename T>
Status Base64Encode(StringPiece source, bool with_padding, T* encoded);
template <typename T>
Status Base64Encode(StringPiece source,
T* encoded); // with_padding=false.
/// \brief Converts data from web-safe base64 encoding.
///
/// See https://en.wikipedia.org/wiki/Base64
template <typename T>
Status Base64Decode(StringPiece data, T* decoded);
// Explicit instantiations defined in base64.cc.
extern template Status Base64Decode<string>(StringPiece data, string* decoded);
extern template Status Base64Encode<string>(StringPiece source,
string* encoded);
extern template Status Base64Encode<string>(StringPiece source,
bool with_padding, string* encoded);
#ifdef USE_TSTRING
extern template Status Base64Decode<tstring>(StringPiece data,
tstring* decoded);
extern template Status Base64Encode<tstring>(StringPiece source,
tstring* encoded);
extern template Status Base64Encode<tstring>(StringPiece source,
bool with_padding,
tstring* encoded);
#endif // USE_TSTRING
} // namespace tensorflow
#endif // TENSORFLOW_CORE_PLATFORM_BASE64_H_