App: modernize C++11

* use nullptr
This commit is contained in:
wmayer
2022-03-23 17:29:23 +01:00
parent 882e34f2ce
commit 749361d2f3
67 changed files with 647 additions and 643 deletions

View File

@@ -32,12 +32,12 @@
using namespace App;
Enumeration::Enumeration()
: _EnumArray(NULL), _ownEnumArray(false), _index(0), _maxVal(-1)
: _EnumArray(nullptr), _ownEnumArray(false), _index(0), _maxVal(-1)
{
}
Enumeration::Enumeration(const Enumeration &other)
: _EnumArray(NULL), _ownEnumArray(false), _index(0), _maxVal(-1)
: _EnumArray(nullptr), _ownEnumArray(false), _index(0), _maxVal(-1)
{
if (other._ownEnumArray) {
setEnums(other.getEnumVector());
@@ -59,7 +59,7 @@ Enumeration::Enumeration(const char *valStr)
#else
_EnumArray[0] = strdup(valStr);
#endif
_EnumArray[1] = NULL;
_EnumArray[1] = nullptr;
}
Enumeration::Enumeration(const char **list, const char *valStr)
@@ -72,7 +72,7 @@ Enumeration::Enumeration(const char **list, const char *valStr)
Enumeration::~Enumeration()
{
if (_ownEnumArray) {
if (_EnumArray != NULL) {
if (_EnumArray != nullptr) {
tearDown();
}
}
@@ -81,14 +81,14 @@ Enumeration::~Enumeration()
void Enumeration::tearDown(void)
{
// Ugly...
for(char **plEnums = (char **)_EnumArray; *plEnums != NULL; ++plEnums) {
for(char **plEnums = (char **)_EnumArray; *plEnums != nullptr; ++plEnums) {
// Delete C Strings first
free(*plEnums);
}
delete [] _EnumArray;
_EnumArray = NULL;
_EnumArray = nullptr;
_ownEnumArray = false;
_maxVal = -1;
}
@@ -99,7 +99,7 @@ void Enumeration::setEnums(const char **plEnums)
return;
std::string oldValue;
bool preserve = (isValid() && plEnums != NULL);
bool preserve = (isValid() && plEnums != nullptr);
if (preserve) {
const char* str = getCStr();
if (str)
@@ -157,7 +157,7 @@ void Enumeration::setEnums(const std::vector<std::string> &values)
#endif
}
_EnumArray[i] = 0; // null termination
_EnumArray[i] = nullptr; // null termination
// Other state variables
_maxVal = static_cast<int>(values.size() - 1);
@@ -188,7 +188,7 @@ void Enumeration::setValue(const char *value)
// search for the right entry
while (1) {
// end of list? set zero
if (*plEnums == NULL) {
if (*plEnums == nullptr) {
_index = 0;
break;
}
@@ -242,7 +242,7 @@ bool Enumeration::contains(const char *value) const
// search for the right entry
while (1) {
// end of list?
if (*plEnums == NULL)
if (*plEnums == nullptr)
return false;
if (strcmp(*plEnums, value) == 0)
return true;
@@ -256,7 +256,7 @@ const char * Enumeration::getCStr(void) const
//assert(_EnumArray);
if (!isValid() || _index < 0 || _index > _maxVal) {
return NULL;
return nullptr;
}
return _EnumArray[_index];
@@ -281,7 +281,7 @@ std::vector<std::string> Enumeration::getEnumVector(void) const
const char **plEnums = _EnumArray;
// end of list?
while (*plEnums != NULL) {
while (*plEnums != nullptr) {
result.push_back(*plEnums);
++plEnums;
}
@@ -296,7 +296,7 @@ const char ** Enumeration::getEnums(void) const
bool Enumeration::isValid(void) const
{
return (_EnumArray != NULL && _index >= 0 && _index <= _maxVal);
return (_EnumArray != nullptr && _index >= 0 && _index <= _maxVal);
}
Enumeration & Enumeration::operator=(const Enumeration &other)
@@ -333,7 +333,7 @@ bool Enumeration::operator==(const Enumeration &other) const
bool Enumeration::operator==(const char *other) const
{
if (getCStr() == NULL) {
if (getCStr() == nullptr) {
return false;
}
@@ -342,7 +342,7 @@ bool Enumeration::operator==(const char *other) const
void Enumeration::findMaxVal(void)
{
if (_EnumArray == NULL) {
if (_EnumArray == nullptr) {
_maxVal = -1;
return;
}
@@ -352,7 +352,7 @@ void Enumeration::findMaxVal(void)
// the NULL terminator doesn't belong to the range of
// valid values
int i = -1;
while (*(plEnums++) != NULL) {
while (*(plEnums++) != nullptr) {
++i;
// very unlikely to have enums with more then 5000 entries!
assert(i < 5000);