4593 Replace all occurrences of "NULL" to nullptr in src/google/protobug/stubs
This commit is contained in:
parent
e9a5412afc
commit
526b350199
@ -113,7 +113,7 @@ char* GrowingArrayByteSink::GetBuffer(size_t* nbytes) {
|
||||
ShrinkToFit();
|
||||
char* b = buf_;
|
||||
*nbytes = size_;
|
||||
buf_ = NULL;
|
||||
buf_ = nullptr;
|
||||
size_ = capacity_ = 0;
|
||||
return b;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ inline To down_cast(From* f) { // so we only accept pointers
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)
|
||||
assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only!
|
||||
assert(f == nullptr || dynamic_cast<To>(f) != nullptr); // RTTI: debug mode only!
|
||||
#endif
|
||||
return static_cast<To>(f);
|
||||
}
|
||||
@ -107,7 +107,7 @@ inline To down_cast(From& f) {
|
||||
|
||||
#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)
|
||||
// RTTI: debug mode only!
|
||||
assert(dynamic_cast<ToAsPointer>(&f) != NULL);
|
||||
assert(dynamic_cast<ToAsPointer>(&f) != nullptr);
|
||||
#endif
|
||||
return *static_cast<ToAsPointer>(&f);
|
||||
}
|
||||
|
@ -176,12 +176,12 @@ void NullLogHandler(LogLevel /* level */, const char* /* filename */,
|
||||
static LogHandler* log_handler_ = &DefaultLogHandler;
|
||||
static int log_silencer_count_ = 0;
|
||||
|
||||
static Mutex* log_silencer_count_mutex_ = NULL;
|
||||
static Mutex* log_silencer_count_mutex_ = nullptr;
|
||||
GOOGLE_PROTOBUF_DECLARE_ONCE(log_silencer_count_init_);
|
||||
|
||||
void DeleteLogSilencerCount() {
|
||||
delete log_silencer_count_mutex_;
|
||||
log_silencer_count_mutex_ = NULL;
|
||||
log_silencer_count_mutex_ = nullptr;
|
||||
}
|
||||
void InitLogSilencerCount() {
|
||||
log_silencer_count_mutex_ = new Mutex;
|
||||
@ -282,9 +282,9 @@ void LogFinisher::operator=(LogMessage& other) {
|
||||
LogHandler* SetLogHandler(LogHandler* new_func) {
|
||||
LogHandler* old = internal::log_handler_;
|
||||
if (old == &internal::NullLogHandler) {
|
||||
old = NULL;
|
||||
old = nullptr;
|
||||
}
|
||||
if (new_func == NULL) {
|
||||
if (new_func == nullptr) {
|
||||
internal::log_handler_ = &internal::NullLogHandler;
|
||||
} else {
|
||||
internal::log_handler_ = new_func;
|
||||
|
@ -100,14 +100,14 @@ TEST(LoggingTest, DefaultLogging) {
|
||||
}
|
||||
|
||||
TEST(LoggingTest, NullLogging) {
|
||||
LogHandler* old_handler = SetLogHandler(NULL);
|
||||
LogHandler* old_handler = SetLogHandler(nullptr);
|
||||
|
||||
CaptureTestStderr();
|
||||
GOOGLE_LOG(INFO ) << "A message.";
|
||||
GOOGLE_LOG(WARNING) << "A warning.";
|
||||
GOOGLE_LOG(ERROR ) << "An error.";
|
||||
|
||||
EXPECT_TRUE(SetLogHandler(old_handler) == NULL);
|
||||
EXPECT_TRUE(SetLogHandler(old_handler) == nullptr);
|
||||
|
||||
string text = GetCapturedTestStderr();
|
||||
EXPECT_EQ("", text);
|
||||
@ -179,9 +179,9 @@ class ClosureTest : public testing::Test {
|
||||
virtual void SetUp() {
|
||||
current_instance_ = this;
|
||||
a_ = 0;
|
||||
b_ = NULL;
|
||||
b_ = nullptr;
|
||||
c_.clear();
|
||||
permanent_closure_ = NULL;
|
||||
permanent_closure_ = nullptr;
|
||||
}
|
||||
|
||||
void DeleteClosureInCallback() {
|
||||
@ -196,7 +196,7 @@ class ClosureTest : public testing::Test {
|
||||
static ClosureTest* current_instance_;
|
||||
};
|
||||
|
||||
ClosureTest* ClosureTest::current_instance_ = NULL;
|
||||
ClosureTest* ClosureTest::current_instance_ = nullptr;
|
||||
|
||||
TEST_F(ClosureTest, TestClosureFunction0) {
|
||||
Closure* closure = NewCallback(&SetA123Function);
|
||||
@ -321,7 +321,7 @@ TEST_F(ClosureTest, TestPermanentClosureFunction2) {
|
||||
EXPECT_EQ(789, a_);
|
||||
EXPECT_EQ(cstr, b_);
|
||||
a_ = 0;
|
||||
b_ = NULL;
|
||||
b_ = nullptr;
|
||||
closure->Run();
|
||||
EXPECT_EQ(789, a_);
|
||||
EXPECT_EQ(cstr, b_);
|
||||
@ -338,7 +338,7 @@ TEST_F(ClosureTest, TestPermanentClosureMethod2) {
|
||||
EXPECT_EQ(789, a_);
|
||||
EXPECT_EQ(cstr, b_);
|
||||
a_ = 0;
|
||||
b_ = NULL;
|
||||
b_ = nullptr;
|
||||
closure->Run();
|
||||
EXPECT_EQ(789, a_);
|
||||
EXPECT_EQ(cstr, b_);
|
||||
|
@ -91,7 +91,7 @@ struct CharTraits<wchar_t> {
|
||||
|
||||
template <typename char_type>
|
||||
bool null_or_empty(const char_type* s) {
|
||||
return s == NULL || *s == 0;
|
||||
return s == nullptr || *s == 0;
|
||||
}
|
||||
|
||||
// Returns true if the path starts with a drive letter, e.g. "c:".
|
||||
@ -225,7 +225,7 @@ bool as_windows_path(const char* path, wstring* result) {
|
||||
|
||||
|
||||
if (!is_path_absolute(wpath.c_str())) {
|
||||
int size = ::GetCurrentDirectoryW(0, NULL);
|
||||
int size = ::GetCurrentDirectoryW(0, nullptr);
|
||||
if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
||||
return false;
|
||||
}
|
||||
@ -316,17 +316,17 @@ FILE* fopen(const char* path, const char* mode) {
|
||||
#ifdef SUPPORT_LONGPATHS
|
||||
if (null_or_empty(path)) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
wstring wpath;
|
||||
if (!as_windows_path(path, &wpath)) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
wstring wmode;
|
||||
if (!strings::utf8_to_wcs(mode, &wmode)) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return ::_wfopen(wpath.c_str(), wmode.c_str());
|
||||
#else
|
||||
@ -365,15 +365,15 @@ bool wcs_to_mbs(const WCHAR* s, string* out, bool outUtf8) {
|
||||
BOOL usedDefaultChar = FALSE;
|
||||
SetLastError(0);
|
||||
int size = WideCharToMultiByte(
|
||||
outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, NULL, 0, NULL,
|
||||
outUtf8 ? NULL : &usedDefaultChar);
|
||||
outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, nullptr, 0, nullptr,
|
||||
outUtf8 ? nullptr : &usedDefaultChar);
|
||||
if ((size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
|| usedDefaultChar) {
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<CHAR[]> astr(new CHAR[size]);
|
||||
WideCharToMultiByte(
|
||||
outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, astr.get(), size, NULL, NULL);
|
||||
outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, astr.get(), size, nullptr, nullptr);
|
||||
out->assign(astr.get());
|
||||
return true;
|
||||
}
|
||||
@ -386,7 +386,7 @@ bool mbs_to_wcs(const char* s, wstring* out, bool inUtf8) {
|
||||
|
||||
SetLastError(0);
|
||||
int size =
|
||||
MultiByteToWideChar(inUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, NULL, 0);
|
||||
MultiByteToWideChar(inUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, nullptr, 0);
|
||||
if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
||||
return false;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ void StripTrailingSlashes(string* str) {
|
||||
}
|
||||
|
||||
bool GetEnvVarAsUtf8(const WCHAR* name, string* result) {
|
||||
DWORD size = ::GetEnvironmentVariableW(name, NULL, 0);
|
||||
DWORD size = ::GetEnvironmentVariableW(name, nullptr, 0);
|
||||
if (size > 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND) {
|
||||
std::unique_ptr<WCHAR[]> wcs(new WCHAR[size]);
|
||||
::GetEnvironmentVariableW(name, wcs.get(), size);
|
||||
@ -128,7 +128,7 @@ bool GetEnvVarAsUtf8(const WCHAR* name, string* result) {
|
||||
}
|
||||
|
||||
bool GetCwdAsUtf8(string* result) {
|
||||
DWORD size = ::GetCurrentDirectoryW(0, NULL);
|
||||
DWORD size = ::GetCurrentDirectoryW(0, nullptr);
|
||||
if (size > 0) {
|
||||
std::unique_ptr<WCHAR[]> wcs(new WCHAR[size]);
|
||||
::GetCurrentDirectoryW(size, wcs.get());
|
||||
@ -201,7 +201,7 @@ bool IoWin32Test::CreateAllUnder(wstring path) {
|
||||
if (path.find(L"\\\\?\\") != 0) {
|
||||
path = wstring(L"\\\\?\\") + path;
|
||||
}
|
||||
if (::CreateDirectoryW(path.c_str(), NULL) ||
|
||||
if (::CreateDirectoryW(path.c_str(), nullptr) ||
|
||||
GetLastError() == ERROR_ALREADY_EXISTS ||
|
||||
GetLastError() == ERROR_ACCESS_DENIED) {
|
||||
return true;
|
||||
@ -210,7 +210,7 @@ bool IoWin32Test::CreateAllUnder(wstring path) {
|
||||
size_t pos = path.find_last_of(L'\\');
|
||||
if (pos != wstring::npos) {
|
||||
wstring parent(path, 0, pos);
|
||||
if (CreateAllUnder(parent) && CreateDirectoryW(path.c_str(), NULL)) {
|
||||
if (CreateAllUnder(parent) && CreateDirectoryW(path.c_str(), nullptr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -352,8 +352,8 @@ TEST_F(IoWin32Test, MkdirTestNonAscii) {
|
||||
|
||||
// Create a non-ASCII path.
|
||||
// Ensure that we can create the directory using SetCurrentDirectoryW.
|
||||
EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1").c_str(), NULL));
|
||||
EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1\\" + kUtf16Text).c_str(), NULL));
|
||||
EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1").c_str(), nullptr));
|
||||
EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1\\" + kUtf16Text).c_str(), nullptr));
|
||||
// Ensure that we can create a very similarly named directory using mkdir.
|
||||
// We don't attemp to delete and recreate the same directory, because on
|
||||
// Windows, deleting files and directories seems to be asynchronous.
|
||||
@ -386,7 +386,7 @@ TEST_F(IoWin32Test, ChdirTestNonAscii) {
|
||||
wstring wNonAscii(wtest_tmpdir + L"\\" + kUtf16Text);
|
||||
string nonAscii;
|
||||
EXPECT_TRUE(strings::wcs_to_utf8(wNonAscii.c_str(), &nonAscii));
|
||||
EXPECT_TRUE(CreateDirectoryW(wNonAscii.c_str(), NULL));
|
||||
EXPECT_TRUE(CreateDirectoryW(wNonAscii.c_str(), nullptr));
|
||||
WCHAR cwd[MAX_PATH];
|
||||
EXPECT_TRUE(GetCurrentDirectoryW(MAX_PATH, cwd));
|
||||
// Ensure that we can cd into the path using SetCurrentDirectoryW.
|
||||
@ -400,7 +400,7 @@ TEST_F(IoWin32Test, ChdirTestNonAscii) {
|
||||
}
|
||||
|
||||
TEST_F(IoWin32Test, AsWindowsPathTest) {
|
||||
DWORD size = GetCurrentDirectoryW(0, NULL);
|
||||
DWORD size = GetCurrentDirectoryW(0, nullptr);
|
||||
std::unique_ptr<wchar_t[]> cwd_str(new wchar_t[size]);
|
||||
EXPECT_GT(GetCurrentDirectoryW(size, cwd_str.get()), 0);
|
||||
wstring cwd = wstring(L"\\\\?\\") + cwd_str.get();
|
||||
|
@ -162,7 +162,7 @@ namespace internal {
|
||||
template<typename T>
|
||||
T* CheckNotNull(const char* /* file */, int /* line */,
|
||||
const char* name, T* val) {
|
||||
if (val == NULL) {
|
||||
if (val == nullptr) {
|
||||
GOOGLE_LOG(FATAL) << name;
|
||||
}
|
||||
return val;
|
||||
@ -170,7 +170,7 @@ T* CheckNotNull(const char* /* file */, int /* line */,
|
||||
} // namespace internal
|
||||
#define GOOGLE_CHECK_NOTNULL(A) \
|
||||
::google::protobuf::internal::CheckNotNull(\
|
||||
__FILE__, __LINE__, "'" #A "' must not be NULL", (A))
|
||||
__FILE__, __LINE__, "'" #A "' must not be nullptr", (A))
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
||||
@ -208,7 +208,7 @@ typedef void LogHandler(LogLevel level, const char* filename, int line,
|
||||
// also help end users figure out a problem. If you would prefer that
|
||||
// these messages be sent somewhere other than stderr, call SetLogHandler()
|
||||
// to set your own handler. This returns the old handler. Set the handler
|
||||
// to NULL to ignore log messages (but see also LogSilencer, below).
|
||||
// to nullptr to ignore log messages (but see also LogSilencer, below).
|
||||
//
|
||||
// Obviously, SetLogHandler is not thread-safe. You should only call it
|
||||
// at initialization time, and probably not from library code. If you
|
||||
|
@ -131,7 +131,7 @@ FindWithDefault(const Collection& collection,
|
||||
}
|
||||
|
||||
// Returns a pointer to the const value associated with the given key if it
|
||||
// exists, or NULL otherwise.
|
||||
// exists, or nullptr otherwise.
|
||||
template <class Collection>
|
||||
const typename Collection::value_type::second_type*
|
||||
FindOrNull(const Collection& collection,
|
||||
@ -156,11 +156,11 @@ FindOrNull(Collection& collection, // NOLINT
|
||||
}
|
||||
|
||||
// Returns the pointer value associated with the given key. If none is found,
|
||||
// NULL is returned. The function is designed to be used with a map of keys to
|
||||
// nullptr is returned. The function is designed to be used with a map of keys to
|
||||
// pointers.
|
||||
//
|
||||
// This function does not distinguish between a missing key and a key mapped
|
||||
// to a NULL value.
|
||||
// to nullptr.
|
||||
template <class Collection>
|
||||
typename Collection::value_type::second_type
|
||||
FindPtrOrNull(const Collection& collection,
|
||||
@ -188,7 +188,7 @@ FindPtrOrNull(Collection& collection, // NOLINT
|
||||
}
|
||||
|
||||
// Finds the pointer value associated with the given key in a map whose values
|
||||
// are linked_ptrs. Returns NULL if key is not found.
|
||||
// are linked_ptrs. Returns nullptr if key is not found.
|
||||
template <class Collection>
|
||||
typename Collection::value_type::second_type::element_type*
|
||||
FindLinkedPtrOrNull(const Collection& collection,
|
||||
@ -215,7 +215,7 @@ FindLinkedPtrOrDie(const Collection& collection,
|
||||
}
|
||||
|
||||
// Finds the value associated with the given key and copies it to *value (if not
|
||||
// NULL). Returns false if the key was not found, true otherwise.
|
||||
// nullptr). Returns false if the key was not found, true otherwise.
|
||||
template <class Collection, class Key, class Value>
|
||||
bool FindCopy(const Collection& collection,
|
||||
const Key& key,
|
||||
@ -447,7 +447,7 @@ LookupOrInsertNew(Collection* const collection,
|
||||
std::pair<typename Collection::iterator, bool> ret =
|
||||
collection->insert(typename Collection::value_type(
|
||||
key,
|
||||
static_cast<typename Collection::value_type::second_type>(NULL)));
|
||||
static_cast<typename Collection::value_type::second_type>(nullptr)));
|
||||
if (ret.second) {
|
||||
ret.first->second = new Element();
|
||||
}
|
||||
@ -466,7 +466,7 @@ LookupOrInsertNew(Collection* const collection,
|
||||
std::pair<typename Collection::iterator, bool> ret =
|
||||
collection->insert(typename Collection::value_type(
|
||||
key,
|
||||
static_cast<typename Collection::value_type::second_type>(NULL)));
|
||||
static_cast<typename Collection::value_type::second_type>(nullptr)));
|
||||
if (ret.second) {
|
||||
ret.first->second = new Element(arg);
|
||||
}
|
||||
@ -612,7 +612,7 @@ bool UpdateReturnCopy(Collection* const collection,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Tries to insert the given key-value pair into the collection. Returns NULL if
|
||||
// Tries to insert the given key-value pair into the collection. Returns nullptr if
|
||||
// the insert succeeds. Otherwise, returns a pointer to the existing value.
|
||||
//
|
||||
// This complements UpdateReturnCopy in that it allows to update only after
|
||||
@ -625,7 +625,7 @@ InsertOrReturnExisting(Collection* const collection,
|
||||
const typename Collection::value_type& vt) {
|
||||
std::pair<typename Collection::iterator, bool> ret = collection->insert(vt);
|
||||
if (ret.second) {
|
||||
return NULL; // Inserted, no existing previous value.
|
||||
return nullptr; // Inserted, no existing previous value.
|
||||
} else {
|
||||
return &ret.first->second; // Return address of already existing value.
|
||||
}
|
||||
@ -644,7 +644,7 @@ InsertOrReturnExisting(
|
||||
|
||||
// Erases the collection item identified by the given key, and returns the value
|
||||
// associated with that key. It is assumed that the value (i.e., the
|
||||
// mapped_type) is a pointer. Returns NULL if the key was not found in the
|
||||
// mapped_type) is a pointer. Returns nullptr if the key was not found in the
|
||||
// collection.
|
||||
//
|
||||
// Examples:
|
||||
@ -665,7 +665,7 @@ typename Collection::value_type::second_type EraseKeyReturnValuePtr(
|
||||
const typename Collection::value_type::first_type& key) {
|
||||
typename Collection::iterator it = collection->find(key);
|
||||
if (it == collection->end()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
typename Collection::value_type::second_type v = it->second;
|
||||
collection->erase(it);
|
||||
@ -679,7 +679,7 @@ typename Collection::value_type::second_type EraseKeyReturnValuePtr(
|
||||
template <class MapContainer, class KeyContainer>
|
||||
void InsertKeysFromMap(const MapContainer& map_container,
|
||||
KeyContainer* key_container) {
|
||||
GOOGLE_CHECK(key_container != NULL);
|
||||
GOOGLE_CHECK(key_container != nullptr);
|
||||
for (typename MapContainer::const_iterator it = map_container.begin();
|
||||
it != map_container.end(); ++it) {
|
||||
key_container->insert(it->first);
|
||||
@ -693,7 +693,7 @@ void InsertKeysFromMap(const MapContainer& map_container,
|
||||
template <class MapContainer, class KeyContainer>
|
||||
void AppendKeysFromMap(const MapContainer& map_container,
|
||||
KeyContainer* key_container) {
|
||||
GOOGLE_CHECK(key_container != NULL);
|
||||
GOOGLE_CHECK(key_container != nullptr);
|
||||
for (typename MapContainer::const_iterator it = map_container.begin();
|
||||
it != map_container.end(); ++it) {
|
||||
key_container->push_back(it->first);
|
||||
@ -710,7 +710,7 @@ void AppendKeysFromMap(const MapContainer& map_container,
|
||||
template <class MapContainer, class KeyType>
|
||||
void AppendKeysFromMap(const MapContainer& map_container,
|
||||
std::vector<KeyType>* key_container) {
|
||||
GOOGLE_CHECK(key_container != NULL);
|
||||
GOOGLE_CHECK(key_container != nullptr);
|
||||
// We now have the opportunity to call reserve(). Calling reserve() every
|
||||
// time is a bad idea for some use cases: libstdc++'s implementation of
|
||||
// vector<>::reserve() resizes the vector's backing store to exactly the
|
||||
@ -737,7 +737,7 @@ void AppendKeysFromMap(const MapContainer& map_container,
|
||||
template <class MapContainer, class ValueContainer>
|
||||
void AppendValuesFromMap(const MapContainer& map_container,
|
||||
ValueContainer* value_container) {
|
||||
GOOGLE_CHECK(value_container != NULL);
|
||||
GOOGLE_CHECK(value_container != nullptr);
|
||||
for (typename MapContainer::const_iterator it = map_container.begin();
|
||||
it != map_container.end(); ++it) {
|
||||
value_container->push_back(it->second);
|
||||
@ -754,7 +754,7 @@ void AppendValuesFromMap(const MapContainer& map_container,
|
||||
template <class MapContainer, class ValueType>
|
||||
void AppendValuesFromMap(const MapContainer& map_container,
|
||||
std::vector<ValueType>* value_container) {
|
||||
GOOGLE_CHECK(value_container != NULL);
|
||||
GOOGLE_CHECK(value_container != nullptr);
|
||||
// See AppendKeysFromMap for why this is done.
|
||||
if (value_container->empty()) {
|
||||
value_container->reserve(map_container.size());
|
||||
|
@ -86,12 +86,12 @@ class LIBPROTOBUF_EXPORT MutexLock {
|
||||
typedef MutexLock ReaderMutexLock;
|
||||
typedef MutexLock WriterMutexLock;
|
||||
|
||||
// MutexLockMaybe is like MutexLock, but is a no-op when mu is NULL.
|
||||
// MutexLockMaybe is like MutexLock, but is a no-op when mu is nullptr.
|
||||
class LIBPROTOBUF_EXPORT MutexLockMaybe {
|
||||
public:
|
||||
explicit MutexLockMaybe(Mutex *mu) :
|
||||
mu_(mu) { if (this->mu_ != NULL) { this->mu_->Lock(); } }
|
||||
~MutexLockMaybe() { if (this->mu_ != NULL) { this->mu_->Unlock(); } }
|
||||
mu_(mu) { if (this->mu_ != nullptr) { this->mu_->Lock(); } }
|
||||
~MutexLockMaybe() { if (this->mu_ != nullptr) { this->mu_->Unlock(); } }
|
||||
private:
|
||||
Mutex *const mu_;
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLockMaybe);
|
||||
@ -109,7 +109,7 @@ class ThreadLocalStorage {
|
||||
}
|
||||
T* Get() {
|
||||
T* result = static_cast<T*>(pthread_getspecific(key_));
|
||||
if (result == NULL) {
|
||||
if (result == nullptr) {
|
||||
result = new T();
|
||||
pthread_setspecific(key_, result);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class Singleton {
|
||||
}
|
||||
static void ShutDown() {
|
||||
delete instance_;
|
||||
instance_ = NULL;
|
||||
instance_ = nullptr;
|
||||
}
|
||||
private:
|
||||
static void Init() {
|
||||
@ -59,7 +59,7 @@ template<typename T>
|
||||
ProtobufOnceType Singleton<T>::once_;
|
||||
|
||||
template<typename T>
|
||||
T* Singleton<T>::instance_ = NULL;
|
||||
T* Singleton<T>::instance_ = nullptr;
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
@ -33,7 +33,7 @@
|
||||
// usable value, or an error Status explaining why such a value is
|
||||
// not present. To this end, StatusOr<T> does not allow its Status
|
||||
// value to be Status::OK. Further, StatusOr<T*> does not allow the
|
||||
// contained pointer to be NULL.
|
||||
// contained pointer to be nullptr.
|
||||
//
|
||||
// The primary use-case for StatusOr<T> is as the return value of a
|
||||
// function which may fail.
|
||||
@ -114,15 +114,15 @@ class StatusOr {
|
||||
StatusOr(const Status& status); // NOLINT
|
||||
|
||||
// Construct a new StatusOr with the given value. If T is a plain pointer,
|
||||
// value must not be NULL. After calling this constructor, calls to
|
||||
// value must not be nullptr. After calling this constructor, calls to
|
||||
// ValueOrDie() will succeed, and calls to status() will return OK.
|
||||
//
|
||||
// NOTE: Not explicit - we want to use StatusOr<T> as a return type
|
||||
// so it is convenient and sensible to be able to do 'return T()'
|
||||
// when when the return type is StatusOr<T>.
|
||||
//
|
||||
// REQUIRES: if T is a plain pointer, value != NULL. This requirement is
|
||||
// DCHECKed. In optimized builds, passing a NULL pointer here will have
|
||||
// REQUIRES: if T is a plain pointer, value != nullptr. This requirement is
|
||||
// DCHECKed. In optimized builds, passing a null pointer here will have
|
||||
// the effect of passing PosixErrorSpace::EINVAL as a fallback.
|
||||
StatusOr(const T& value); // NOLINT
|
||||
|
||||
@ -174,13 +174,13 @@ class LIBPROTOBUF_EXPORT StatusOrHelper {
|
||||
|
||||
template<typename T>
|
||||
struct StatusOrHelper::Specialize {
|
||||
// For non-pointer T, a reference can never be NULL.
|
||||
// For non-pointer T, a reference can never be nullptr.
|
||||
static inline bool IsValueNull(const T& t) { return false; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct StatusOrHelper::Specialize<T*> {
|
||||
static inline bool IsValueNull(const T* t) { return t == NULL; }
|
||||
static inline bool IsValueNull(const T* t) { return t == nullptr; }
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
@ -202,7 +202,7 @@ inline StatusOr<T>::StatusOr(const Status& status) {
|
||||
template<typename T>
|
||||
inline StatusOr<T>::StatusOr(const T& value) {
|
||||
if (internal::StatusOrHelper::Specialize<T>::IsValueNull(value)) {
|
||||
status_ = Status(error::INTERNAL, "NULL is not a vaild argument.");
|
||||
status_ = Status(error::INTERNAL, "nullptr is not a vaild argument.");
|
||||
} else {
|
||||
status_ = Status::OK;
|
||||
value_ = value;
|
||||
|
@ -82,7 +82,7 @@ inline void STLStringResizeUninitialized(string* s, size_t new_size) {
|
||||
// already work on all current implementations.
|
||||
inline char* string_as_array(string* str) {
|
||||
// DO NOT USE const_cast<char*>(str->data())! See the unittest for why.
|
||||
return str->empty() ? NULL : &*str->begin();
|
||||
return str->empty() ? nullptr : &*str->begin();
|
||||
}
|
||||
|
||||
// STLDeleteElements() deletes all the elements in an STL container and clears
|
||||
@ -90,7 +90,7 @@ inline char* string_as_array(string* str) {
|
||||
// hash_set, or any other STL container which defines sensible begin(), end(),
|
||||
// and clear() methods.
|
||||
//
|
||||
// If container is NULL, this function is a no-op.
|
||||
// If container is nullptr, this function is a no-op.
|
||||
//
|
||||
// As an alternative to calling STLDeleteElements() directly, consider
|
||||
// ElementDeleter (defined below), which ensures that your container's elements
|
||||
@ -104,7 +104,7 @@ void STLDeleteElements(T *container) {
|
||||
|
||||
// Given an STL container consisting of (key, value) pairs, STLDeleteValues
|
||||
// deletes all the "value" components and clears the container. Does nothing
|
||||
// in the case it's given a NULL pointer.
|
||||
// in the case it's given a null pointer.
|
||||
|
||||
template <class T>
|
||||
void STLDeleteValues(T *v) {
|
||||
|
@ -115,7 +115,7 @@ stringpiece_ssize_type StringPiece::find(char c, size_type pos) const {
|
||||
}
|
||||
const char* result = static_cast<const char*>(
|
||||
memchr(ptr_ + pos, c, length_ - pos));
|
||||
return result != NULL ? result - ptr_ : npos;
|
||||
return result != nullptr ? result - ptr_ : npos;
|
||||
}
|
||||
|
||||
stringpiece_ssize_type StringPiece::rfind(StringPiece s, size_type pos) const {
|
||||
|
@ -76,30 +76,30 @@
|
||||
//
|
||||
// There are several ways to create a null StringPiece:
|
||||
// StringPiece()
|
||||
// StringPiece(NULL)
|
||||
// StringPiece(NULL, 0)
|
||||
// For all of the above, sp.data() == NULL, sp.length() == 0,
|
||||
// StringPiece(nullptr)
|
||||
// StringPiece(nullptr, 0)
|
||||
// For all of the above, sp.data() == nullptr, sp.length() == 0,
|
||||
// and sp.empty() == true. Also, if you create a StringPiece with
|
||||
// a non-NULL pointer then sp.data() != NULL. Once created,
|
||||
// sp.data() will stay either NULL or not-NULL, except if you call
|
||||
// a non-null pointer then sp.data() != nullptr. Once created,
|
||||
// sp.data() will stay either nullptr or not-nullptr, except if you call
|
||||
// sp.clear() or sp.set().
|
||||
//
|
||||
// Thus, you can use StringPiece(NULL) to signal an out-of-band value
|
||||
// Thus, you can use StringPiece(nullptr) to signal an out-of-band value
|
||||
// that is different from other StringPiece values. This is similar
|
||||
// to the way that const char* p1 = NULL; is different from
|
||||
// to the way that const char* p1 = nullptr; is different from
|
||||
// const char* p2 = "";.
|
||||
//
|
||||
// There are many ways to create an empty StringPiece:
|
||||
// StringPiece()
|
||||
// StringPiece(NULL)
|
||||
// StringPiece(NULL, 0)
|
||||
// StringPiece(nullptr)
|
||||
// StringPiece(nullptr, 0)
|
||||
// StringPiece("")
|
||||
// StringPiece("", 0)
|
||||
// StringPiece("abcdef", 0)
|
||||
// StringPiece("abcdef"+6, 0)
|
||||
// For all of the above, sp.length() will be 0 and sp.empty() will be true.
|
||||
// For some empty StringPiece values, sp.data() will be NULL.
|
||||
// For some empty StringPiece values, sp.data() will not be NULL.
|
||||
// For some empty StringPiece values, sp.data() will be nullptr.
|
||||
// For some empty StringPiece values, sp.data() will not be nullptr.
|
||||
//
|
||||
// Be careful not to confuse: null StringPiece and empty StringPiece.
|
||||
// The set of empty StringPieces properly includes the set of null StringPieces.
|
||||
@ -109,20 +109,20 @@
|
||||
// All empty StringPiece values compare equal to each other.
|
||||
// Even a null StringPieces compares equal to a non-null empty StringPiece:
|
||||
// StringPiece() == StringPiece("", 0)
|
||||
// StringPiece(NULL) == StringPiece("abc", 0)
|
||||
// StringPiece(NULL, 0) == StringPiece("abcdef"+6, 0)
|
||||
// StringPiece(nullptr) == StringPiece("abc", 0)
|
||||
// StringPiece(nullptr, 0) == StringPiece("abcdef"+6, 0)
|
||||
//
|
||||
// Look carefully at this example:
|
||||
// StringPiece("") == NULL
|
||||
// StringPiece("") == nullptr
|
||||
// True or false? TRUE, because StringPiece::operator== converts
|
||||
// the right-hand side from NULL to StringPiece(NULL),
|
||||
// the right-hand side from nullptr to StringPiece(nullptr),
|
||||
// and then compares two zero-length spans of characters.
|
||||
// However, we are working to make this example produce a compile error.
|
||||
//
|
||||
// Suppose you want to write:
|
||||
// bool TestWhat?(StringPiece sp) { return sp == NULL; } // BAD
|
||||
// bool TestWhat?(StringPiece sp) { return sp == nullptr; } // BAD
|
||||
// Do not do that. Write one of these instead:
|
||||
// bool TestNull(StringPiece sp) { return sp.data() == NULL; }
|
||||
// bool TestNull(StringPiece sp) { return sp.data() == nullptr; }
|
||||
// bool TestEmpty(StringPiece sp) { return sp.empty(); }
|
||||
// The intent of TestWhat? is unclear. Did you mean TestNull or TestEmpty?
|
||||
// Right now, TestWhat? behaves likes TestEmpty.
|
||||
@ -207,11 +207,11 @@ class LIBPROTOBUF_EXPORT StringPiece {
|
||||
//
|
||||
// Style guide exception granted:
|
||||
// http://goto/style-guide-exception-20978288
|
||||
StringPiece() : ptr_(NULL), length_(0) {}
|
||||
StringPiece() : ptr_(nullptr), length_(0) {}
|
||||
|
||||
StringPiece(const char* str) // NOLINT(runtime/explicit)
|
||||
: ptr_(str), length_(0) {
|
||||
if (str != NULL) {
|
||||
if (str != nullptr) {
|
||||
length_ = CheckedSsizeTFromSizeT(strlen(str));
|
||||
}
|
||||
}
|
||||
@ -248,7 +248,7 @@ class LIBPROTOBUF_EXPORT StringPiece {
|
||||
bool empty() const { return length_ == 0; }
|
||||
|
||||
void clear() {
|
||||
ptr_ = NULL;
|
||||
ptr_ = nullptr;
|
||||
length_ = 0;
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ class LIBPROTOBUF_EXPORT StringPiece {
|
||||
|
||||
void set(const char* str) {
|
||||
ptr_ = str;
|
||||
if (str != NULL)
|
||||
if (str != nullptr)
|
||||
length_ = CheckedSsizeTFromSizeT(strlen(str));
|
||||
else
|
||||
length_ = 0;
|
||||
@ -309,7 +309,7 @@ class LIBPROTOBUF_EXPORT StringPiece {
|
||||
// for a StringPiece be called "as_string()". We also leave the
|
||||
// "as_string()" method defined here for existing code.
|
||||
string ToString() const {
|
||||
if (ptr_ == NULL) return string();
|
||||
if (ptr_ == nullptr) return string();
|
||||
return string(data(), static_cast<size_type>(size()));
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ TEST(StringPiece, Ctor) {
|
||||
{
|
||||
// Null.
|
||||
StringPiece s10;
|
||||
EXPECT_TRUE(s10.data() == NULL);
|
||||
EXPECT_TRUE(s10.data() == nullptr);
|
||||
EXPECT_EQ(0, s10.length());
|
||||
}
|
||||
|
||||
@ -148,8 +148,8 @@ TEST(StringPiece, ComparisonOperators) {
|
||||
EXPECT_EQ(result, StringPiece((x)).compare(StringPiece((y))) op 0)
|
||||
|
||||
COMPARE(true, ==, "", "");
|
||||
COMPARE(true, ==, "", NULL);
|
||||
COMPARE(true, ==, NULL, "");
|
||||
COMPARE(true, ==, "", nullptr);
|
||||
COMPARE(true, ==, nullptr, "");
|
||||
COMPARE(true, ==, "a", "a");
|
||||
COMPARE(true, ==, "aa", "aa");
|
||||
COMPARE(false, ==, "a", "");
|
||||
@ -253,7 +253,7 @@ TEST(StringPiece, STL1) {
|
||||
|
||||
EXPECT_EQ(*d.data(), 'f');
|
||||
EXPECT_EQ(d.data()[5], 'r');
|
||||
EXPECT_TRUE(e.data() == NULL);
|
||||
EXPECT_TRUE(e.data() == nullptr);
|
||||
|
||||
EXPECT_EQ(*a.begin(), 'a');
|
||||
EXPECT_EQ(*(b.begin() + 2), 'c');
|
||||
@ -312,7 +312,7 @@ TEST(StringPiece, STL2) {
|
||||
d.clear();
|
||||
EXPECT_EQ(d.size(), 0);
|
||||
EXPECT_TRUE(d.empty());
|
||||
EXPECT_TRUE(d.data() == NULL);
|
||||
EXPECT_TRUE(d.data() == nullptr);
|
||||
EXPECT_TRUE(d.begin() == d.end());
|
||||
|
||||
EXPECT_EQ(StringPiece::npos, string::npos);
|
||||
@ -707,17 +707,17 @@ TEST(StringPiece, Contains) {
|
||||
EXPECT_TRUE(!a.contains(d));
|
||||
}
|
||||
|
||||
TEST(StringPiece, NULLInput) {
|
||||
TEST(StringPiece, NullInput) {
|
||||
// we used to crash here, but now we don't.
|
||||
StringPiece s(NULL);
|
||||
EXPECT_EQ(s.data(), (const char*)NULL);
|
||||
StringPiece s(nullptr);
|
||||
EXPECT_EQ(s.data(), (const char*)nullptr);
|
||||
EXPECT_EQ(s.size(), 0);
|
||||
|
||||
s.set(NULL);
|
||||
EXPECT_EQ(s.data(), (const char*)NULL);
|
||||
s.set(nullptr);
|
||||
EXPECT_EQ(s.data(), (const char*)nullptr);
|
||||
EXPECT_EQ(s.size(), 0);
|
||||
|
||||
// .ToString() on a StringPiece with NULL should produce the empty string.
|
||||
// .ToString() on a StringPiece with nullptr should produce the empty string.
|
||||
EXPECT_EQ("", s.ToString());
|
||||
EXPECT_EQ("", s.as_string());
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void StringAppendV(string* dst, const char* format, va_list ap) {
|
||||
// Error or MSVC running out of space. MSVC 8.0 and higher
|
||||
// can be asked about space needed with the special idiom below:
|
||||
va_copy(backup_ap, ap);
|
||||
result = vsnprintf(NULL, 0, format, backup_ap);
|
||||
result = vsnprintf(nullptr, 0, format, backup_ap);
|
||||
va_end(backup_ap);
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ TEST(StringPrintfTest, Multibyte) {
|
||||
// out of memory while trying to determine destination buffer size.
|
||||
// see b/4194543.
|
||||
|
||||
char* old_locale = setlocale(LC_CTYPE, NULL);
|
||||
char* old_locale = setlocale(LC_CTYPE, nullptr);
|
||||
// Push locale with multibyte mode
|
||||
setlocale(LC_CTYPE, "en_US.utf8");
|
||||
|
||||
@ -120,7 +120,7 @@ TEST(StringPrintfTest, Multibyte) {
|
||||
|
||||
TEST(StringPrintfTest, NoMultibyte) {
|
||||
// No multibyte handling, but the string contains funny chars.
|
||||
char* old_locale = setlocale(LC_CTYPE, NULL);
|
||||
char* old_locale = setlocale(LC_CTYPE, nullptr);
|
||||
setlocale(LC_CTYPE, "POSIX");
|
||||
string value = StringPrintf("%.*s", 3, "\375\067s");
|
||||
setlocale(LC_CTYPE, old_locale);
|
||||
|
@ -87,7 +87,7 @@ void StripString(string* s, const char* remove, char replacewith) {
|
||||
const char * str_start = s->c_str();
|
||||
const char * str = str_start;
|
||||
for (str = strpbrk(str, remove);
|
||||
str != NULL;
|
||||
str != nullptr;
|
||||
str = strpbrk(str + 1, remove)) {
|
||||
(*s)[str - str_start] = replacewith;
|
||||
}
|
||||
@ -102,7 +102,7 @@ void ReplaceCharacters(string *s, const char *remove, char replacewith) {
|
||||
const char *str_start = s->c_str();
|
||||
const char *str = str_start;
|
||||
for (str = strpbrk(str, remove);
|
||||
str != NULL;
|
||||
str != nullptr;
|
||||
str = strpbrk(str + 1, remove)) {
|
||||
(*s)[str - str_start] = replacewith;
|
||||
}
|
||||
@ -280,7 +280,7 @@ static void JoinStringsIterator(const ITERATOR& start,
|
||||
const ITERATOR& end,
|
||||
const char* delim,
|
||||
string* result) {
|
||||
GOOGLE_CHECK(result != NULL);
|
||||
GOOGLE_CHECK(result != nullptr);
|
||||
result->clear();
|
||||
int delim_length = strlen(delim);
|
||||
|
||||
@ -318,7 +318,7 @@ void JoinStrings(const std::vector<string>& components,
|
||||
// result is truncated to 8 bits.
|
||||
//
|
||||
// The second call stores its errors in a supplied string vector.
|
||||
// If the string vector pointer is NULL, it reports the errors with LOG().
|
||||
// If the string vector pointer is nullptr, it reports the errors with LOG().
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#define IS_OCTAL_DIGIT(c) (((c) >= '0') && ((c) <= '7'))
|
||||
@ -328,12 +328,12 @@ void JoinStrings(const std::vector<string>& components,
|
||||
#define LOG_STRING(LEVEL, VECTOR) GOOGLE_LOG_IF(LEVEL, false)
|
||||
|
||||
int UnescapeCEscapeSequences(const char* source, char* dest) {
|
||||
return UnescapeCEscapeSequences(source, dest, NULL);
|
||||
return UnescapeCEscapeSequences(source, dest, nullptr);
|
||||
}
|
||||
|
||||
int UnescapeCEscapeSequences(const char* source, char* dest,
|
||||
std::vector<string> *errors) {
|
||||
GOOGLE_DCHECK(errors == NULL) << "Error reporting not implemented.";
|
||||
GOOGLE_DCHECK(errors == nullptr) << "Error reporting not implemented.";
|
||||
|
||||
char* d = dest;
|
||||
const char* p = source;
|
||||
@ -458,13 +458,13 @@ int UnescapeCEscapeSequences(const char* source, char* dest,
|
||||
// to be the same.
|
||||
//
|
||||
// The second call stores its errors in a supplied string vector.
|
||||
// If the string vector pointer is NULL, it reports the errors with LOG().
|
||||
// If the string vector pointer is nullptr, it reports the errors with LOG().
|
||||
//
|
||||
// In the first and second calls, the length of dest is returned. In the
|
||||
// the third call, the new string is returned.
|
||||
// ----------------------------------------------------------------------
|
||||
int UnescapeCEscapeString(const string& src, string* dest) {
|
||||
return UnescapeCEscapeString(src, dest, NULL);
|
||||
return UnescapeCEscapeString(src, dest, nullptr);
|
||||
}
|
||||
|
||||
int UnescapeCEscapeString(const string& src, string* dest,
|
||||
@ -478,7 +478,7 @@ int UnescapeCEscapeString(const string& src, string* dest,
|
||||
|
||||
string UnescapeCEscapeString(const string& src) {
|
||||
std::unique_ptr<char[]> unescaped(new char[src.size() + 1]);
|
||||
int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), NULL);
|
||||
int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), nullptr);
|
||||
return string(unescaped.get(), len);
|
||||
}
|
||||
|
||||
@ -982,7 +982,7 @@ static const char two_ASCII_digits[100][2] = {
|
||||
|
||||
char* FastUInt32ToBufferLeft(uint32 u, char* buffer) {
|
||||
uint32 digits;
|
||||
const char *ASCII_digits = NULL;
|
||||
const char *ASCII_digits = nullptr;
|
||||
// The idea of this implementation is to trim the number of divides to as few
|
||||
// as possible by using multiplication and subtraction rather than mod (%),
|
||||
// and by outputting two digits at a time rather than one.
|
||||
@ -1073,7 +1073,7 @@ char* FastInt32ToBufferLeft(int32 i, char* buffer) {
|
||||
|
||||
char* FastUInt64ToBufferLeft(uint64 u64, char* buffer) {
|
||||
int digits;
|
||||
const char *ASCII_digits = NULL;
|
||||
const char *ASCII_digits = nullptr;
|
||||
|
||||
uint32 u = static_cast<uint32>(u64);
|
||||
if (u == u64) return FastUInt32ToBufferLeft(u, buffer);
|
||||
@ -1231,7 +1231,7 @@ static inline bool IsValidFloatChar(char c) {
|
||||
void DelocalizeRadix(char* buffer) {
|
||||
// Fast check: if the buffer has a normal decimal point, assume no
|
||||
// translation is needed.
|
||||
if (strchr(buffer, '.') != NULL) return;
|
||||
if (strchr(buffer, '.') != nullptr) return;
|
||||
|
||||
// Find the first unknown character.
|
||||
while (IsValidFloatChar(*buffer)) ++buffer;
|
||||
@ -1286,7 +1286,7 @@ char* DoubleToBuffer(double value, char* buffer) {
|
||||
// of a double. This long double may have extra bits that make it compare
|
||||
// unequal to "value" even though it would be exactly equal if it were
|
||||
// truncated to a double.
|
||||
volatile double parsed_value = strtod(buffer, NULL);
|
||||
volatile double parsed_value = strtod(buffer, nullptr);
|
||||
if (parsed_value != value) {
|
||||
int snprintf_result =
|
||||
snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value);
|
||||
@ -1318,7 +1318,7 @@ inline bool CaseEqual(StringPiece s1, StringPiece s2) {
|
||||
}
|
||||
|
||||
bool safe_strtob(StringPiece str, bool* value) {
|
||||
GOOGLE_CHECK(value != NULL) << "NULL output boolean given.";
|
||||
GOOGLE_CHECK(value != nullptr) << "nullptr output boolean given.";
|
||||
if (CaseEqual(str, "true") || CaseEqual(str, "t") ||
|
||||
CaseEqual(str, "yes") || CaseEqual(str, "y") ||
|
||||
CaseEqual(str, "1")) {
|
||||
@ -1619,7 +1619,7 @@ void StrAppend(string *result,
|
||||
int GlobalReplaceSubstring(const string& substring,
|
||||
const string& replacement,
|
||||
string* s) {
|
||||
GOOGLE_CHECK(s != NULL);
|
||||
GOOGLE_CHECK(s != nullptr);
|
||||
if (s->empty() || substring.empty())
|
||||
return 0;
|
||||
string tmp;
|
||||
@ -1969,7 +1969,7 @@ int Base64UnescapeInternal(const char *src_param, int szsrc,
|
||||
// for (i = 0; i < 255; i += 8) {
|
||||
// for (j = i; j < i + 8; j++) {
|
||||
// pos = strchr(Base64, j);
|
||||
// if ((pos == NULL) || (j == 0))
|
||||
// if ((pos == nullptr) || (j == 0))
|
||||
// idx = -1;
|
||||
// else
|
||||
// idx = pos - Base64;
|
||||
|
@ -285,7 +285,7 @@ inline string JoinStrings(const std::vector<string>& components,
|
||||
//
|
||||
// Errors: In the first form of the call, errors are reported with
|
||||
// LOG(ERROR). The same is true for the second form of the call if
|
||||
// the pointer to the string std::vector is NULL; otherwise, error
|
||||
// the pointer to the string std::vector is nullptr; otherwise, error
|
||||
// messages are stored in the std::vector. In either case, the effect on
|
||||
// the dest array is not defined, but rest of the source will be
|
||||
// processed.
|
||||
@ -304,7 +304,7 @@ LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest,
|
||||
// to be the same.
|
||||
//
|
||||
// The second call stores its errors in a supplied string vector.
|
||||
// If the string vector pointer is NULL, it reports the errors with LOG().
|
||||
// If the string vector pointer is nullptr, it reports the errors with LOG().
|
||||
//
|
||||
// In the first and second calls, the length of dest is returned. In the
|
||||
// the third call, the new string is returned.
|
||||
|
@ -50,18 +50,18 @@ namespace {
|
||||
|
||||
TEST(StringUtilityTest, ImmuneToLocales) {
|
||||
// Remember the old locale.
|
||||
char* old_locale_cstr = setlocale(LC_NUMERIC, NULL);
|
||||
ASSERT_TRUE(old_locale_cstr != NULL);
|
||||
char* old_locale_cstr = setlocale(LC_NUMERIC, nullptr);
|
||||
ASSERT_TRUE(old_locale_cstr != nullptr);
|
||||
string old_locale = old_locale_cstr;
|
||||
|
||||
// Set the locale to "C".
|
||||
ASSERT_TRUE(setlocale(LC_NUMERIC, "C") != NULL);
|
||||
ASSERT_TRUE(setlocale(LC_NUMERIC, "C") != nullptr);
|
||||
|
||||
EXPECT_EQ("1.5", SimpleDtoa(1.5));
|
||||
EXPECT_EQ("1.5", SimpleFtoa(1.5));
|
||||
|
||||
if (setlocale(LC_NUMERIC, "es_ES") == NULL &&
|
||||
setlocale(LC_NUMERIC, "es_ES.utf8") == NULL) {
|
||||
if (setlocale(LC_NUMERIC, "es_ES") == nullptr &&
|
||||
setlocale(LC_NUMERIC, "es_ES.utf8") == nullptr) {
|
||||
// Some systems may not have the desired locale available.
|
||||
GOOGLE_LOG(WARNING)
|
||||
<< "Couldn't set locale to es_ES. Skipping this test.";
|
||||
|
@ -44,7 +44,7 @@ using internal::SubstituteArg;
|
||||
// to Substitute().
|
||||
static int CountSubstituteArgs(const SubstituteArg* const* args_array) {
|
||||
int count = 0;
|
||||
while (args_array[count] != NULL && args_array[count]->size() != -1) {
|
||||
while (args_array[count] != nullptr && args_array[count]->size() != -1) {
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
@ -71,7 +71,7 @@ void SubstituteAndAppend(
|
||||
const SubstituteArg& arg6, const SubstituteArg& arg7,
|
||||
const SubstituteArg& arg8, const SubstituteArg& arg9) {
|
||||
const SubstituteArg* const args_array[] = {
|
||||
&arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, NULL
|
||||
&arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, nullptr
|
||||
};
|
||||
|
||||
// Determine total size needed.
|
||||
|
@ -93,7 +93,7 @@ class SubstituteArg {
|
||||
|
||||
// Indicates that no argument was given.
|
||||
inline explicit SubstituteArg()
|
||||
: text_(NULL), size_(-1) {}
|
||||
: text_(nullptr), size_(-1) {}
|
||||
|
||||
// Primitives
|
||||
// We don't overload for signed and unsigned char because if people are
|
||||
|
@ -142,12 +142,12 @@ string FormatNanos(int32 nanos) {
|
||||
|
||||
// Parses an integer from a null-terminated char sequence. The method
|
||||
// consumes at most "width" chars. Returns a pointer after the consumed
|
||||
// integer, or NULL if the data does not start with an integer or the
|
||||
// integer, or nullptr if the data does not start with an integer or the
|
||||
// integer value does not fall in the range of [min_value, max_value].
|
||||
const char* ParseInt(const char* data, int width, int min_value,
|
||||
int max_value, int* result) {
|
||||
if (!ascii_isdigit(*data)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
int value = 0;
|
||||
for (int i = 0; i < width; ++i, ++data) {
|
||||
@ -161,7 +161,7 @@ const char* ParseInt(const char* data, int width, int min_value,
|
||||
*result = value;
|
||||
return data;
|
||||
} else {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ const char* ParseInt(const char* data, int width, int min_value,
|
||||
// "010" will be parsed to 10000000 nanos.
|
||||
const char* ParseNanos(const char* data, int32* nanos) {
|
||||
if (!ascii_isdigit(*data)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
int value = 0;
|
||||
int len = 0;
|
||||
@ -193,15 +193,15 @@ const char* ParseNanos(const char* data, int32* nanos) {
|
||||
const char* ParseTimezoneOffset(const char* data, int64* offset) {
|
||||
// Accept format "HH:MM". E.g., "08:00"
|
||||
int hour;
|
||||
if ((data = ParseInt(data, 2, 0, 23, &hour)) == NULL) {
|
||||
return NULL;
|
||||
if ((data = ParseInt(data, 2, 0, 23, &hour)) == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (*data++ != ':') {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
int minute;
|
||||
if ((data = ParseInt(data, 2, 0, 59, &minute)) == NULL) {
|
||||
return NULL;
|
||||
if ((data = ParseInt(data, 2, 0, 59, &minute)) == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
*offset = (hour * 60 + minute) * 60;
|
||||
return data;
|
||||
@ -264,7 +264,7 @@ bool DateTimeToSeconds(const DateTime& time, int64* seconds) {
|
||||
void GetCurrentTime(int64* seconds, int32* nanos) {
|
||||
// TODO(xiaofeng): Improve the accuracy of this implementation (or just
|
||||
// remove this method from protobuf).
|
||||
*seconds = time(NULL);
|
||||
*seconds = time(nullptr);
|
||||
*nanos = 0;
|
||||
}
|
||||
|
||||
@ -290,37 +290,37 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) {
|
||||
// With UTC offset: 2015-05-20T13:29:35.120-08:00
|
||||
|
||||
// Parse year
|
||||
if ((data = ParseInt(data, 4, 1, 9999, &time.year)) == NULL) {
|
||||
if ((data = ParseInt(data, 4, 1, 9999, &time.year)) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
// Expect '-'
|
||||
if (*data++ != '-') return false;
|
||||
// Parse month
|
||||
if ((data = ParseInt(data, 2, 1, 12, &time.month)) == NULL) {
|
||||
if ((data = ParseInt(data, 2, 1, 12, &time.month)) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
// Expect '-'
|
||||
if (*data++ != '-') return false;
|
||||
// Parse day
|
||||
if ((data = ParseInt(data, 2, 1, 31, &time.day)) == NULL) {
|
||||
if ((data = ParseInt(data, 2, 1, 31, &time.day)) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
// Expect 'T'
|
||||
if (*data++ != 'T') return false;
|
||||
// Parse hour
|
||||
if ((data = ParseInt(data, 2, 0, 23, &time.hour)) == NULL) {
|
||||
if ((data = ParseInt(data, 2, 0, 23, &time.hour)) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
// Expect ':'
|
||||
if (*data++ != ':') return false;
|
||||
// Parse minute
|
||||
if ((data = ParseInt(data, 2, 0, 59, &time.minute)) == NULL) {
|
||||
if ((data = ParseInt(data, 2, 0, 59, &time.minute)) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
// Expect ':'
|
||||
if (*data++ != ':') return false;
|
||||
// Parse second
|
||||
if ((data = ParseInt(data, 2, 0, 59, &time.second)) == NULL) {
|
||||
if ((data = ParseInt(data, 2, 0, 59, &time.second)) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (!DateTimeToSeconds(time, seconds)) {
|
||||
@ -330,7 +330,7 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) {
|
||||
if (*data == '.') {
|
||||
++data;
|
||||
// Parse nanoseconds.
|
||||
if ((data = ParseNanos(data, nanos)) == NULL) {
|
||||
if ((data = ParseNanos(data, nanos)) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -342,14 +342,14 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) {
|
||||
} else if (*data == '+') {
|
||||
++data;
|
||||
int64 offset;
|
||||
if ((data = ParseTimezoneOffset(data, &offset)) == NULL) {
|
||||
if ((data = ParseTimezoneOffset(data, &offset)) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
*seconds -= offset;
|
||||
} else if (*data == '-') {
|
||||
++data;
|
||||
int64 offset;
|
||||
if ((data = ParseTimezoneOffset(data, &offset)) == NULL) {
|
||||
if ((data = ParseTimezoneOffset(data, &offset)) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
*seconds += offset;
|
||||
|
Loading…
Reference in New Issue
Block a user