Files
wxWidgets/include/wx/gtk/private/value.h
Vadim Zeitlin 3568a160a9 Use wxGtkValue RAII wrapper in wxGTK code
wxGtkValue class was added back in 3f84cb17ca (Add wxActivityIndicator
control., 2015-03-06), but somehow never used. Start using it now
(better late than never...) as it makes the code simpler, shorter and
more robust.

No real changes.
2021-01-24 23:55:43 +01:00

49 lines
1.3 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private/value.h
// Purpose: Helper wrapper for working with GValue.
// Author: Vadim Zeitlin
// Created: 2015-03-05
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_VALUE_H_
#define _WX_GTK_PRIVATE_VALUE_H_
// ----------------------------------------------------------------------------
// wxGtkValue: RAII wrapper for GValue
// ----------------------------------------------------------------------------
class wxGtkValue
{
public:
explicit wxGtkValue()
: m_val(G_VALUE_INIT)
{
}
// Initialize the value of the specified type.
explicit wxGtkValue(GType gtype)
: m_val(G_VALUE_INIT)
{
g_value_init(&m_val, gtype);
}
~wxGtkValue()
{
g_value_unset(&m_val);
}
// Unsafe but convenient access to the real value for GTK+ functions.
operator GValue*() { return &m_val; }
private:
GValue m_val;
// For now we just don't support copying at all for simplicity, it could be
// implemented later if needed.
wxDECLARE_NO_COPY_CLASS(wxGtkValue);
};
#endif // _WX_GTK_PRIVATE_VALUE_H_