Qualify uses of std::string

PiperOrigin-RevId: 324247205
Change-Id: Ie5e2164261078620060ebccb74eab2297b639a23
This commit is contained in:
A. Unique TensorFlower 2020-07-31 11:24:39 -07:00 committed by TensorFlower Gardener
parent 1267e76078
commit a452e69984
7 changed files with 95 additions and 87 deletions

View File

@ -22,7 +22,7 @@ limitations under the License.
namespace tensorflow { namespace tensorflow {
namespace port { namespace port {
string MaybeAbiDemangle(const char* name); std::string MaybeAbiDemangle(const char* name);
} // namespace port } // namespace port
} // namespace tensorflow } // namespace tensorflow

View File

@ -108,7 +108,7 @@ class Env {
/// The ownership of the returned RandomAccessFile is passed to the caller /// The ownership of the returned RandomAccessFile is passed to the caller
/// and the object should be deleted when is not used. The file object /// and the object should be deleted when is not used. The file object
/// shouldn't live longer than the Env object. /// shouldn't live longer than the Env object.
Status NewRandomAccessFile(const string& fname, Status NewRandomAccessFile(const std::string& fname,
std::unique_ptr<RandomAccessFile>* result); std::unique_ptr<RandomAccessFile>* result);
/// \brief Creates an object that writes to a new file with the specified /// \brief Creates an object that writes to a new file with the specified
@ -124,7 +124,7 @@ class Env {
/// The ownership of the returned WritableFile is passed to the caller /// The ownership of the returned WritableFile is passed to the caller
/// and the object should be deleted when is not used. The file object /// and the object should be deleted when is not used. The file object
/// shouldn't live longer than the Env object. /// shouldn't live longer than the Env object.
Status NewWritableFile(const string& fname, Status NewWritableFile(const std::string& fname,
std::unique_ptr<WritableFile>* result); std::unique_ptr<WritableFile>* result);
/// \brief Creates an object that either appends to an existing file, or /// \brief Creates an object that either appends to an existing file, or
@ -139,7 +139,7 @@ class Env {
/// The ownership of the returned WritableFile is passed to the caller /// The ownership of the returned WritableFile is passed to the caller
/// and the object should be deleted when is not used. The file object /// and the object should be deleted when is not used. The file object
/// shouldn't live longer than the Env object. /// shouldn't live longer than the Env object.
Status NewAppendableFile(const string& fname, Status NewAppendableFile(const std::string& fname,
std::unique_ptr<WritableFile>* result); std::unique_ptr<WritableFile>* result);
/// \brief Creates a readonly region of memory with the file context. /// \brief Creates a readonly region of memory with the file context.
@ -154,10 +154,10 @@ class Env {
/// and the object should be deleted when is not used. The memory region /// and the object should be deleted when is not used. The memory region
/// object shouldn't live longer than the Env object. /// object shouldn't live longer than the Env object.
Status NewReadOnlyMemoryRegionFromFile( Status NewReadOnlyMemoryRegionFromFile(
const string& fname, std::unique_ptr<ReadOnlyMemoryRegion>* result); const std::string& fname, std::unique_ptr<ReadOnlyMemoryRegion>* result);
/// Returns OK if the named path exists and NOT_FOUND otherwise. /// Returns OK if the named path exists and NOT_FOUND otherwise.
Status FileExists(const string& fname); Status FileExists(const std::string& fname);
/// Returns true if all the listed files exist, false otherwise. /// Returns true if all the listed files exist, false otherwise.
/// if status is not null, populate the vector with a detailed status /// if status is not null, populate the vector with a detailed status
@ -169,7 +169,7 @@ class Env {
/// directory. The names are relative to "dir". /// directory. The names are relative to "dir".
/// ///
/// Original contents of *results are dropped. /// Original contents of *results are dropped.
Status GetChildren(const string& dir, std::vector<string>* result); Status GetChildren(const std::string& dir, std::vector<string>* result);
/// \brief Returns true if the path matches the given pattern. The wildcards /// \brief Returns true if the path matches the given pattern. The wildcards
/// allowed in pattern are described in FileSystem::GetMatchingPaths. /// allowed in pattern are described in FileSystem::GetMatchingPaths.
@ -180,11 +180,11 @@ class Env {
/// that pattern. *results is cleared. /// that pattern. *results is cleared.
/// ///
/// More details about `pattern` in FileSystem::GetMatchingPaths. /// More details about `pattern` in FileSystem::GetMatchingPaths.
virtual Status GetMatchingPaths(const string& pattern, virtual Status GetMatchingPaths(const std::string& pattern,
std::vector<string>* results); std::vector<string>* results);
/// Deletes the named file. /// Deletes the named file.
Status DeleteFile(const string& fname); Status DeleteFile(const std::string& fname);
/// \brief Deletes the specified directory and all subdirectories and files /// \brief Deletes the specified directory and all subdirectories and files
/// underneath it. This is accomplished by traversing the directory tree /// underneath it. This is accomplished by traversing the directory tree
@ -210,7 +210,7 @@ class Env {
/// * PERMISSION_DENIED - dirname or some descendant is not writable /// * PERMISSION_DENIED - dirname or some descendant is not writable
/// * UNIMPLEMENTED - Some underlying functions (like Delete) are not /// * UNIMPLEMENTED - Some underlying functions (like Delete) are not
/// implemented /// implemented
Status DeleteRecursively(const string& dirname, int64* undeleted_files, Status DeleteRecursively(const std::string& dirname, int64* undeleted_files,
int64* undeleted_dirs); int64* undeleted_dirs);
/// \brief Creates the specified directory and all the necessary /// \brief Creates the specified directory and all the necessary
@ -218,19 +218,19 @@ class Env {
/// * OK - successfully created the directory and sub directories, even if /// * OK - successfully created the directory and sub directories, even if
/// they were already created. /// they were already created.
/// * PERMISSION_DENIED - dirname or some subdirectory is not writable. /// * PERMISSION_DENIED - dirname or some subdirectory is not writable.
Status RecursivelyCreateDir(const string& dirname); Status RecursivelyCreateDir(const std::string& dirname);
/// \brief Creates the specified directory. Typical return codes /// \brief Creates the specified directory. Typical return codes
/// * OK - successfully created the directory. /// * OK - successfully created the directory.
/// * ALREADY_EXISTS - directory already exists. /// * ALREADY_EXISTS - directory already exists.
/// * PERMISSION_DENIED - dirname is not writable. /// * PERMISSION_DENIED - dirname is not writable.
Status CreateDir(const string& dirname); Status CreateDir(const std::string& dirname);
/// Deletes the specified directory. /// Deletes the specified directory.
Status DeleteDir(const string& dirname); Status DeleteDir(const std::string& dirname);
/// Obtains statistics for the given path. /// Obtains statistics for the given path.
Status Stat(const string& fname, FileStatistics* stat); Status Stat(const std::string& fname, FileStatistics* stat);
/// \brief Returns whether the given path is a directory or not. /// \brief Returns whether the given path is a directory or not.
/// Typical return codes (not guaranteed exhaustive): /// Typical return codes (not guaranteed exhaustive):
@ -239,7 +239,7 @@ class Env {
/// * NOT_FOUND - The path entry does not exist. /// * NOT_FOUND - The path entry does not exist.
/// * PERMISSION_DENIED - Insufficient permissions. /// * PERMISSION_DENIED - Insufficient permissions.
/// * UNIMPLEMENTED - The file factory doesn't support directories. /// * UNIMPLEMENTED - The file factory doesn't support directories.
Status IsDirectory(const string& fname); Status IsDirectory(const std::string& fname);
/// \brief Returns whether the given path is on a file system /// \brief Returns whether the given path is on a file system
/// that has atomic move capabilities. This can be used /// that has atomic move capabilities. This can be used
@ -251,17 +251,17 @@ class Env {
/// so has_atomic_move holds the above information. /// so has_atomic_move holds the above information.
/// * UNIMPLEMENTED - The file system of the path hasn't been implemented in /// * UNIMPLEMENTED - The file system of the path hasn't been implemented in
/// TF /// TF
Status HasAtomicMove(const string& path, bool* has_atomic_move); Status HasAtomicMove(const std::string& path, bool* has_atomic_move);
/// Stores the size of `fname` in `*file_size`. /// Stores the size of `fname` in `*file_size`.
Status GetFileSize(const string& fname, uint64* file_size); Status GetFileSize(const std::string& fname, uint64* file_size);
/// \brief Renames file src to target. If target already exists, it will be /// \brief Renames file src to target. If target already exists, it will be
/// replaced. /// replaced.
Status RenameFile(const string& src, const string& target); Status RenameFile(const std::string& src, const std::string& target);
/// \brief Copy the src to target. /// \brief Copy the src to target.
Status CopyFile(const string& src, const string& target); Status CopyFile(const std::string& src, const std::string& target);
/// \brief Returns the absolute path of the current executable. It resolves /// \brief Returns the absolute path of the current executable. It resolves
/// symlinks if there is any. /// symlinks if there is any.
@ -374,7 +374,7 @@ class EnvWrapper : public Env {
/// Returns the target to which this Env forwards all calls /// Returns the target to which this Env forwards all calls
Env* target() const { return target_; } Env* target() const { return target_; }
Status GetFileSystemForFile(const string& fname, Status GetFileSystemForFile(const std::string& fname,
FileSystem** result) override { FileSystem** result) override {
return target_->GetFileSystemForFile(fname, result); return target_->GetFileSystemForFile(fname, result);
} }
@ -383,7 +383,7 @@ class EnvWrapper : public Env {
return target_->GetRegisteredFileSystemSchemes(schemes); return target_->GetRegisteredFileSystemSchemes(schemes);
} }
Status RegisterFileSystem(const string& scheme, Status RegisterFileSystem(const std::string& scheme,
FileSystemRegistry::Factory factory) override { FileSystemRegistry::Factory factory) override {
return target_->RegisterFileSystem(scheme, factory); return target_->RegisterFileSystem(scheme, factory);
} }
@ -468,43 +468,44 @@ struct ThreadOptions {
/// A utility routine: copy contents of `src` in file system `src_fs` /// A utility routine: copy contents of `src` in file system `src_fs`
/// to `target` in file system `target_fs`. /// to `target` in file system `target_fs`.
Status FileSystemCopyFile(FileSystem* src_fs, const string& src, Status FileSystemCopyFile(FileSystem* src_fs, const std::string& src,
FileSystem* target_fs, const string& target); FileSystem* target_fs, const std::string& target);
/// A utility routine: reads contents of named file into `*data` /// A utility routine: reads contents of named file into `*data`
Status ReadFileToString(Env* env, const string& fname, string* data); Status ReadFileToString(Env* env, const std::string& fname, std::string* data);
/// A utility routine: write contents of `data` to file named `fname` /// A utility routine: write contents of `data` to file named `fname`
/// (overwriting existing contents, if any). /// (overwriting existing contents, if any).
Status WriteStringToFile(Env* env, const string& fname, Status WriteStringToFile(Env* env, const std::string& fname,
const StringPiece& data); const StringPiece& data);
/// Write binary representation of "proto" to the named file. /// Write binary representation of "proto" to the named file.
Status WriteBinaryProto(Env* env, const string& fname, Status WriteBinaryProto(Env* env, const std::string& fname,
const protobuf::MessageLite& proto); const protobuf::MessageLite& proto);
/// Reads contents of named file and parse as binary encoded proto data /// Reads contents of named file and parse as binary encoded proto data
/// and store into `*proto`. /// and store into `*proto`.
Status ReadBinaryProto(Env* env, const string& fname, Status ReadBinaryProto(Env* env, const std::string& fname,
protobuf::MessageLite* proto); protobuf::MessageLite* proto);
/// Write the text representation of "proto" to the named file. /// Write the text representation of "proto" to the named file.
Status WriteTextProto(Env* env, const string& fname, Status WriteTextProto(Env* env, const std::string& fname,
const protobuf::Message& proto); const protobuf::Message& proto);
/// Read contents of named file and parse as text encoded proto data /// Read contents of named file and parse as text encoded proto data
/// and store into `*proto`. /// and store into `*proto`.
inline Status ReadTextProto(Env* /* env */, const string& /* fname */, inline Status ReadTextProto(Env* /* env */, const std::string& /* fname */,
protobuf::MessageLite* /* proto */) { protobuf::MessageLite* /* proto */) {
return errors::Unimplemented("Can't parse text protos with protolite."); return errors::Unimplemented("Can't parse text protos with protolite.");
} }
Status ReadTextProto(Env* env, const string& fname, protobuf::Message* proto); Status ReadTextProto(Env* env, const std::string& fname,
protobuf::Message* proto);
/// Read contents of named file and parse as either text or binary encoded proto /// Read contents of named file and parse as either text or binary encoded proto
/// data and store into `*proto`. /// data and store into `*proto`.
Status ReadTextOrBinaryProto(Env* env, const string& fname, Status ReadTextOrBinaryProto(Env* env, const std::string& fname,
protobuf::Message* proto); protobuf::Message* proto);
Status ReadTextOrBinaryProto(Env* env, const string& fname, Status ReadTextOrBinaryProto(Env* env, const std::string& fname,
protobuf::MessageLite* proto); protobuf::MessageLite* proto);
// START_SKIP_DOXYGEN // START_SKIP_DOXYGEN

View File

@ -73,7 +73,7 @@ class FileSystem {
}; };
virtual tensorflow::Status NewRandomAccessFile( virtual tensorflow::Status NewRandomAccessFile(
const string& fname, TransactionToken* token, const std::string& fname, TransactionToken* token,
std::unique_ptr<RandomAccessFile>* result) { std::unique_ptr<RandomAccessFile>* result) {
// We duplicate these methods due to Google internal coding style prevents // We duplicate these methods due to Google internal coding style prevents
// virtual functions with default arguments. See PR #41615. // virtual functions with default arguments. See PR #41615.
@ -98,7 +98,7 @@ class FileSystem {
}; };
virtual tensorflow::Status NewWritableFile( virtual tensorflow::Status NewWritableFile(
const string& fname, TransactionToken* token, const std::string& fname, TransactionToken* token,
std::unique_ptr<WritableFile>* result) { std::unique_ptr<WritableFile>* result) {
return Status::OK(); return Status::OK();
} }
@ -120,7 +120,7 @@ class FileSystem {
}; };
virtual tensorflow::Status NewAppendableFile( virtual tensorflow::Status NewAppendableFile(
const string& fname, TransactionToken* token, const std::string& fname, TransactionToken* token,
std::unique_ptr<WritableFile>* result) { std::unique_ptr<WritableFile>* result) {
return Status::OK(); return Status::OK();
} }
@ -141,7 +141,7 @@ class FileSystem {
} }
virtual tensorflow::Status NewReadOnlyMemoryRegionFromFile( virtual tensorflow::Status NewReadOnlyMemoryRegionFromFile(
const string& fname, TransactionToken* token, const std::string& fname, TransactionToken* token,
std::unique_ptr<ReadOnlyMemoryRegion>* result) { std::unique_ptr<ReadOnlyMemoryRegion>* result) {
return Status::OK(); return Status::OK();
} }
@ -151,7 +151,7 @@ class FileSystem {
return FileExists(fname, nullptr); return FileExists(fname, nullptr);
}; };
virtual tensorflow::Status FileExists(const string& fname, virtual tensorflow::Status FileExists(const std::string& fname,
TransactionToken* token) { TransactionToken* token) {
return Status::OK(); return Status::OK();
} }
@ -170,12 +170,12 @@ class FileSystem {
/// \brief Returns the immediate children in the given directory. /// \brief Returns the immediate children in the given directory.
/// ///
/// The returned paths are relative to 'dir'. /// The returned paths are relative to 'dir'.
virtual tensorflow::Status GetChildren(const string& dir, virtual tensorflow::Status GetChildren(const std::string& dir,
std::vector<string>* result) { std::vector<string>* result) {
return GetChildren(dir, nullptr, result); return GetChildren(dir, nullptr, result);
} }
virtual tensorflow::Status GetChildren(const string& dir, virtual tensorflow::Status GetChildren(const std::string& dir,
TransactionToken* token, TransactionToken* token,
std::vector<string>* result) { std::vector<string>* result) {
return Status::OK(); return Status::OK();
@ -203,12 +203,12 @@ class FileSystem {
/// * OK - no errors /// * OK - no errors
/// * UNIMPLEMENTED - Some underlying functions (like GetChildren) are not /// * UNIMPLEMENTED - Some underlying functions (like GetChildren) are not
/// implemented /// implemented
virtual tensorflow::Status GetMatchingPaths(const string& pattern, virtual tensorflow::Status GetMatchingPaths(const std::string& pattern,
std::vector<string>* results) { std::vector<string>* results) {
return GetMatchingPaths(pattern, nullptr, results); return GetMatchingPaths(pattern, nullptr, results);
} }
virtual tensorflow::Status GetMatchingPaths(const string& pattern, virtual tensorflow::Status GetMatchingPaths(const std::string& pattern,
TransactionToken* token, TransactionToken* token,
std::vector<string>* results) { std::vector<string>* results) {
return Status::OK(); return Status::OK();
@ -226,7 +226,8 @@ class FileSystem {
return Stat(fname, nullptr, stat); return Stat(fname, nullptr, stat);
} }
virtual tensorflow::Status Stat(const string& fname, TransactionToken* token, virtual tensorflow::Status Stat(const std::string& fname,
TransactionToken* token,
FileStatistics* stat) { FileStatistics* stat) {
return Status::OK(); return Status::OK();
} }
@ -236,7 +237,7 @@ class FileSystem {
return DeleteFile(fname, nullptr); return DeleteFile(fname, nullptr);
} }
virtual tensorflow::Status DeleteFile(const string& fname, virtual tensorflow::Status DeleteFile(const std::string& fname,
TransactionToken* token) { TransactionToken* token) {
return Status::OK(); return Status::OK();
} }
@ -250,7 +251,7 @@ class FileSystem {
return CreateDir(dirname, nullptr); return CreateDir(dirname, nullptr);
} }
virtual tensorflow::Status CreateDir(const string& dirname, virtual tensorflow::Status CreateDir(const std::string& dirname,
TransactionToken* token) { TransactionToken* token) {
return Status::OK(); return Status::OK();
} }
@ -265,7 +266,7 @@ class FileSystem {
return RecursivelyCreateDir(dirname, nullptr); return RecursivelyCreateDir(dirname, nullptr);
} }
virtual tensorflow::Status RecursivelyCreateDir(const string& dirname, virtual tensorflow::Status RecursivelyCreateDir(const std::string& dirname,
TransactionToken* token); TransactionToken* token);
/// \brief Deletes the specified directory. /// \brief Deletes the specified directory.
@ -273,7 +274,7 @@ class FileSystem {
return DeleteDir(dirname, nullptr); return DeleteDir(dirname, nullptr);
}; };
virtual tensorflow::Status DeleteDir(const string& dirname, virtual tensorflow::Status DeleteDir(const std::string& dirname,
TransactionToken* token) { TransactionToken* token) {
return Status::OK(); return Status::OK();
} }
@ -302,7 +303,7 @@ class FileSystem {
/// * PERMISSION_DENIED - dirname or some descendant is not writable /// * PERMISSION_DENIED - dirname or some descendant is not writable
/// * UNIMPLEMENTED - Some underlying functions (like Delete) are not /// * UNIMPLEMENTED - Some underlying functions (like Delete) are not
/// implemented /// implemented
virtual tensorflow::Status DeleteRecursively(const string& dirname, virtual tensorflow::Status DeleteRecursively(const std::string& dirname,
int64* undeleted_files, int64* undeleted_files,
int64* undeleted_dirs) { int64* undeleted_dirs) {
return DeleteRecursively(dirname, nullptr, undeleted_files, undeleted_dirs); return DeleteRecursively(dirname, nullptr, undeleted_files, undeleted_dirs);
@ -314,12 +315,12 @@ class FileSystem {
int64* undeleted_dirs); int64* undeleted_dirs);
/// \brief Stores the size of `fname` in `*file_size`. /// \brief Stores the size of `fname` in `*file_size`.
virtual tensorflow::Status GetFileSize(const string& fname, virtual tensorflow::Status GetFileSize(const std::string& fname,
uint64* file_size) { uint64* file_size) {
return GetFileSize(fname, nullptr, file_size); return GetFileSize(fname, nullptr, file_size);
} }
virtual tensorflow::Status GetFileSize(const string& fname, virtual tensorflow::Status GetFileSize(const std::string& fname,
TransactionToken* token, TransactionToken* token,
uint64* file_size) { uint64* file_size) {
return Status::OK(); return Status::OK();
@ -331,7 +332,8 @@ class FileSystem {
return RenameFile(src, target, nullptr); return RenameFile(src, target, nullptr);
} }
virtual tensorflow::Status RenameFile(const string& src, const string& target, virtual tensorflow::Status RenameFile(const std::string& src,
const std::string& target,
TransactionToken* token) { TransactionToken* token) {
return Status::OK(); return Status::OK();
} }
@ -341,7 +343,8 @@ class FileSystem {
return CopyFile(src, target, nullptr); return CopyFile(src, target, nullptr);
} }
virtual tensorflow::Status CopyFile(const string& src, const string& target, virtual tensorflow::Status CopyFile(const std::string& src,
const std::string& target,
TransactionToken* token); TransactionToken* token);
/// \brief Translate an URI to a filename for the FileSystem implementation. /// \brief Translate an URI to a filename for the FileSystem implementation.
@ -366,7 +369,7 @@ class FileSystem {
return IsDirectory(fname, nullptr); return IsDirectory(fname, nullptr);
} }
virtual tensorflow::Status IsDirectory(const string& fname, virtual tensorflow::Status IsDirectory(const std::string& fname,
TransactionToken* token); TransactionToken* token);
/// \brief Returns whether the given path is on a file system /// \brief Returns whether the given path is on a file system
@ -379,7 +382,7 @@ class FileSystem {
/// so has_atomic_move holds the above information. /// so has_atomic_move holds the above information.
/// * UNIMPLEMENTED - The file system of the path hasn't been implemented in /// * UNIMPLEMENTED - The file system of the path hasn't been implemented in
/// TF /// TF
virtual Status HasAtomicMove(const string& path, bool* has_atomic_move); virtual Status HasAtomicMove(const std::string& path, bool* has_atomic_move);
/// \brief Flushes any cached filesystem objects from memory. /// \brief Flushes any cached filesystem objects from memory.
virtual void FlushCaches() { FlushCaches(nullptr); } virtual void FlushCaches() { FlushCaches(nullptr); }
@ -483,7 +486,7 @@ class FileSystem {
} }
/// \brief Adds `path` to transaction in `token` /// \brief Adds `path` to transaction in `token`
virtual tensorflow::Status AddToTransaction(const string& path, virtual tensorflow::Status AddToTransaction(const std::string& path,
TransactionToken* token) { TransactionToken* token) {
return Status::OK(); return Status::OK();
} }
@ -496,13 +499,13 @@ class FileSystem {
/// \brief Get token for `path` or start a new transaction and add `path` to /// \brief Get token for `path` or start a new transaction and add `path` to
/// it. /// it.
virtual tensorflow::Status GetTokenOrStartTransaction( virtual tensorflow::Status GetTokenOrStartTransaction(
const string& path, TransactionToken** token) { const std::string& path, TransactionToken** token) {
token = nullptr; token = nullptr;
return Status::OK(); return Status::OK();
} }
/// \brief Return transaction for `path` or nullptr in `token` /// \brief Return transaction for `path` or nullptr in `token`
virtual tensorflow::Status GetTransactionForPath(const string& path, virtual tensorflow::Status GetTransactionForPath(const std::string& path,
TransactionToken** token) { TransactionToken** token) {
token = nullptr; token = nullptr;
return Status::OK(); return Status::OK();
@ -527,31 +530,31 @@ class FileSystem {
class WrappedFileSystem : public FileSystem { class WrappedFileSystem : public FileSystem {
public: public:
tensorflow::Status NewRandomAccessFile( tensorflow::Status NewRandomAccessFile(
const string& fname, TransactionToken* token, const std::string& fname, TransactionToken* token,
std::unique_ptr<RandomAccessFile>* result) override { std::unique_ptr<RandomAccessFile>* result) override {
return fs_->NewRandomAccessFile(fname, (token ? token : token_), result); return fs_->NewRandomAccessFile(fname, (token ? token : token_), result);
} }
tensorflow::Status NewWritableFile( tensorflow::Status NewWritableFile(
const string& fname, TransactionToken* token, const std::string& fname, TransactionToken* token,
std::unique_ptr<WritableFile>* result) override { std::unique_ptr<WritableFile>* result) override {
return fs_->NewWritableFile(fname, (token ? token : token_), result); return fs_->NewWritableFile(fname, (token ? token : token_), result);
} }
tensorflow::Status NewAppendableFile( tensorflow::Status NewAppendableFile(
const string& fname, TransactionToken* token, const std::string& fname, TransactionToken* token,
std::unique_ptr<WritableFile>* result) override { std::unique_ptr<WritableFile>* result) override {
return fs_->NewAppendableFile(fname, (token ? token : token_), result); return fs_->NewAppendableFile(fname, (token ? token : token_), result);
} }
tensorflow::Status NewReadOnlyMemoryRegionFromFile( tensorflow::Status NewReadOnlyMemoryRegionFromFile(
const string& fname, TransactionToken* token, const std::string& fname, TransactionToken* token,
std::unique_ptr<ReadOnlyMemoryRegion>* result) override { std::unique_ptr<ReadOnlyMemoryRegion>* result) override {
return fs_->NewReadOnlyMemoryRegionFromFile(fname, (token ? token : token_), return fs_->NewReadOnlyMemoryRegionFromFile(fname, (token ? token : token_),
result); result);
} }
tensorflow::Status FileExists(const string& fname, tensorflow::Status FileExists(const std::string& fname,
TransactionToken* token) override { TransactionToken* token) override {
return fs_->FileExists(fname, (token ? token : token_)); return fs_->FileExists(fname, (token ? token : token_));
} }
@ -561,12 +564,13 @@ class WrappedFileSystem : public FileSystem {
return fs_->FilesExist(files, (token ? token : token_), status); return fs_->FilesExist(files, (token ? token : token_), status);
} }
tensorflow::Status GetChildren(const string& dir, TransactionToken* token, tensorflow::Status GetChildren(const std::string& dir,
TransactionToken* token,
std::vector<string>* result) override { std::vector<string>* result) override {
return fs_->GetChildren(dir, (token ? token : token_), result); return fs_->GetChildren(dir, (token ? token : token_), result);
} }
tensorflow::Status GetMatchingPaths(const string& pattern, tensorflow::Status GetMatchingPaths(const std::string& pattern,
TransactionToken* token, TransactionToken* token,
std::vector<string>* results) override { std::vector<string>* results) override {
return fs_->GetMatchingPaths(pattern, (token ? token : token_), results); return fs_->GetMatchingPaths(pattern, (token ? token : token_), results);
@ -576,27 +580,27 @@ class WrappedFileSystem : public FileSystem {
return fs_->Match(filename, pattern); return fs_->Match(filename, pattern);
} }
tensorflow::Status Stat(const string& fname, TransactionToken* token, tensorflow::Status Stat(const std::string& fname, TransactionToken* token,
FileStatistics* stat) override { FileStatistics* stat) override {
return fs_->Stat(fname, (token ? token : token_), stat); return fs_->Stat(fname, (token ? token : token_), stat);
} }
tensorflow::Status DeleteFile(const string& fname, tensorflow::Status DeleteFile(const std::string& fname,
TransactionToken* token) override { TransactionToken* token) override {
return fs_->DeleteFile(fname, (token ? token : token_)); return fs_->DeleteFile(fname, (token ? token : token_));
} }
tensorflow::Status CreateDir(const string& dirname, tensorflow::Status CreateDir(const std::string& dirname,
TransactionToken* token) override { TransactionToken* token) override {
return fs_->CreateDir(dirname, (token ? token : token_)); return fs_->CreateDir(dirname, (token ? token : token_));
} }
tensorflow::Status RecursivelyCreateDir(const string& dirname, tensorflow::Status RecursivelyCreateDir(const std::string& dirname,
TransactionToken* token) override { TransactionToken* token) override {
return fs_->RecursivelyCreateDir(dirname, (token ? token : token_)); return fs_->RecursivelyCreateDir(dirname, (token ? token : token_));
} }
tensorflow::Status DeleteDir(const string& dirname, tensorflow::Status DeleteDir(const std::string& dirname,
TransactionToken* token) override { TransactionToken* token) override {
return fs_->DeleteDir(dirname, (token ? token : token_)); return fs_->DeleteDir(dirname, (token ? token : token_));
} }
@ -609,17 +613,19 @@ class WrappedFileSystem : public FileSystem {
undeleted_files, undeleted_dirs); undeleted_files, undeleted_dirs);
} }
tensorflow::Status GetFileSize(const string& fname, TransactionToken* token, tensorflow::Status GetFileSize(const std::string& fname,
TransactionToken* token,
uint64* file_size) override { uint64* file_size) override {
return fs_->GetFileSize(fname, (token ? token : token_), file_size); return fs_->GetFileSize(fname, (token ? token : token_), file_size);
} }
tensorflow::Status RenameFile(const string& src, const string& target, tensorflow::Status RenameFile(const std::string& src,
const std::string& target,
TransactionToken* token) override { TransactionToken* token) override {
return fs_->RenameFile(src, target, (token ? token : token_)); return fs_->RenameFile(src, target, (token ? token : token_));
} }
tensorflow::Status CopyFile(const string& src, const string& target, tensorflow::Status CopyFile(const std::string& src, const std::string& target,
TransactionToken* token) override { TransactionToken* token) override {
return fs_->CopyFile(src, target, (token ? token : token_)); return fs_->CopyFile(src, target, (token ? token : token_));
} }
@ -628,12 +634,13 @@ class WrappedFileSystem : public FileSystem {
return fs_->TranslateName(name); return fs_->TranslateName(name);
} }
tensorflow::Status IsDirectory(const string& fname, tensorflow::Status IsDirectory(const std::string& fname,
TransactionToken* token) override { TransactionToken* token) override {
return fs_->IsDirectory(fname, (token ? token : token_)); return fs_->IsDirectory(fname, (token ? token : token_));
} }
Status HasAtomicMove(const string& path, bool* has_atomic_move) override { Status HasAtomicMove(const std::string& path,
bool* has_atomic_move) override {
return fs_->HasAtomicMove(path, has_atomic_move); return fs_->HasAtomicMove(path, has_atomic_move);
} }
@ -651,7 +658,7 @@ class WrappedFileSystem : public FileSystem {
return fs_->StartTransaction(token); return fs_->StartTransaction(token);
} }
tensorflow::Status AddToTransaction(const string& path, tensorflow::Status AddToTransaction(const std::string& path,
TransactionToken* token) override { TransactionToken* token) override {
return fs_->AddToTransaction(path, (token ? token : token_)); return fs_->AddToTransaction(path, (token ? token : token_));
} }
@ -660,13 +667,13 @@ class WrappedFileSystem : public FileSystem {
return fs_->EndTransaction(token); return fs_->EndTransaction(token);
} }
tensorflow::Status GetTransactionForPath(const string& path, tensorflow::Status GetTransactionForPath(const std::string& path,
TransactionToken** token) override { TransactionToken** token) override {
return fs_->GetTransactionForPath(path, token); return fs_->GetTransactionForPath(path, token);
} }
tensorflow::Status GetTokenOrStartTransaction( tensorflow::Status GetTokenOrStartTransaction(
const string& path, TransactionToken** token) override { const std::string& path, TransactionToken** token) override {
return fs_->GetTokenOrStartTransaction(path, token); return fs_->GetTokenOrStartTransaction(path, token);
} }

View File

@ -38,7 +38,7 @@ inline uint64 Hash64(const char* data, size_t n) {
inline uint64 Hash64(const char* data) { return Hash64(data, ::strlen(data)); } inline uint64 Hash64(const char* data) { return Hash64(data, ::strlen(data)); }
inline uint64 Hash64(const string& str) { inline uint64 Hash64(const std::string& str) {
return Hash64(str.data(), str.size()); return Hash64(str.data(), str.size());
} }

View File

@ -33,18 +33,18 @@ namespace tensorflow {
namespace strings { namespace strings {
// Return a C++ string // Return a C++ string
extern string Printf(const char* format, ...) extern std::string Printf(const char* format, ...)
// Tell the compiler to do printf format string checking. // Tell the compiler to do printf format string checking.
TF_PRINTF_ATTRIBUTE(1, 2); TF_PRINTF_ATTRIBUTE(1, 2);
// Append result to a supplied string // Append result to a supplied string
extern void Appendf(string* dst, const char* format, ...) extern void Appendf(std::string* dst, const char* format, ...)
// Tell the compiler to do printf format string checking. // Tell the compiler to do printf format string checking.
TF_PRINTF_ATTRIBUTE(2, 3); TF_PRINTF_ATTRIBUTE(2, 3);
// Lower-level routine that takes a va_list and appends to a specified // Lower-level routine that takes a va_list and appends to a specified
// string. All other routines are just convenience wrappers around it. // string. All other routines are just convenience wrappers around it.
extern void Appendv(string* dst, const char* format, va_list ap); extern void Appendv(std::string* dst, const char* format, va_list ap);
} // namespace strings } // namespace strings
} // namespace tensorflow } // namespace tensorflow

View File

@ -53,7 +53,7 @@ namespace testing {
// Return a temporary directory suitable for temporary testing files. // Return a temporary directory suitable for temporary testing files.
// //
// Where possible, consider using Env::LocalTempFilename over this function. // Where possible, consider using Env::LocalTempFilename over this function.
string TmpDir(); std::string TmpDir();
// Returns the path to TensorFlow in the directory containing data // Returns the path to TensorFlow in the directory containing data
// dependencies. // dependencies.
@ -62,7 +62,7 @@ string TmpDir();
// tensorflow/core/platform/resource_loader.h:GetDataDependencyFilepath. That // tensorflow/core/platform/resource_loader.h:GetDataDependencyFilepath. That
// function should do the right thing both within and outside of tests allowing // function should do the right thing both within and outside of tests allowing
// avoiding test specific APIs. // avoiding test specific APIs.
string TensorFlowSrcRoot(); std::string TensorFlowSrcRoot();
// Return a random number generator seed to use in randomized tests. // Return a random number generator seed to use in randomized tests.
// Returns the same value for the lifetime of the process. // Returns the same value for the lifetime of the process.

View File

@ -108,22 +108,22 @@ class ThreadPool {
// operations like I/O the hint should be set to false. // operations like I/O the hint should be set to false.
// //
// REQUIRES: num_threads > 0 // REQUIRES: num_threads > 0
ThreadPool(Env* env, const ThreadOptions& thread_options, const string& name, ThreadPool(Env* env, const ThreadOptions& thread_options,
int num_threads, bool low_latency_hint, const std::string& name, int num_threads, bool low_latency_hint,
Eigen::Allocator* allocator = nullptr); Eigen::Allocator* allocator = nullptr);
// Constructs a pool for low-latency ops that contains "num_threads" threads // Constructs a pool for low-latency ops that contains "num_threads" threads
// with specified "name". env->StartThread() is used to create individual // with specified "name". env->StartThread() is used to create individual
// threads. // threads.
// REQUIRES: num_threads > 0 // REQUIRES: num_threads > 0
ThreadPool(Env* env, const string& name, int num_threads); ThreadPool(Env* env, const std::string& name, int num_threads);
// Constructs a pool for low-latency ops that contains "num_threads" threads // Constructs a pool for low-latency ops that contains "num_threads" threads
// with specified "name". env->StartThread() is used to create individual // with specified "name". env->StartThread() is used to create individual
// threads with the given ThreadOptions. // threads with the given ThreadOptions.
// REQUIRES: num_threads > 0 // REQUIRES: num_threads > 0
ThreadPool(Env* env, const ThreadOptions& thread_options, const string& name, ThreadPool(Env* env, const ThreadOptions& thread_options,
int num_threads); const std::string& name, int num_threads);
// Constructs a pool that wraps around the thread::ThreadPoolInterface // Constructs a pool that wraps around the thread::ThreadPoolInterface
// instance provided by the caller. Caller retains ownership of // instance provided by the caller. Caller retains ownership of