added tiny wxInitializer class
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10462 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
38caaa61b1
commit
fae9f59039
@ -351,6 +351,27 @@ extern bool WXDLLEXPORT wxInitialize();
|
||||
// wxUninitialize()
|
||||
extern void WXDLLEXPORT wxUninitialize();
|
||||
|
||||
// create an object of this class on stack to initialize/cleanup thel ibrary
|
||||
// automatically
|
||||
class WXDLLEXPORT wxInitializer
|
||||
{
|
||||
public:
|
||||
// initialize the library
|
||||
wxInitializer() { m_ok = wxInitialize(); }
|
||||
|
||||
// has the initialization been successful? (explicit test)
|
||||
bool IsOk() const { return m_ok; }
|
||||
|
||||
// has the initialization been successful? (implicit test)
|
||||
operator bool() const { return m_ok; }
|
||||
|
||||
// dtor only does clean up if we initialized the library properly
|
||||
~wxInitializer() { if ( m_ok ) wxUninitialize(); }
|
||||
|
||||
private:
|
||||
bool m_ok;
|
||||
};
|
||||
|
||||
#endif // !wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user