Move stringprintf to core/platform
PiperOrigin-RevId: 262429337
This commit is contained in:
parent
115b86b882
commit
d8ea8ddfd2
@ -36,7 +36,6 @@ tensorflow/core/lib/strings/proto_text_util.cc
|
||||
tensorflow/core/lib/strings/scanner.cc
|
||||
tensorflow/core/lib/strings/str_util.cc
|
||||
tensorflow/core/lib/strings/strcat.cc
|
||||
tensorflow/core/lib/strings/stringprintf.cc
|
||||
tensorflow/core/lib/wav/wav_io.cc
|
||||
tensorflow/core/platform/cpu_info.cc
|
||||
tensorflow/core/platform/default/logging.cc
|
||||
@ -56,6 +55,7 @@ tensorflow/core/platform/posix/posix_file_system.cc
|
||||
tensorflow/core/platform/protobuf.cc
|
||||
tensorflow/core/platform/protobuf_util.cc
|
||||
tensorflow/core/platform/setround.cc
|
||||
tensorflow/core/platform/stringprintf.cc
|
||||
tensorflow/core/platform/tensor_coding.cc
|
||||
tensorflow/core/platform/tracing.cc
|
||||
tensorflow/tools/proto_text/gen_proto_text_functions.cc
|
||||
|
@ -768,6 +768,7 @@ cc_library(
|
||||
deps = [
|
||||
":lib_internal",
|
||||
"//tensorflow/core/platform:stringpiece",
|
||||
"//tensorflow/core/platform:stringprintf",
|
||||
"@com_google_absl//absl/container:inlined_vector",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/types:optional",
|
||||
@ -2497,6 +2498,7 @@ cc_library(
|
||||
"//tensorflow/core/lib/bfloat16",
|
||||
"//tensorflow/core/platform:abi",
|
||||
"//tensorflow/core/platform:cpu_info",
|
||||
"//tensorflow/core/platform:stringprintf",
|
||||
"//tensorflow/core/platform/default/build_config:platformlib",
|
||||
"@snappy",
|
||||
"@zlib_archive//:zlib",
|
||||
@ -3802,7 +3804,6 @@ tf_cc_tests(
|
||||
"lib/strings/scanner_test.cc",
|
||||
"lib/strings/str_util_test.cc",
|
||||
"lib/strings/strcat_test.cc",
|
||||
"lib/strings/stringprintf_test.cc",
|
||||
"lib/wav/wav_io_test.cc",
|
||||
"//tensorflow/core/platform:fingerprint_test.cc",
|
||||
"//tensorflow/core/platform:integral_types_test.cc",
|
||||
@ -3813,6 +3814,7 @@ tf_cc_tests(
|
||||
"//tensorflow/core/platform:profile_utils/cpu_utils_test.cc",
|
||||
"//tensorflow/core/platform:stacktrace_handler_test.cc",
|
||||
"//tensorflow/core/platform:stringpiece_test.cc",
|
||||
"//tensorflow/core/platform:stringprintf_test.cc",
|
||||
"//tensorflow/core/platform:subprocess_test.cc",
|
||||
"//tensorflow/core/platform:vmodule_benchmark_test.cc",
|
||||
],
|
||||
@ -3825,6 +3827,7 @@ tf_cc_tests(
|
||||
":test",
|
||||
":test_main",
|
||||
"//tensorflow/core/platform:stringpiece",
|
||||
"//tensorflow/core/platform:stringprintf",
|
||||
"//third_party/eigen3",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/synchronization",
|
||||
|
@ -23,30 +23,6 @@ limitations under the License.
|
||||
#ifndef TENSORFLOW_CORE_LIB_STRINGS_STRINGPRINTF_H_
|
||||
#define TENSORFLOW_CORE_LIB_STRINGS_STRINGPRINTF_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string>
|
||||
|
||||
#include "tensorflow/core/platform/macros.h"
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace strings {
|
||||
|
||||
// Return a C++ string
|
||||
extern string Printf(const char* format, ...)
|
||||
// Tell the compiler to do printf format string checking.
|
||||
TF_PRINTF_ATTRIBUTE(1, 2);
|
||||
|
||||
// Append result to a supplied string
|
||||
extern void Appendf(string* dst, const char* format, ...)
|
||||
// Tell the compiler to do printf format string checking.
|
||||
TF_PRINTF_ATTRIBUTE(2, 3);
|
||||
|
||||
// Lower-level routine that takes a va_list and appends to a specified
|
||||
// string. All other routines are just convenience wrappers around it.
|
||||
extern void Appendv(string* dst, const char* format, va_list ap);
|
||||
|
||||
} // namespace strings
|
||||
} // namespace tensorflow
|
||||
#include "tensorflow/core/platform/stringprintf.h"
|
||||
|
||||
#endif // TENSORFLOW_CORE_LIB_STRINGS_STRINGPRINTF_H_
|
||||
|
@ -168,6 +168,16 @@ cc_library(
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "stringprintf",
|
||||
srcs = ["stringprintf.cc"],
|
||||
hdrs = ["stringprintf.h"],
|
||||
deps = [
|
||||
":macros",
|
||||
":types",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "tstring",
|
||||
hdrs = ["tstring.h"],
|
||||
@ -218,6 +228,7 @@ filegroup(
|
||||
"cpu_info.cc",
|
||||
"platform_strings.cc",
|
||||
"protobuf.cc",
|
||||
"stringprintf.cc",
|
||||
],
|
||||
),
|
||||
visibility = ["//tensorflow/core:__pkg__"],
|
||||
@ -277,6 +288,7 @@ filegroup(
|
||||
"gif.h",
|
||||
"jpeg.h",
|
||||
"png.h",
|
||||
"stringprintf.h",
|
||||
"**/cuda.h",
|
||||
"**/rocm.h",
|
||||
"**/stream_executor.h",
|
||||
@ -306,6 +318,7 @@ filegroup(
|
||||
"cpu_info.cc",
|
||||
"platform_strings.cc",
|
||||
"protobuf.cc",
|
||||
"stringprintf.cc",
|
||||
],
|
||||
),
|
||||
visibility = ["//tensorflow/core:__pkg__"],
|
||||
|
@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#include "tensorflow/core/lib/strings/stringprintf.h"
|
||||
#include "tensorflow/core/platform/stringprintf.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h> // For va_list and related operations
|
52
tensorflow/core/platform/stringprintf.h
Normal file
52
tensorflow/core/platform/stringprintf.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* Copyright 2015 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.
|
||||
==============================================================================*/
|
||||
|
||||
// Printf variants that place their output in a C++ string.
|
||||
//
|
||||
// Usage:
|
||||
// string result = strings::Printf("%d %s\n", 10, "hello");
|
||||
// strings::Appendf(&result, "%d %s\n", 20, "there");
|
||||
|
||||
#ifndef TENSORFLOW_CORE_PLATFORM_STRINGPRINTF_H_
|
||||
#define TENSORFLOW_CORE_PLATFORM_STRINGPRINTF_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "tensorflow/core/platform/macros.h"
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace strings {
|
||||
|
||||
// Return a C++ string
|
||||
extern string Printf(const char* format, ...)
|
||||
// Tell the compiler to do printf format string checking.
|
||||
TF_PRINTF_ATTRIBUTE(1, 2);
|
||||
|
||||
// Append result to a supplied string
|
||||
extern void Appendf(string* dst, const char* format, ...)
|
||||
// Tell the compiler to do printf format string checking.
|
||||
TF_PRINTF_ATTRIBUTE(2, 3);
|
||||
|
||||
// Lower-level routine that takes a va_list and appends to a specified
|
||||
// string. All other routines are just convenience wrappers around it.
|
||||
extern void Appendv(string* dst, const char* format, va_list ap);
|
||||
|
||||
} // namespace strings
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CORE_PLATFORM_STRINGPRINTF_H_
|
@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#include "tensorflow/core/lib/strings/stringprintf.h"
|
||||
#include "tensorflow/core/platform/stringprintf.h"
|
||||
|
||||
#include <string>
|
||||
|
Loading…
Reference in New Issue
Block a user