Mass replace NULL --> nullptr

(Except one instance was instead replaced with nil)
This commit is contained in:
2015-09-13 10:50:21 -04:00
parent f1b097a54c
commit 780b413d0c
24 changed files with 92 additions and 92 deletions

View File

@@ -207,14 +207,14 @@ void cLed::attachFocusHandler(focus_callback_t f) throw(){
}
bool cLed::triggerFocusHandler(cDialog& me, std::string id, bool losing){
if(onFocus != NULL) return onFocus(me,id,losing);
if(onFocus != nullptr) return onFocus(me,id,losing);
return true;
}
bool cLed::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){
bool result;
eLedState oldState = state;
if(onClick != NULL) result = onClick(me,id,mods);
if(onClick != nullptr) result = onClick(me,id,mods);
else{ // simple state toggle
switch(state){
case led_red:
@@ -394,7 +394,7 @@ bool cLedGroup::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){
}
bool cLedGroup::triggerFocusHandler(cDialog& me, std::string id, bool losingFocus){
if(onFocus != NULL) return onFocus(me,id,losingFocus);
if(onFocus != nullptr) return onFocus(me,id,losingFocus);
return true;
}

View File

@@ -50,13 +50,13 @@ const char* xHandlerNotSupported::what(){
xUnsupportedProp::xUnsupportedProp(eFormat prop) throw(){
whichProp = prop;
msg = NULL;
msg = nullptr;
}
xUnsupportedProp::~xUnsupportedProp() throw(){
if(msg != NULL) delete msg;
if(msg != nullptr) delete msg;
}
const char* xUnsupportedProp::what() throw(){
if(msg == NULL){
if(msg == nullptr){
msg = new char[62];
std::string s;
switch(whichProp){
@@ -266,7 +266,7 @@ void cControl::detachKey(){
cControl::cControl(eControlType t, cDialog& p) : parent(&p), inWindow(&p.win), type(t), visible(true), key({false, 0, mod_none}), frameStyle(0) {}
cControl::cControl(eControlType t, sf::RenderWindow& p) : parent(NULL), inWindow(&p), type(t), visible(true), key({false, 0, mod_none}), frameStyle(0) {}
cControl::cControl(eControlType t, sf::RenderWindow& p) : parent(nullptr), inWindow(&p), type(t), visible(true), key({false, 0, mod_none}), frameStyle(0) {}
bool cControl::triggerClickHandler(cDialog&, std::string, eKeyMod){
return true;

View File

@@ -230,7 +230,7 @@ protected:
/// May be null, if the control was created via cControl(eControlType,sf::RenderWindow&).
cDialog* parent;
/// This control's labelling control.
cControl* labelCtrl = NULL;
cControl* labelCtrl = nullptr;
/// The parent window of the control.
/// This is for use in implementing draw().
sf::RenderWindow* inWindow;

View File

@@ -1360,7 +1360,7 @@ bool cDialog::addLabelFor(std::string key, std::string label, eLabelPos where, s
}
labelCtrl->setText(label);
labelCtrl->setFormat(TXT_FONT, bold ? FONT_BOLD : FONT_PLAIN);
if(bg == BG_DARK && dynamic_cast<cButton*>(&ctrl) != NULL)
if(bg == BG_DARK && dynamic_cast<cButton*>(&ctrl) != nullptr)
labelCtrl->setColour(defTextClr);
else labelCtrl->setColour(ctrl.getColour());
ctrl.setLabelCtrl(labelCtrl);
@@ -1417,13 +1417,13 @@ xBadNode::xBadNode(std::string t, int r, int c, std::string dlg) throw() :
type(t),
row(r),
col(c),
msg(NULL),
msg(nullptr),
dlg(dlg) {}
const char* xBadNode::what() const throw() {
if(msg == NULL){
if(msg == nullptr){
char* s = new (nothrow) char[200];
if(s == NULL){
if(s == nullptr){
std::cerr << "Allocation of memory for error message failed, bailing out..." << std::endl;
abort();
}
@@ -1434,7 +1434,7 @@ const char* xBadNode::what() const throw() {
}
xBadNode::~xBadNode() throw(){
if(msg != NULL) delete[] msg;
if(msg != nullptr) delete[] msg;
}
xBadAttr::xBadAttr(std::string t, std::string n, int r, int c, std::string dlg) throw() :
@@ -1442,13 +1442,13 @@ xBadAttr::xBadAttr(std::string t, std::string n, int r, int c, std::string dlg)
name(n),
row(r),
col(c),
msg(NULL),
msg(nullptr),
dlg(dlg) {}
const char* xBadAttr::what() const throw() {
if(msg == NULL){
if(msg == nullptr){
char* s = new (nothrow) char[200];
if(s == NULL){
if(s == nullptr){
std::cerr << "Allocation of memory for error message failed, bailing out..." << std::endl;
abort();
}
@@ -1459,7 +1459,7 @@ const char* xBadAttr::what() const throw() {
}
xBadAttr::~xBadAttr() throw(){
if(msg != NULL) delete[] msg;
if(msg != nullptr) delete[] msg;
}
xMissingAttr::xMissingAttr(std::string t, std::string n, int r, int c, std::string dlg) throw() :
@@ -1467,13 +1467,13 @@ xMissingAttr::xMissingAttr(std::string t, std::string n, int r, int c, std::stri
name(n),
row(r),
col(c),
msg(NULL),
msg(nullptr),
dlg(dlg) {}
const char* xMissingAttr::what() const throw() {
if(msg == NULL){
if(msg == nullptr){
char* s = new (nothrow) char[200];
if(s == NULL){
if(s == nullptr){
std::cerr << "Allocation of memory for error message failed, bailing out..." << std::endl;
abort();
}
@@ -1484,7 +1484,7 @@ const char* xMissingAttr::what() const throw() {
}
xMissingAttr::~xMissingAttr() throw(){
if(msg != NULL) delete[] msg;
if(msg != nullptr) delete[] msg;
}
xMissingElem::xMissingElem(std::string p, std::string t, int r, int c, std::string dlg) throw() :
@@ -1492,13 +1492,13 @@ xMissingElem::xMissingElem(std::string p, std::string t, int r, int c, std::stri
name(t),
row(r),
col(c),
msg(NULL),
msg(nullptr),
dlg(dlg) {}
const char* xMissingElem::what() const throw() {
if(msg == NULL){
if(msg == nullptr){
char* s = new (nothrow) char[200];
if(s == NULL){
if(s == nullptr){
std::cerr << "Allocation of memory for error message failed, bailing out..." << std::endl;
abort();
}
@@ -1509,7 +1509,7 @@ const char* xMissingElem::what() const throw() {
}
xMissingElem::~xMissingElem() throw(){
if(msg != NULL) delete[] msg;
if(msg != nullptr) delete[] msg;
}
xBadVal::xBadVal(std::string t, std::string n, std::string v, int r, int c, std::string dlg) throw() :
@@ -1518,13 +1518,13 @@ xBadVal::xBadVal(std::string t, std::string n, std::string v, int r, int c, std:
val(v),
row(r),
col(c),
msg(NULL),
msg(nullptr),
dlg(dlg) {}
const char* xBadVal::what() const throw() {
if(msg == NULL){
if(msg == nullptr){
char* s = new (nothrow) char[200];
if(s == NULL){
if(s == nullptr){
std::cerr << "Allocation of memory for error message failed, bailing out..." << std::endl;
abort();
}
@@ -1535,7 +1535,7 @@ const char* xBadVal::what() const throw() {
}
xBadVal::~xBadVal() throw(){
if(msg != NULL) delete[] msg;
if(msg != nullptr) delete[] msg;
}
bool cDialog::doAnimations = false;

View File

@@ -58,11 +58,11 @@ public:
static short defaultBackground;
/// Create a new dialog with no items.
/// @param p Optionally, a parent dialog.
explicit cDialog(cDialog* p = NULL);
explicit cDialog(cDialog* p = nullptr);
/// Creates a new dialog, loading its definition from a file.
/// @param path The name of the file to load. It must be in the game's dialogs directory.
/// @param p Optionally, a parent dialog.
explicit cDialog(std::string path, cDialog* p = NULL); // cd_create_dialog
explicit cDialog(std::string path, cDialog* p = nullptr); // cd_create_dialog
~cDialog(); // cd_kill_dialog
/// Add a new control to the dialog.
/// @param what A pointer to the control, which should already be constructed.

View File

@@ -502,7 +502,7 @@ cStrDlog& cStrDlog::setSound(snd_num_t snd){
}
cStrDlog& cStrDlog::setRecordHandler(record_callback_t rec){
if(rec == NULL){
if(rec == nullptr){
hasRecord = false;
dlg["record"].hide();
}else{

View File

@@ -44,7 +44,7 @@ public:
/// @param pic The icon to show at the top left.
/// @param t The type of icon to show.
/// @param parent Optionally, a parent dialog.
cStrDlog(std::string str1,std::string str2,std::string title,pic_num_t pic,ePicType t,cDialog* parent = NULL);
cStrDlog(std::string str1,std::string str2,std::string title,pic_num_t pic,ePicType t,cDialog* parent = nullptr);
/// Set a sound to be played when the dialog is shown.
/// @param num The sound number.
/// @return This object, for method-call chaining.
@@ -78,18 +78,18 @@ protected:
bool onClick(cDialog& me, std::string id);
/// Create a choice dialog, but don't initialize it.
/// @param p Optionally, a parent dialog.
explicit cChoiceDlog(cDialog* p = NULL);
explicit cChoiceDlog(cDialog* p = nullptr);
public:
/// Create a choice dialog with just one button.
/// @param file The file to load the dialog definition from.
/// @param p Optionally, a parent dialog.
/// @note The dialog definition file must include a button whose name attribute is "okay".
explicit cChoiceDlog(std::string file, cDialog* p = NULL);
explicit cChoiceDlog(std::string file, cDialog* p = nullptr);
/// Create a choice dialog with several buttons.
/// @param file The file to load the dialog definition from.
/// @param buttons A list of the buttons to handle. All of them must be defined in the file.
/// @param p Optionally, a parent dialog.
cChoiceDlog(std::string file, std::vector<std::string> buttons, cDialog* p = NULL);
cChoiceDlog(std::string file, std::vector<std::string> buttons, cDialog* p = nullptr);
/// Reference the cDialog powering this choice dialog, perhaps to customize details of it.
/// @return A pointer to the dialog.
cDialog* operator->();
@@ -133,21 +133,21 @@ public:
/// @param pic The icon to show at the top left.
/// @param t The type of the icon.
/// @param parent Optionally, a parent dialog.
cThreeChoice(std::vector<std::string>& strings, cBasicButtonType button, pic_num_t pic, ePicType t, cDialog* parent = NULL);
cThreeChoice(std::vector<std::string>& strings, cBasicButtonType button, pic_num_t pic, ePicType t, cDialog* parent = nullptr);
/// Create a dialog with up to three buttons.
/// @param strings A list of the strings to place in the dialog.
/// @param buttons A list of the button specifications.
/// @param pic The icon to show at the top left.
/// @param t The type of the icon.
/// @param parent Optionally, a parent dialog.
cThreeChoice(std::vector<std::string>& strings, std::array<cBasicButtonType, 3>& buttons, pic_num_t pic, ePicType t, cDialog* parent = NULL);
cThreeChoice(std::vector<std::string>& strings, std::array<cBasicButtonType, 3>& buttons, pic_num_t pic, ePicType t, cDialog* parent = nullptr);
/// Create a dialog with up to three buttons.
/// @param strings A list of the strings to place in the dialog.
/// @param buttons A list of the index of the button; this is an index into available_btns which is in turn used to index basic_buttons.
/// @param pic The icon to show at the top left.
/// @param t The type of the icon.
/// @param parent Optionally, a parent dialog.
cThreeChoice(std::vector<std::string>& strings, std::array<short, 3>& buttons, pic_num_t pic, ePicType t, cDialog* parent = NULL);
cThreeChoice(std::vector<std::string>& strings, std::array<short, 3>& buttons, pic_num_t pic, ePicType t, cDialog* parent = nullptr);
/// @copydoc cChoiceDlog::show()
/// @note The unique key in this case is the label specified in the button specification.
std::string show();
@@ -174,14 +174,14 @@ public:
/// @param strs A list of all strings in the dialog.
/// @param title The title to show in the dialog.
/// @param parent Optionally, a parent dialog.
explicit cStringChoice(std::vector<std::string>& strs, std::string title, cDialog* parent = NULL);
explicit cStringChoice(std::vector<std::string>& strs, std::string title, cDialog* parent = nullptr);
/// Initializes a dialog from an iterator pair.
/// @param begin An iterator to the first string in the dialog.
/// @param end An iterator to one past the last string in the dialog.
/// @param title The title to show in the dialog.
/// @param parent Optionally, a parent dialog.
/// @note Currently, only vector iterators are supported.
cStringChoice(std::vector<std::string>::iterator begin, std::vector<std::string>::iterator end, std::string title, cDialog* parent = NULL);
cStringChoice(std::vector<std::string>::iterator begin, std::vector<std::string>::iterator end, std::string title, cDialog* parent = nullptr);
/// Attach a handler to be called when the selected item changes.
/// @param f A function that takes a reference to the dialog and the index of the newly selected item.
void attachSelectHandler(std::function<void(cStringChoice&,int)> f);
@@ -216,23 +216,23 @@ public:
/// @param pics A list of all icons in the dialog.
/// @param t The type of icons to show; all icons are assumed to be of the same type.
/// @param parent Optionally, a parent dialog.
cPictChoice(const std::vector<pic_num_t>& pics, ePicType t, cDialog* parent = NULL);
cPictChoice(const std::vector<pic_num_t>& pics, ePicType t, cDialog* parent = nullptr);
/// Initializes a dialog from a list of icons.
/// @param pics A list of all icons in the dialog as {num,type} pairs.
/// @param parent Optionally, a parent dialog.
cPictChoice(const std::vector<std::pair<pic_num_t,ePicType>>& pics, cDialog* parent = NULL);
cPictChoice(const std::vector<std::pair<pic_num_t,ePicType>>& pics, cDialog* parent = nullptr);
/// Initializes a dialog from an iterator pair.
/// @param begin An iterator to the first icon in the dialog.
/// @param end An iterator to one past the last icon in the dialog.
/// @param t The type of icons to show; all icons are assumed to be of the same type.
/// @param parent Optionally, a parent dialog.
cPictChoice(std::vector<pic_num_t>::const_iterator begin, std::vector<pic_num_t>::const_iterator end, ePicType t, cDialog* parent = NULL);
cPictChoice(std::vector<pic_num_t>::const_iterator begin, std::vector<pic_num_t>::const_iterator end, ePicType t, cDialog* parent = nullptr);
/// Initializes a dialog from an index pair.
/// @param first The number of the first icon in the dialog.
/// @param last The number of the last icon in the dialog.
/// @param t The type of icons to show; all icons are assumed to be of the same type.
/// @param parent Optionally, a parent dialog.
cPictChoice(pic_num_t first, pic_num_t last, ePicType t, cDialog* parent = NULL);
cPictChoice(pic_num_t first, pic_num_t last, ePicType t, cDialog* parent = nullptr);
/// Attach a handler to be called when the selected item changes.
/// @param f A function that takes a reference to the dialog and the index of the newly selected item.
void attachSelectHandler(std::function<void(cPictChoice&,int)> f);
@@ -259,28 +259,28 @@ public:
/// @param str1 The first string in the error dialog.
/// @param str2 The second string in the error dialog.
/// @param parent Optionally, a parent dialog.
void showFatalError(std::string str1, std::string str2, cDialog* parent = NULL);
void showFatalError(std::string str1, std::string str2, cDialog* parent = nullptr);
/// Shows a simple error dialog for an unrecoverable condition.
/// @param str1 The string in the error dialog.
/// @param parent Optionally, a parent dialog.
void showFatalError(std::string str1, cDialog* parent = NULL);
void showFatalError(std::string str1, cDialog* parent = nullptr);
/// Shows a simple error dialog for a recoverable condition.
/// @param str1 The first string in the error dialog.
/// @param str2 The second string in the error dialog.
/// @param parent Optionally, a parent dialog.
void showError(std::string str1, std::string str2, cDialog* parent = NULL);
void showError(std::string str1, std::string str2, cDialog* parent = nullptr);
/// Shows a simple error dialog for a recoverable condition.
/// @param str1 The string in the error dialog.
/// @param parent Optionally, a parent dialog.
void showError(std::string str1, cDialog* parent = NULL);
void showError(std::string str1, cDialog* parent = nullptr);
/// Shows a simple warning message dialog.
/// @param str1 The first string in the warning dialog.
/// @param str2 The second string in the warning dialog.
/// @param parent Optionally, a parent dialog.
void showWarning(std::string str1, std::string str2, cDialog* parent = NULL);
void showWarning(std::string str1, std::string str2, cDialog* parent = nullptr);
/// Shows a simple warning message dialog.
/// @param str1 The string in the warning dialog.
/// @param parent Optionally, a parent dialog.
void showWarning(std::string str1, cDialog* parent = NULL);
void showWarning(std::string str1, cDialog* parent = nullptr);

View File

@@ -52,7 +52,7 @@ bool cTextField::triggerFocusHandler(cDialog& me, std::string id, bool losingFoc
}
}
bool passed = true;
if(onFocus != NULL) passed = onFocus(me,id,losingFocus);
if(onFocus != nullptr) passed = onFocus(me,id,losingFocus);
if(passed) haveFocus = !losingFocus;
if(haveFocus && insertionPoint < 0)
insertionPoint = getText().length();

View File

@@ -15,7 +15,7 @@ extern sf::Texture bg_gworld;
void cTextMsg::attachClickHandler(click_callback_t f) throw(){
onClick = f;
clickable = onClick != NULL;
clickable = onClick != nullptr;
}
void cTextMsg::attachFocusHandler(focus_callback_t) throw(xHandlerNotSupported){
@@ -23,7 +23,7 @@ void cTextMsg::attachFocusHandler(focus_callback_t) throw(xHandlerNotSupported){
}
bool cTextMsg::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){
if(onClick != NULL) return onClick(me,id,mods);
if(onClick != nullptr) return onClick(me,id,mods);
return false;
}

View File

@@ -60,7 +60,7 @@ void cScrollbar::attachFocusHandler(focus_callback_t) throw(xHandlerNotSupported
bool cScrollbar::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods) {
// TODO: Implement detection of scrolling stuff, maybe even dragging the thumb
if(onClick != NULL) return onClick(me,id,mods);
if(onClick != nullptr) return onClick(me,id,mods);
return false;
}