Skip to content

Commit

Permalink
Added std:: prefix to Windows build and a few files
Browse files Browse the repository at this point in the history
BUG=google#392
TEST=unittest
REF_BUG=71969651
REF_CL=182312682
REF_TIME=2018-01-18T13:37:36+09:00
REF_TIME_RAW=1516250256 +0900
  • Loading branch information
hiroyuki-komatsu committed Jan 18, 2018
1 parent c1baa70 commit 18fa27d
Show file tree
Hide file tree
Showing 151 changed files with 1,082 additions and 1,049 deletions.
2 changes: 1 addition & 1 deletion src/base/android_jni_mock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void MockJNIEnv::TearDownJNIEnv() {
}

void MockJNIEnv::ClearArrayMap() {
for (map<jbyteArray, pair<jsize, jbyte*> >::iterator iter =
for (std::map<jbyteArray, pair<jsize, jbyte*> >::iterator iter =
byte_array_map_.begin();
iter != byte_array_map_.end(); ++iter) {
delete iter->first;
Expand Down
21 changes: 11 additions & 10 deletions src/base/codegen_bytearray_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ class BasicCodeGenByteArrayStreamBuf : public std::streambuf {
<< "_data_wordtype[] = {\n";
output_stream_format_flags_ = output_stream_->flags();
// Set the output format in the form of "0x000012340000ABCD".
output_stream_->setf(ios_base::hex, ios_base::basefield);
output_stream_->setf(ios_base::uppercase);
output_stream_->setf(ios_base::right);
output_stream_->setf(std::ios_base::hex, std::ios_base::basefield);
output_stream_->setf(std::ios_base::uppercase);
output_stream_->setf(std::ios_base::right);
output_stream_format_fill_ = output_stream_->fill('0');
// Put the prefix "0x" by ourselves, otherwise it becomes "0X".
output_stream_->unsetf(ios_base::showbase);
output_stream_->unsetf(std::ios_base::showbase);
word_buffer_ = 0;
#else
*output_stream_ << "const char k" << var_name_base_ << "_data[] =\n";
Expand Down Expand Up @@ -239,8 +239,8 @@ class BasicCodeGenByteArrayStreamBuf : public std::streambuf {
char * const buf = reinterpret_cast<char *>(&word_buffer_);
const size_t kWordSize = sizeof word_buffer_;
while (begin < end) {
size_t output_length = min(static_cast<size_t>(end - begin),
kWordSize - output_count_ % kWordSize);
size_t output_length = std::min(static_cast<size_t>(end - begin),
kWordSize - output_count_ % kWordSize);
for (size_t i = 0; i < output_length; ++i) {
buf[output_count_ % kWordSize + i] = *begin++;
}
Expand Down Expand Up @@ -276,7 +276,8 @@ class BasicCodeGenByteArrayStreamBuf : public std::streambuf {

#ifdef MOZC_CODEGEN_BYTEARRAY_STREAM_USES_WORD_ARRAY
void WriteWordBuffer() {
*output_stream_ << "0x" << setw(2 * sizeof word_buffer_) << word_buffer_;
*output_stream_ << "0x" << std::setw(2 * sizeof word_buffer_)
<< word_buffer_;
word_buffer_ = 0;
}
#endif
Expand All @@ -287,7 +288,7 @@ class BasicCodeGenByteArrayStreamBuf : public std::streambuf {
std::basic_ostream<char> *output_stream_;
codegenstream::StreamOwner own_output_stream_;
#ifdef MOZC_CODEGEN_BYTEARRAY_STREAM_USES_WORD_ARRAY
ios_base::fmtflags output_stream_format_flags_;
std::ios_base::fmtflags output_stream_format_flags_;
char output_stream_format_fill_;
#endif

Expand Down Expand Up @@ -319,7 +320,7 @@ class CodeGenByteArrayOutputStream : public std::ostream {
// A call to |OpenVarDef| must precede any output to the instance.
void OpenVarDef(const string &var_name_base) {
if (!streambuf_.OpenVarDef(var_name_base)) {
this->setstate(ios_base::failbit);
this->setstate(std::ios_base::failbit);
}
}

Expand All @@ -328,7 +329,7 @@ class CodeGenByteArrayOutputStream : public std::ostream {
// unless |OpenVarDef| is called with a different variable name.
void CloseVarDef() {
if (!streambuf_.CloseVarDef()) {
this->setstate(ios_base::failbit);
this->setstate(std::ios_base::failbit);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/base/crash_report_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ google_breakpad::CustomClientInfo* GetCustomInfo() {

// Returns the pipe name of the GoogleCrashHandler.exe or
// GoogleCrashHandler64.exe running as a system user.
wstring GetCrashHandlerPipeName() {
wstring pipe_name = kGoogleCrashHandlerPipePrefix;
std::wstring GetCrashHandlerPipeName() {
std::wstring pipe_name = kGoogleCrashHandlerPipePrefix;
pipe_name.append(kSystemPrincipalSid);
pipe_name.append(kGoogleCrashHandlerPipePostfix);
return pipe_name;
Expand Down Expand Up @@ -269,7 +269,7 @@ bool CrashReportHandler::Initialize(bool check_address) {
FileUtil::CreateDirectory(acrashdump_directory);
}

wstring crashdump_directory;
std::wstring crashdump_directory;
Util::UTF8ToWide(acrashdump_directory, &crashdump_directory);

google_breakpad::ExceptionHandler::FilterCallback filter_callback =
Expand Down
22 changes: 12 additions & 10 deletions src/base/file_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ InputFileStream::InputFileStream()
}

InputFileStream::InputFileStream(const char* filename,
ios_base::openmode mode)
std::ios_base::openmode mode)
: std::istream(nullptr) {
init(&string_buffer_);
InputFileStream::open(filename, mode);
}

void InputFileStream::open(const char* filename, ios_base::openmode mode) {
void InputFileStream::open(const char* filename, std::ios_base::openmode mode) {
string buffer;
const bool ret = PepperFileUtil::ReadBinaryFile(filename, &buffer);
if (ret) {
string_buffer_.sputn(buffer.c_str(), buffer.length());
} else {
setstate(ios_base::failbit);
setstate(std::ios_base::failbit);
}
}

Expand All @@ -76,7 +76,7 @@ OutputFileStream::OutputFileStream()
}

OutputFileStream::OutputFileStream(const char* filename,
ios_base::openmode mode)
std::ios_base::openmode mode)
: ostream(),
write_done_(false) {
init(&string_buffer_);
Expand All @@ -87,7 +87,8 @@ OutputFileStream::~OutputFileStream() {
close();
}

void OutputFileStream::open(const char* filename, ios_base::openmode mode) {
void OutputFileStream::open(const char* filename,
std::ios_base::openmode mode) {
filename_ = filename;
}

Expand All @@ -108,7 +109,7 @@ void OutputFileStream::close() {
namespace {

#ifdef OS_WIN
wstring ToPlatformString(const char* filename) {
std::wstring ToPlatformString(const char* filename) {
// Since Windows uses UTF-16 for internationalized file names, we should
// convert the encoding of the given |filename| from UTF-8 to UTF-16.
// NOTE: To avoid circular dependency, |Util::UTF8ToWide| shouldn't be used
Expand All @@ -127,22 +128,23 @@ string ToPlatformString(const char* filename) {
InputFileStream::InputFileStream() {}

InputFileStream::InputFileStream(const char* filename,
ios_base::openmode mode) {
std::ios_base::openmode mode) {
InputFileStream::open(filename, mode);
}

void InputFileStream::open(const char* filename, ios_base::openmode mode) {
void InputFileStream::open(const char* filename, std::ios_base::openmode mode) {
std::ifstream::open(ToPlatformString(filename), mode);
}

OutputFileStream::OutputFileStream() {}

OutputFileStream::OutputFileStream(const char* filename,
ios_base::openmode mode) {
std::ios_base::openmode mode) {
OutputFileStream::open(filename, mode);
}

void OutputFileStream::open(const char* filename, ios_base::openmode mode) {
void OutputFileStream::open(const char* filename,
std::ios_base::openmode mode) {
std::ofstream::open(ToPlatformString(filename), mode);
}
#endif // MOZC_USE_PEPPER_FILE_IO
Expand Down
18 changes: 10 additions & 8 deletions src/base/file_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class InputFileStream : public std::istream {
public:
InputFileStream();
explicit InputFileStream(const char* filename,
ios_base::openmode mode = ios_base::in);
std::ios_base::openmode mode = std::ios_base::in);
// Opens the file and reads the all data to string_buffer_.
void open(const char* filename, ios_base::openmode mode = ios_base::in);
void open(const char* filename, ios_base::openmode mode = std::ios_base::in);
// Do nothing.
// Note: Error handling after close() is not correctly implemented.
// TODO(horo) Implement error handling correctly.
Expand All @@ -75,10 +75,10 @@ class OutputFileStream : public std::ostream {
public:
OutputFileStream();
explicit OutputFileStream(const char* filename,
ios_base::openmode mode = ios_base::in);
std::ios_base::openmode mode = std::ios_base::in);
~OutputFileStream();
// Sets filename_.
void open(const char* filename, ios_base::openmode mode = ios_base::in);
void open(const char* filename, ios_base::openmode mode = std::ios_base::in);
// Write the data to the file using Pepper FileIO.
// Note: Error handling after close() is not correctly implemented.
// TODO(horo) Implement error handling correctly.
Expand Down Expand Up @@ -107,13 +107,14 @@ class InputFileStream : public std::ifstream {
public:
InputFileStream();
explicit InputFileStream(const char* filename,
ios_base::openmode mode = ios_base::in);
std::ios_base::openmode mode = std::ios_base::in);

// Opens the specified file.
// This function is a wrapper function for the ifstream::open() function
// to change the encoding of the specified file name from UTF-8 to its native
// one before calling the ifstream::open() function.
void open(const char* filename, ios_base::openmode mode = ios_base::in);
void open(const char* filename,
std::ios_base::openmode mode = std::ios_base::in);

// Helper functions to load the entire content of a file into string.
void ReadToString(string *s);
Expand All @@ -127,13 +128,14 @@ class OutputFileStream : public std::ofstream {
public:
OutputFileStream();
explicit OutputFileStream(const char* filename,
ios_base::openmode mode = ios_base::out);
std::ios_base::openmode mode = std::ios_base::out);

// Opens the specified file.
// This function is a wrapper function for the ofstream::open() function
// to change the encoding of the specified file name from UTF-8 to its native
// one before calling the ofstream::open() function.
void open(const char* filename, ios_base::openmode mode = ios_base::out);
void open(const char* filename,
std::ios_base::openmode mode = std::ios_base::out);

private:
virtual void UnusedKeyMethod(); // go/definekeymethod
Expand Down
24 changes: 12 additions & 12 deletions src/base/file_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void StripWritePreventingAttributesIfExists(const string &filename) {
if (!FileUtil::FileExists(filename)) {
return;
}
wstring wide_filename;
std::wstring wide_filename;
Util::UTF8ToWide(filename, &wide_filename);
const DWORD kDropAttributes =
FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY;
Expand All @@ -102,7 +102,7 @@ void StripWritePreventingAttributesIfExists(const string &filename) {

bool FileUtil::CreateDirectory(const string &path) {
#if defined(OS_WIN)
wstring wide;
std::wstring wide;
return (Util::UTF8ToWide(path, &wide) > 0 &&
::CreateDirectoryW(wide.c_str(), nullptr) != 0);
#elif defined(OS_NACL) // OS_WIN
Expand All @@ -114,7 +114,7 @@ bool FileUtil::CreateDirectory(const string &path) {

bool FileUtil::RemoveDirectory(const string &dirname) {
#ifdef OS_WIN
wstring wide;
std::wstring wide;
return (Util::UTF8ToWide(dirname, &wide) > 0 &&
::RemoveDirectoryW(wide.c_str()) != 0);
#elif defined(OS_NACL) // OS_WIN
Expand All @@ -127,7 +127,7 @@ bool FileUtil::RemoveDirectory(const string &dirname) {
bool FileUtil::Unlink(const string &filename) {
#ifdef OS_WIN
StripWritePreventingAttributesIfExists(filename);
wstring wide;
std::wstring wide;
return (Util::UTF8ToWide(filename, &wide) > 0 &&
::DeleteFileW(wide.c_str()) != 0);
#elif defined(MOZC_USE_PEPPER_FILE_IO)
Expand All @@ -139,7 +139,7 @@ bool FileUtil::Unlink(const string &filename) {

bool FileUtil::FileExists(const string &filename) {
#ifdef OS_WIN
wstring wide;
std::wstring wide;
return (Util::UTF8ToWide(filename, &wide) > 0 &&
::GetFileAttributesW(wide.c_str()) != -1);
#elif defined(MOZC_USE_PEPPER_FILE_IO)
Expand All @@ -152,7 +152,7 @@ bool FileUtil::FileExists(const string &filename) {

bool FileUtil::DirectoryExists(const string &dirname) {
#ifdef OS_WIN
wstring wide;
std::wstring wide;
if (Util::UTF8ToWide(dirname, &wide) <= 0) {
return false;
}
Expand All @@ -171,7 +171,7 @@ bool FileUtil::DirectoryExists(const string &dirname) {
#ifdef OS_WIN
namespace {

bool TransactionalMoveFile(const wstring &from, const wstring &to) {
bool TransactionalMoveFile(const std::wstring &from, const std::wstring &to) {
const DWORD kTimeout = 5000; // 5 sec.
ScopedHandle handle(::CreateTransaction(
nullptr, 0, 0, 0, 0, kTimeout, nullptr));
Expand Down Expand Up @@ -229,7 +229,7 @@ bool FileUtil::HideFileWithExtraAttributes(const string &filename,
return false;
}

wstring wfilename;
std::wstring wfilename;
Util::UTF8ToWide(filename, &wfilename);

const DWORD original_attributes = ::GetFileAttributesW(wfilename.c_str());
Expand All @@ -250,7 +250,7 @@ bool FileUtil::CopyFile(const string &from, const string &to) {
}

#ifdef OS_WIN
wstring wto;
std::wstring wto;
Util::UTF8ToWide(to, &wto);
StripWritePreventingAttributesIfExists(to);
#endif // OS_WIN
Expand All @@ -271,7 +271,7 @@ bool FileUtil::CopyFile(const string &from, const string &to) {
ofs.close();

#ifdef OS_WIN
wstring wfrom;
std::wstring wfrom;
Util::UTF8ToWide(from, &wfrom);
::SetFileAttributesW(wto.c_str(), ::GetFileAttributesW(wfrom.c_str()));
#endif // OS_WIN
Expand Down Expand Up @@ -302,7 +302,7 @@ bool FileUtil::IsEqualFile(const string &filename1,

bool FileUtil::AtomicRename(const string &from, const string &to) {
#ifdef OS_WIN
wstring fromw, tow;
std::wstring fromw, tow;
Util::UTF8ToWide(from, &fromw);
Util::UTF8ToWide(to, &tow);

Expand Down Expand Up @@ -385,7 +385,7 @@ string FileUtil::NormalizeDirectorySeparator(const string &path) {
bool FileUtil::GetModificationTime(const string &filename,
FileTimeStamp *modified_at) {
#if defined (OS_WIN)
wstring wide;
std::wstring wide;
if (!Util::UTF8ToWide(filename, &wide)) {
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/base/file_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ TEST_F(FileUtilTest, Unlink) {
FILE_ATTRIBUTE_TEMPORARY,
};

wstring wfilepath;
std::wstring wfilepath;
Util::UTF8ToWide(filepath, &wfilepath);
for (size_t i = 0; i < arraysize(kTestAttributeList); ++i) {
SCOPED_TRACE(Util::StringPrintf("AttributeTest %zd", i));
Expand All @@ -157,7 +157,7 @@ TEST_F(FileUtilTest, HideFile) {

EXPECT_FALSE(FileUtil::HideFile(filename));

wstring wfilename;
std::wstring wfilename;
Util::UTF8ToWide(filename.c_str(), &wfilename);

CreateTestFile(filename, "test data");
Expand Down Expand Up @@ -267,7 +267,7 @@ TEST_F(FileUtilTest, CopyFile) {
CreateTestFile(from, test_label);

const TestData &kData = kTestDataList[i];
wstring wfrom, wto;
std::wstring wfrom, wto;
Util::UTF8ToWide(from.c_str(), &wfrom);
Util::UTF8ToWide(to.c_str(), &wto);
EXPECT_NE(FALSE,
Expand Down Expand Up @@ -356,7 +356,7 @@ TEST_F(FileUtilTest, AtomicRename) {
CreateTestFile(from, test_label);

const TestData &kData = kTestDataList[i];
wstring wfrom, wto;
std::wstring wfrom, wto;
Util::UTF8ToWide(from.c_str(), &wfrom);
Util::UTF8ToWide(to.c_str(), &wto);
EXPECT_NE(FALSE,
Expand Down
Loading

0 comments on commit 18fa27d

Please sign in to comment.