diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-01-24 11:00:22 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-01-24 11:05:51 +0100 |
commit | 418ffcadb0a5334ebe621369c14d6c3dd651acce (patch) | |
tree | e76132cb4a9013676b9a6dc6222d5f3f68d3a099 | |
parent | d9dc702115d705c39a39fb1f2290f5feb8dc19c9 (diff) | |
download | mana-418ffcadb0a5334ebe621369c14d6c3dd651acce.tar.gz mana-418ffcadb0a5334ebe621369c14d6c3dd651acce.tar.bz2 mana-418ffcadb0a5334ebe621369c14d6c3dd651acce.tar.xz mana-418ffcadb0a5334ebe621369c14d6c3dd651acce.zip |
Fixed compilation issues and use of deprecated C++ features
* Fixed compiler errors due to dynamic exception specifications
* Replace std::auto_ptr with std::unique_ptr
* Replace std::mem_fun with std::mem_fn
* Prefix for_each with std:: (apparently not needed before)
* Just use lambda instead of std::bind2nd
* Removed usages of std::unary_function
-rw-r--r-- | src/event.cpp | 24 | ||||
-rw-r--r-- | src/event.h | 24 | ||||
-rw-r--r-- | src/gui/setup.cpp | 6 | ||||
-rw-r--r-- | src/gui/tradewindow.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/button.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/dropdown.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/playerbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/progressbar.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/tab.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/textfield.cpp | 2 | ||||
-rw-r--r-- | src/net/manaserv/messagehandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/messagehandler.h | 2 | ||||
-rw-r--r-- | src/resources/theme.cpp | 4 | ||||
-rw-r--r-- | src/utils/dtor.h | 6 |
15 files changed, 44 insertions, 44 deletions
diff --git a/src/event.cpp b/src/event.cpp index 45e65fff..73099cc3 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -37,7 +37,7 @@ Event::~Event() // Integers -void Event::setInt(const std::string &key, int value) throw (BadEvent) +void Event::setInt(const std::string &key, int value) { if (mData.find(key) != mData.end()) throw KEY_ALREADY_EXISTS; @@ -45,7 +45,7 @@ void Event::setInt(const std::string &key, int value) throw (BadEvent) mData[key] = new IntData(value); } -int Event::getInt(const std::string &key) const throw (BadEvent) +int Event::getInt(const std::string &key) const { VariableMap::const_iterator it = mData.find(key); if (it == mData.end()) @@ -66,7 +66,7 @@ bool Event::hasInt(const std::string &key) const // Strings -void Event::setString(const std::string &key, const std::string &value) throw (BadEvent) +void Event::setString(const std::string &key, const std::string &value) { if (mData.find(key) != mData.end()) throw KEY_ALREADY_EXISTS; @@ -74,7 +74,7 @@ void Event::setString(const std::string &key, const std::string &value) throw (B mData[key] = new StringData(value); } -const std::string &Event::getString(const std::string &key) const throw (BadEvent) +const std::string &Event::getString(const std::string &key) const { VariableMap::const_iterator it = mData.find(key); if (it == mData.end()) @@ -96,7 +96,7 @@ bool Event::hasString(const std::string &key) const // Floats -void Event::setFloat(const std::string &key, double value) throw (BadEvent) +void Event::setFloat(const std::string &key, double value) { if (mData.find(key) != mData.end()) throw KEY_ALREADY_EXISTS; @@ -104,7 +104,7 @@ void Event::setFloat(const std::string &key, double value) throw (BadEvent) mData[key] = new FloatData(value); } -double Event::getFloat(const std::string &key) const throw (BadEvent) +double Event::getFloat(const std::string &key) const { VariableMap::const_iterator it = mData.find(key); if (it == mData.end()) @@ -125,7 +125,7 @@ bool Event::hasFloat(const std::string &key) const // Booleans -void Event::setBool(const std::string &key, bool value) throw (BadEvent) +void Event::setBool(const std::string &key, bool value) { if (mData.find(key) != mData.end()) throw KEY_ALREADY_EXISTS; @@ -133,7 +133,7 @@ void Event::setBool(const std::string &key, bool value) throw (BadEvent) mData[key] = new BoolData(value); } -bool Event::getBool(const std::string &key) const throw (BadEvent) +bool Event::getBool(const std::string &key) const { VariableMap::const_iterator it = mData.find(key); if (it == mData.end()) @@ -154,7 +154,7 @@ bool Event::hasBool(const std::string &key) const // Items -void Event::setItem(const std::string &key, Item *value) throw (BadEvent) +void Event::setItem(const std::string &key, Item *value) { if (mData.find(key) != mData.end()) throw KEY_ALREADY_EXISTS; @@ -162,7 +162,7 @@ void Event::setItem(const std::string &key, Item *value) throw (BadEvent) mData[key] = new ItemData(value); } -Item *Event::getItem(const std::string &key) const throw (BadEvent) +Item *Event::getItem(const std::string &key) const { VariableMap::const_iterator it = mData.find(key); if (it == mData.end()) @@ -183,7 +183,7 @@ bool Event::hasItem(const std::string &key) const // Actors -void Event::setActor(const std::string &key, ActorSprite *value) throw (BadEvent) +void Event::setActor(const std::string &key, ActorSprite *value) { if (mData.find(key) != mData.end()) throw KEY_ALREADY_EXISTS; @@ -191,7 +191,7 @@ void Event::setActor(const std::string &key, ActorSprite *value) throw (BadEvent mData[key] = new ActorData(value); } -ActorSprite *Event::getActor(const std::string &key) const throw (BadEvent) +ActorSprite *Event::getActor(const std::string &key) const { VariableMap::const_iterator it = mData.find(key); if (it == mData.end()) diff --git a/src/event.h b/src/event.h index f33e4c70..b785b16f 100644 --- a/src/event.h +++ b/src/event.h @@ -132,12 +132,12 @@ public: /** * Sets the given variable to the given integer, if it isn't already set. */ - void setInt(const std::string &key, int value) throw (BadEvent); + void setInt(const std::string &key, int value); /** * Returns the given variable if it is set and an integer. */ - int getInt(const std::string &key) const throw (BadEvent); + int getInt(const std::string &key) const; /** * Returns the given variable if it is set and an integer, returning the @@ -156,12 +156,12 @@ public: /** * Sets the given variable to the given string, if it isn't already set. */ - void setString(const std::string &key, const std::string &value) throw (BadEvent); + void setString(const std::string &key, const std::string &value); /** * Returns the given variable if it is set and a string. */ - const std::string &getString(const std::string &key) const throw (BadEvent); + const std::string &getString(const std::string &key) const; /** * Returns the given variable if it is set and a string, returning the @@ -182,12 +182,12 @@ public: * Sets the given variable to the given floating-point, if it isn't already * set. */ - void setFloat(const std::string &key, double value) throw (BadEvent); + void setFloat(const std::string &key, double value); /** * Returns the given variable if it is set and a floating-point. */ - double getFloat(const std::string &key) const throw (BadEvent); + double getFloat(const std::string &key) const; /** * Returns the given variable if it is set and a floating-point, returning @@ -206,12 +206,12 @@ public: /** * Sets the given variable to the given boolean, if it isn't already set. */ - void setBool(const std::string &key, bool value) throw (BadEvent); + void setBool(const std::string &key, bool value); /** * Returns the given variable if it is set and a boolean. */ - bool getBool(const std::string &key) const throw (BadEvent); + bool getBool(const std::string &key) const; /** * Returns the given variable if it is set and a boolean, returning the @@ -230,12 +230,12 @@ public: /** * Sets the given variable to the given Item, if it isn't already set. */ - void setItem(const std::string &key, Item *value) throw (BadEvent); + void setItem(const std::string &key, Item *value); /** * Returns the given variable if it is set and an Item. */ - Item *getItem(const std::string &key) const throw (BadEvent); + Item *getItem(const std::string &key) const; /** * Returns the given variable if it is set and an Item, returning the @@ -254,12 +254,12 @@ public: /** * Sets the given variable to the given actor, if it isn't already set. */ - void setActor(const std::string &key, ActorSprite *value) throw (BadEvent); + void setActor(const std::string &key, ActorSprite *value); /** * Returns the given variable if it is set and an actor. */ - ActorSprite *getActor(const std::string &key) const throw (BadEvent); + ActorSprite *getActor(const std::string &key) const; /** * Returns the given variable if it is set and an actor, returning the diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index f378572b..930408ac 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -38,6 +38,8 @@ #include "utils/dtor.h" #include "utils/gettext.h" +#include <functional> + extern Window *statusWindow; Setup::Setup(): @@ -103,12 +105,12 @@ void Setup::action(const gcn::ActionEvent &event) if (event.getId() == "Apply") { setVisible(false); - for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::apply)); + for_each(mTabs.begin(), mTabs.end(), std::mem_fn(&SetupTab::apply)); } else if (event.getId() == "Cancel") { setVisible(false); - for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel)); + for_each(mTabs.begin(), mTabs.end(), std::mem_fn(&SetupTab::cancel)); } else if (event.getId() == "Reset Windows") { diff --git a/src/gui/tradewindow.h b/src/gui/tradewindow.h index 59ddcbdc..20da4574 100644 --- a/src/gui/tradewindow.h +++ b/src/gui/tradewindow.h @@ -117,7 +117,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener */ void setStatus(Status s); - typedef const std::auto_ptr<Inventory> InventoryPtr; + typedef const std::unique_ptr<Inventory> InventoryPtr; InventoryPtr mMyInventory; InventoryPtr mPartnerInventory; diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 4a31fa63..9247f67a 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -182,7 +182,7 @@ Button::~Button() { for (int mode = 0; mode < BUTTON_COUNT; ++mode) { - for_each(mButton[mode].grid, mButton[mode].grid + 9, + std::for_each(mButton[mode].grid, mButton[mode].grid + 9, dtor<Image*>()); } delete[] mButton; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index e90f6073..101afaef 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -102,7 +102,7 @@ DropDown::~DropDown() buttons[1][0]->decRef(); buttons[1][1]->decRef(); - for_each(skin.grid, skin.grid + 9, dtor<Image*>()); + std::for_each(skin.grid, skin.grid + 9, dtor<Image*>()); } delete mScrollArea; diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 5c5976c1..4f341af0 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -75,7 +75,7 @@ PlayerBox::~PlayerBox() if (instances == 0) { - for_each(background.grid, background.grid + 9, dtor<Image*>()); + std::for_each(background.grid, background.grid + 9, dtor<Image*>()); } } diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 27b194ff..4695f5ab 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -88,7 +88,7 @@ ProgressBar::~ProgressBar() if (mInstances == 0) { - for_each(mBorder.grid, mBorder.grid + 9, dtor<Image*>()); + std::for_each(mBorder.grid, mBorder.grid + 9, dtor<Image*>()); } } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index d5e824e1..c95adeaa 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -66,9 +66,9 @@ ScrollArea::~ScrollArea() if (instances == 0) { - for_each(background.grid, background.grid + 9, dtor<Image*>()); - for_each(vMarker.grid, vMarker.grid + 9, dtor<Image*>()); - for_each(vMarkerHi.grid, vMarkerHi.grid + 9, dtor<Image*>()); + std::for_each(background.grid, background.grid + 9, dtor<Image*>()); + std::for_each(vMarker.grid, vMarker.grid + 9, dtor<Image*>()); + std::for_each(vMarkerHi.grid, vMarkerHi.grid + 9, dtor<Image*>()); buttons[UP][0]->decRef(); buttons[UP][1]->decRef(); diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 17b7108f..c8ed2141 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -76,7 +76,7 @@ Tab::~Tab() { for (int mode = 0; mode < TAB_COUNT; mode++) { - for_each(tabImg[mode].grid, tabImg[mode].grid + 9, dtor<Image*>()); + std::for_each(tabImg[mode].grid, tabImg[mode].grid + 9, dtor<Image*>()); } } } diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index ec57f1c7..e7c279b2 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -84,7 +84,7 @@ TextField::~TextField() instances--; if (instances == 0) - for_each(skin.grid, skin.grid + 9, dtor<Image*>()); + std::for_each(skin.grid, skin.grid + 9, dtor<Image*>()); } void TextField::updateAlpha() diff --git a/src/net/manaserv/messagehandler.h b/src/net/manaserv/messagehandler.h index 6e0221cb..8949d34e 100644 --- a/src/net/manaserv/messagehandler.h +++ b/src/net/manaserv/messagehandler.h @@ -41,7 +41,7 @@ class MessageHandler : public Net::MessageHandler virtual void handleMessage(MessageIn &msg) = 0; }; -typedef const std::auto_ptr<MessageHandler> MessageHandlerPtr; +typedef const std::unique_ptr<MessageHandler> MessageHandlerPtr; } // namespace ManaServ diff --git a/src/net/tmwa/messagehandler.h b/src/net/tmwa/messagehandler.h index 2b1f5b7e..b598f896 100644 --- a/src/net/tmwa/messagehandler.h +++ b/src/net/tmwa/messagehandler.h @@ -49,7 +49,7 @@ class MessageHandler : public Net::MessageHandler Network *mNetwork; }; -typedef const std::auto_ptr<MessageHandler> MessageHandlerPtr; +typedef const std::unique_ptr<MessageHandler> MessageHandlerPtr; } diff --git a/src/resources/theme.cpp b/src/resources/theme.cpp index 96927ac8..1490dbf5 100644 --- a/src/resources/theme.cpp +++ b/src/resources/theme.cpp @@ -84,8 +84,8 @@ void Skin::updateAlpha(float minimumOpacityAllowed) const float alpha = std::max(minimumOpacityAllowed, config.getFloatValue("guialpha")); - for_each(mBorder.grid, mBorder.grid + 9, - std::bind2nd(std::mem_fun(&Image::setAlpha), alpha)); + std::for_each(mBorder.grid, mBorder.grid + 9, + [=] (Image *img) { img->setAlpha(alpha); }); mCloseImage->setAlpha(alpha); mStickyImageUp->setAlpha(alpha); diff --git a/src/utils/dtor.h b/src/utils/dtor.h index 223b73ed..76c68725 100644 --- a/src/utils/dtor.h +++ b/src/utils/dtor.h @@ -23,18 +23,16 @@ #define UTILS_DTOR_H #include <algorithm> -#include <functional> #include <utility> template<typename T> -struct dtor : public std::unary_function <T, void> +struct dtor { void operator()(T &ptr) { delete ptr; } }; template<typename T1, typename T2> -struct dtor<std::pair<T1, T2> > : -public std::unary_function <std::pair<T1, T2>, void> +struct dtor<std::pair<T1, T2>> { void operator()(std::pair<T1, T2> &pair) { delete pair.second; } }; |