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/scanner.cc
|
||||||
tensorflow/core/lib/strings/str_util.cc
|
tensorflow/core/lib/strings/str_util.cc
|
||||||
tensorflow/core/lib/strings/strcat.cc
|
tensorflow/core/lib/strings/strcat.cc
|
||||||
tensorflow/core/lib/strings/stringprintf.cc
|
|
||||||
tensorflow/core/lib/wav/wav_io.cc
|
tensorflow/core/lib/wav/wav_io.cc
|
||||||
tensorflow/core/platform/cpu_info.cc
|
tensorflow/core/platform/cpu_info.cc
|
||||||
tensorflow/core/platform/default/logging.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.cc
|
||||||
tensorflow/core/platform/protobuf_util.cc
|
tensorflow/core/platform/protobuf_util.cc
|
||||||
tensorflow/core/platform/setround.cc
|
tensorflow/core/platform/setround.cc
|
||||||
|
tensorflow/core/platform/stringprintf.cc
|
||||||
tensorflow/core/platform/tensor_coding.cc
|
tensorflow/core/platform/tensor_coding.cc
|
||||||
tensorflow/core/platform/tracing.cc
|
tensorflow/core/platform/tracing.cc
|
||||||
tensorflow/tools/proto_text/gen_proto_text_functions.cc
|
tensorflow/tools/proto_text/gen_proto_text_functions.cc
|
||||||
|
@ -768,6 +768,7 @@ cc_library(
|
|||||||
deps = [
|
deps = [
|
||||||
":lib_internal",
|
":lib_internal",
|
||||||
"//tensorflow/core/platform:stringpiece",
|
"//tensorflow/core/platform:stringpiece",
|
||||||
|
"//tensorflow/core/platform:stringprintf",
|
||||||
"@com_google_absl//absl/container:inlined_vector",
|
"@com_google_absl//absl/container:inlined_vector",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/types:optional",
|
"@com_google_absl//absl/types:optional",
|
||||||
@ -2497,6 +2498,7 @@ cc_library(
|
|||||||
"//tensorflow/core/lib/bfloat16",
|
"//tensorflow/core/lib/bfloat16",
|
||||||
"//tensorflow/core/platform:abi",
|
"//tensorflow/core/platform:abi",
|
||||||
"//tensorflow/core/platform:cpu_info",
|
"//tensorflow/core/platform:cpu_info",
|
||||||
|
"//tensorflow/core/platform:stringprintf",
|
||||||
"//tensorflow/core/platform/default/build_config:platformlib",
|
"//tensorflow/core/platform/default/build_config:platformlib",
|
||||||
"@snappy",
|
"@snappy",
|
||||||
"@zlib_archive//:zlib",
|
"@zlib_archive//:zlib",
|
||||||
@ -3802,7 +3804,6 @@ tf_cc_tests(
|
|||||||
"lib/strings/scanner_test.cc",
|
"lib/strings/scanner_test.cc",
|
||||||
"lib/strings/str_util_test.cc",
|
"lib/strings/str_util_test.cc",
|
||||||
"lib/strings/strcat_test.cc",
|
"lib/strings/strcat_test.cc",
|
||||||
"lib/strings/stringprintf_test.cc",
|
|
||||||
"lib/wav/wav_io_test.cc",
|
"lib/wav/wav_io_test.cc",
|
||||||
"//tensorflow/core/platform:fingerprint_test.cc",
|
"//tensorflow/core/platform:fingerprint_test.cc",
|
||||||
"//tensorflow/core/platform:integral_types_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:profile_utils/cpu_utils_test.cc",
|
||||||
"//tensorflow/core/platform:stacktrace_handler_test.cc",
|
"//tensorflow/core/platform:stacktrace_handler_test.cc",
|
||||||
"//tensorflow/core/platform:stringpiece_test.cc",
|
"//tensorflow/core/platform:stringpiece_test.cc",
|
||||||
|
"//tensorflow/core/platform:stringprintf_test.cc",
|
||||||
"//tensorflow/core/platform:subprocess_test.cc",
|
"//tensorflow/core/platform:subprocess_test.cc",
|
||||||
"//tensorflow/core/platform:vmodule_benchmark_test.cc",
|
"//tensorflow/core/platform:vmodule_benchmark_test.cc",
|
||||||
],
|
],
|
||||||
@ -3825,6 +3827,7 @@ tf_cc_tests(
|
|||||||
":test",
|
":test",
|
||||||
":test_main",
|
":test_main",
|
||||||
"//tensorflow/core/platform:stringpiece",
|
"//tensorflow/core/platform:stringpiece",
|
||||||
|
"//tensorflow/core/platform:stringprintf",
|
||||||
"//third_party/eigen3",
|
"//third_party/eigen3",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/synchronization",
|
"@com_google_absl//absl/synchronization",
|
||||||
|
@ -23,30 +23,6 @@ limitations under the License.
|
|||||||
#ifndef TENSORFLOW_CORE_LIB_STRINGS_STRINGPRINTF_H_
|
#ifndef TENSORFLOW_CORE_LIB_STRINGS_STRINGPRINTF_H_
|
||||||
#define TENSORFLOW_CORE_LIB_STRINGS_STRINGPRINTF_H_
|
#define TENSORFLOW_CORE_LIB_STRINGS_STRINGPRINTF_H_
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include "tensorflow/core/platform/stringprintf.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_LIB_STRINGS_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(
|
cc_library(
|
||||||
name = "tstring",
|
name = "tstring",
|
||||||
hdrs = ["tstring.h"],
|
hdrs = ["tstring.h"],
|
||||||
@ -218,6 +228,7 @@ filegroup(
|
|||||||
"cpu_info.cc",
|
"cpu_info.cc",
|
||||||
"platform_strings.cc",
|
"platform_strings.cc",
|
||||||
"protobuf.cc",
|
"protobuf.cc",
|
||||||
|
"stringprintf.cc",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
visibility = ["//tensorflow/core:__pkg__"],
|
visibility = ["//tensorflow/core:__pkg__"],
|
||||||
@ -277,6 +288,7 @@ filegroup(
|
|||||||
"gif.h",
|
"gif.h",
|
||||||
"jpeg.h",
|
"jpeg.h",
|
||||||
"png.h",
|
"png.h",
|
||||||
|
"stringprintf.h",
|
||||||
"**/cuda.h",
|
"**/cuda.h",
|
||||||
"**/rocm.h",
|
"**/rocm.h",
|
||||||
"**/stream_executor.h",
|
"**/stream_executor.h",
|
||||||
@ -306,6 +318,7 @@ filegroup(
|
|||||||
"cpu_info.cc",
|
"cpu_info.cc",
|
||||||
"platform_strings.cc",
|
"platform_strings.cc",
|
||||||
"protobuf.cc",
|
"protobuf.cc",
|
||||||
|
"stringprintf.cc",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
visibility = ["//tensorflow/core:__pkg__"],
|
visibility = ["//tensorflow/core:__pkg__"],
|
||||||
|
@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
|
|
||||||
#include "tensorflow/core/lib/strings/stringprintf.h"
|
#include "tensorflow/core/platform/stringprintf.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h> // For va_list and related operations
|
#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.
|
limitations under the License.
|
||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
|
|
||||||
#include "tensorflow/core/lib/strings/stringprintf.h"
|
#include "tensorflow/core/platform/stringprintf.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user