diff options
author | Goraf <22941576+Goraf@users.noreply.github.com> | 2018-02-24 15:32:06 +0100 |
---|---|---|
committer | Goraf <22941576+Goraf@users.noreply.github.com> | 2018-02-24 18:20:46 +0100 |
commit | 1c0172cca4f1e90679321912e20436a7f42f122d (patch) | |
tree | 77a544d2c09332ec176f42ebcf58a40d9c5d2b93 /include/m_string.inl | |
parent | dff565f40105b20b0e8e4dba1f48ccc9b8e7ff44 (diff) |
more nullptr
Diffstat (limited to 'include/m_string.inl')
-rw-r--r-- | include/m_string.inl | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/include/m_string.inl b/include/m_string.inl index 33acc46c64..97b94040b9 100644 --- a/include/m_string.inl +++ b/include/m_string.inl @@ -45,7 +45,7 @@ CMSimpleStringT<BaseType>::CMSimpleStringT(PCXSTR pszSrc) {
int nLength = StringLength(pszSrc);
CMStringData* pData = mirstr_allocate(nLength, sizeof(XCHAR));
- if (pData != NULL) {
+ if (pData != nullptr) {
Attach(pData);
SetLength(nLength);
CopyChars(m_pszData, nLength, pszSrc, nLength);
@@ -56,7 +56,7 @@ template<typename BaseType> CMSimpleStringT<BaseType>::CMSimpleStringT(const XCHAR* pchSrc, int nLength)
{
CMStringData* pData = mirstr_allocate(nLength, sizeof(XCHAR));
- if (pData != NULL) {
+ if (pData != nullptr) {
Attach(pData);
SetLength(nLength);
CopyChars(m_pszData, nLength, pchSrc, nLength);
@@ -165,7 +165,7 @@ void CMSimpleStringT<BaseType>::FreeExtra() if (!pOldData->IsLocked()) { // Don't reallocate a locked buffer that's shrinking
CMStringData* pNewData = mirstr_allocate(nLength, sizeof(XCHAR));
- if (pNewData == NULL) {
+ if (pNewData == nullptr) {
SetLength(nLength);
return;
}
@@ -326,7 +326,7 @@ void __stdcall CMSimpleStringT<BaseType>::CopyCharsOverlapped(XCHAR* pchDest, si template<typename BaseType>
int __stdcall CMSimpleStringT<BaseType>::StringLength(const char* psz)
{
- if (psz == NULL)
+ if (psz == nullptr)
return(0);
return (int(strlen(psz)));
@@ -335,7 +335,7 @@ int __stdcall CMSimpleStringT<BaseType>::StringLength(const char* psz) template<typename BaseType>
int __stdcall CMSimpleStringT<BaseType>::StringLength(const wchar_t* psz)
{
- if (psz == NULL)
+ if (psz == nullptr)
return 0;
return int(wcslen(psz));
@@ -344,7 +344,7 @@ int __stdcall CMSimpleStringT<BaseType>::StringLength(const wchar_t* psz) template<typename BaseType>
int __stdcall CMSimpleStringT<BaseType>::StringLengthN(const char* psz, size_t sizeInXChar)
{
- if (psz == NULL)
+ if (psz == nullptr)
return 0;
return int(strnlen(psz, sizeInXChar));
@@ -353,7 +353,7 @@ int __stdcall CMSimpleStringT<BaseType>::StringLengthN(const char* psz, size_t s template<typename BaseType>
int __stdcall CMSimpleStringT<BaseType>::StringLengthN(const wchar_t* psz, size_t sizeInXChar)
{
- if (psz == NULL)
+ if (psz == nullptr)
return 0;
return int(wcsnlen(psz, sizeInXChar));
@@ -381,7 +381,7 @@ void CMSimpleStringT<BaseType>::Fork(int nLength) CMStringData* pOldData = GetData();
int nOldLength = pOldData->nDataLength;
CMStringData* pNewData = mirstr_allocate(nLength, sizeof(XCHAR));
- if (pNewData != NULL) {
+ if (pNewData != nullptr) {
int nCharsToCopy = ((nOldLength < nLength) ? nOldLength : nLength) + 1; // Copy '\0'
CopyChars(PXSTR(pNewData->data()), nCharsToCopy, PCXSTR(pOldData->data()), nCharsToCopy);
pNewData->nDataLength = nOldLength;
@@ -435,7 +435,7 @@ void CMSimpleStringT<BaseType>::Reallocate(int nLength) return;
CMStringData* pNewData = mirstr_realloc(pOldData, nLength, sizeof(XCHAR));
- if (pNewData != NULL)
+ if (pNewData != nullptr)
Attach(pNewData);
}
@@ -449,7 +449,7 @@ void CMSimpleStringT<BaseType>::SetLength(int nLength) template<typename BaseType>
CMStringData* __stdcall CMSimpleStringT<BaseType>::CloneData(CMStringData* pData)
{
- CMStringData* pNewData = NULL;
+ CMStringData* pNewData = nullptr;
if (!pData->IsLocked()) {
pNewData = pData;
@@ -588,7 +588,7 @@ template< typename BaseType, class StringTraits > CMStringT<BaseType, StringTraits>& CMStringT<BaseType, StringTraits>::operator=(PCYSTR pszSrc)
{
// nDestLength is in XCHARs
- int nDestLength = (pszSrc != NULL) ? StringTraits::GetBaseTypeLength(pszSrc) : 0;
+ int nDestLength = (pszSrc != nullptr) ? StringTraits::GetBaseTypeLength(pszSrc) : 0;
if (nDestLength > 0) {
PXSTR pszBuffer = this->GetBuffer(nDestLength);
StringTraits::ConvertToBaseType(pszBuffer, nDestLength, pszSrc);
@@ -836,7 +836,7 @@ int CMStringT<BaseType, StringTraits>::Replace(PCXSTR pszOld, PCXSTR pszNew) PCXSTR pszEnd = pszStart + this->GetLength();
while (pszStart < pszEnd) {
PCXSTR pszTarget;
- while ((pszTarget = StringTraits::StringFindString(pszStart, pszOld)) != NULL) {
+ while ((pszTarget = StringTraits::StringFindString(pszStart, pszOld)) != nullptr) {
nCount++;
pszStart = pszTarget + nSourceLen;
}
@@ -859,7 +859,7 @@ int CMStringT<BaseType, StringTraits>::Replace(PCXSTR pszOld, PCXSTR pszNew) // loop again to actually do the work
while (pszStart < pszEnd) {
PXSTR pszTarget;
- while ((pszTarget = StringTraits::StringFindString(pszStart, pszOld)) != NULL) {
+ while ((pszTarget = StringTraits::StringFindString(pszStart, pszOld)) != nullptr) {
int nBalance = nOldLength - int(pszTarget - pszBuffer + nSourceLen);
memmove_s(pszTarget + nReplacementLen, nBalance*sizeof(XCHAR),
pszTarget + nSourceLen, nBalance*sizeof(XCHAR));
@@ -913,7 +913,7 @@ int CMStringT<BaseType, StringTraits>::Remove(XCHAR chRemove) template< typename BaseType, class StringTraits >
CMStringT<BaseType, StringTraits> CMStringT<BaseType, StringTraits>::Tokenize(PCXSTR pszTokens, int& iStart) const
{
- if ((pszTokens == NULL) || (*pszTokens == (XCHAR)0)) {
+ if ((pszTokens == nullptr) || (*pszTokens == (XCHAR)0)) {
if (iStart < this->GetLength())
return CMStringT(this->GetString() + iStart);
}
@@ -957,7 +957,7 @@ int CMStringT<BaseType, StringTraits>::Find(XCHAR ch, int iStart = 0) const PCXSTR psz = StringTraits::StringFindChar(this->GetString() + iStart, ch);
// return -1 if not found and index otherwise
- return (psz == NULL) ? -1 : int(psz - this->GetString());
+ return (psz == nullptr) ? -1 : int(psz - this->GetString());
}
// look for a specific sub-string
@@ -967,7 +967,7 @@ template< typename BaseType, class StringTraits > int CMStringT<BaseType, StringTraits>::Find(PCXSTR pszSub, int iStart = 0) const
{
// iStart is in XCHARs
- if (pszSub == NULL)
+ if (pszSub == nullptr)
return -1;
// nLength is in XCHARs
@@ -979,7 +979,7 @@ int CMStringT<BaseType, StringTraits>::Find(PCXSTR pszSub, int iStart = 0) const PCXSTR psz = StringTraits::StringFindString(this->GetString() + iStart, pszSub);
// return -1 for not found, distance from beginning otherwise
- return (psz == NULL) ? -1 : int(psz - this->GetString());
+ return (psz == nullptr) ? -1 : int(psz - this->GetString());
}
// Find the first occurrence of any of the characters in string 'pszCharSet'
@@ -987,7 +987,7 @@ template< typename BaseType, class StringTraits > int CMStringT<BaseType, StringTraits>::FindOneOf(PCXSTR pszCharSet) const
{
PCXSTR psz = StringTraits::StringScanSet(this->GetString(), pszCharSet);
- return (psz == NULL) ? -1 : int(psz - this->GetString());
+ return (psz == nullptr) ? -1 : int(psz - this->GetString());
}
// Find the last occurrence of character 'ch'
@@ -998,7 +998,7 @@ int CMStringT<BaseType, StringTraits>::ReverseFind(XCHAR ch) const PCXSTR psz = StringTraits::StringFindCharRev(this->GetString(), ch);
// return -1 if not found, distance from beginning otherwise
- return (psz == NULL) ? -1 : int(psz - this->GetString());
+ return (psz == nullptr) ? -1 : int(psz - this->GetString());
}
// manipulation
@@ -1049,19 +1049,19 @@ CMStringT<BaseType, StringTraits>& CMStringT<BaseType, StringTraits>::TrimRight( // at beginning (DBCS aware)
PCXSTR psz = this->GetString();
- PCXSTR pszLast = NULL;
+ PCXSTR pszLast = nullptr;
while (*psz != 0) {
if (StringTraits::IsSpace(*psz)) {
- if (pszLast == NULL)
+ if (pszLast == nullptr)
pszLast = psz;
}
- else pszLast = NULL;
+ else pszLast = nullptr;
psz = StringTraits::CharNext(psz);
}
- if (pszLast != NULL) {
+ if (pszLast != nullptr) {
// truncate at trailing space start
int iLast = int(pszLast - this->GetString());
@@ -1126,19 +1126,19 @@ CMStringT<BaseType, StringTraits>& CMStringT<BaseType, StringTraits>::TrimRight( // by starting at beginning (DBCS aware)
PCXSTR psz = this->GetString();
- PCXSTR pszLast = NULL;
+ PCXSTR pszLast = nullptr;
while (*psz != 0) {
if (*psz == chTarget) {
- if (pszLast == NULL)
+ if (pszLast == nullptr)
pszLast = psz;
}
- else pszLast = NULL;
+ else pszLast = nullptr;
psz = StringTraits::CharNext(psz);
}
- if (pszLast != NULL) {
+ if (pszLast != nullptr) {
// truncate at left-most matching character
int iLast = int(pszLast - this->GetString());
this->Truncate(iLast);
@@ -1152,7 +1152,7 @@ template< typename BaseType, class StringTraits > CMStringT<BaseType, StringTraits>& CMStringT<BaseType, StringTraits>::TrimRight(PCXSTR pszTargets)
{
// if we're not trimming anything, we're not doing any work
- if ((pszTargets == NULL) || (*pszTargets == 0)) {
+ if ((pszTargets == nullptr) || (*pszTargets == 0)) {
return *this;
}
@@ -1160,21 +1160,21 @@ CMStringT<BaseType, StringTraits>& CMStringT<BaseType, StringTraits>::TrimRight( // by starting at beginning (DBCS aware)
PCXSTR psz = this->GetString();
- PCXSTR pszLast = NULL;
+ PCXSTR pszLast = nullptr;
while (*psz != 0) {
- if (StringTraits::StringFindChar(pszTargets, *psz) != NULL) {
- if (pszLast == NULL) {
+ if (StringTraits::StringFindChar(pszTargets, *psz) != nullptr) {
+ if (pszLast == nullptr) {
pszLast = psz;
}
}
else {
- pszLast = NULL;
+ pszLast = nullptr;
}
psz = StringTraits::CharNext(psz);
}
- if (pszLast != NULL) {
+ if (pszLast != nullptr) {
// truncate at left-most matching character
int iLast = int(pszLast - this->GetString());
this->Truncate(iLast);
@@ -1213,12 +1213,12 @@ template< typename BaseType, class StringTraits > CMStringT<BaseType, StringTraits>& CMStringT<BaseType, StringTraits>::TrimLeft(PCXSTR pszTargets)
{
// if we're not trimming anything, we're not doing any work
- if ((pszTargets == NULL) || (*pszTargets == 0)) {
+ if ((pszTargets == nullptr) || (*pszTargets == 0)) {
return *this;
}
PCXSTR psz = this->GetString();
- while ((*psz != 0) && (StringTraits::StringFindChar(pszTargets, *psz) != NULL)) {
+ while ((*psz != 0) && (StringTraits::StringFindChar(pszTargets, *psz) != nullptr)) {
psz = StringTraits::CharNext(psz);
}
@@ -1380,7 +1380,7 @@ typename CMStringT<BaseType, StringTraits>::PCXSTR CMStringT<BaseType, StringTra template< typename BaseType, class StringTraits >
BOOL CMStringT<BaseType, StringTraits>::GetEnvironmentVariable(PCXSTR pszVar)
{
- ULONG nLength = StringTraits::GetEnvironmentVariable(pszVar, NULL, 0);
+ ULONG nLength = StringTraits::GetEnvironmentVariable(pszVar, nullptr, 0);
BOOL bRetVal = FALSE;
if (nLength == 0)
|