Back to index

unity  6.0.0
Public Member Functions | Private Attributes
unity::glib::Variant Class Reference

#include <Variant.h>

List of all members.

Public Member Functions

 Variant ()
 Variant (GVariant *)
 Variant (GVariant *, StealRef const &)
 Variant (Variant const &)
 ~Variant ()
std::string GetString () const
int GetInt () const
unsigned GetUInt () const
bool GetBool () const
bool ASVToHints (HintsMap &hints) const
Variantoperator= (GVariant *)
 operator GVariant * () const

Private Attributes

GVariant * variant_

Detailed Description

Definition at line 39 of file Variant.h.


Constructor & Destructor Documentation

Definition at line 27 of file Variant.cpp.

  : variant_(NULL)
{}
unity::glib::Variant::Variant ( GVariant *  variant)

Definition at line 31 of file Variant.cpp.

  : variant_(variant)
{
  g_variant_ref_sink(variant_);
}
unity::glib::Variant::Variant ( GVariant *  variant,
StealRef const &  ref 
)

Definition at line 37 of file Variant.cpp.

  : variant_(variant)
{}

Definition at line 41 of file Variant.cpp.

  : variant_(other.variant_)
{
  if (variant_) g_variant_ref_sink(variant_);
}

Definition at line 47 of file Variant.cpp.

{
  if (variant_) g_variant_unref(variant_);
}

Member Function Documentation

bool unity::glib::Variant::ASVToHints ( HintsMap hints) const

Definition at line 74 of file Variant.cpp.

{
  GVariantIter* hints_iter;
  char* key = NULL;
  GVariant* value = NULL;

  if (!g_variant_is_of_type (variant_, G_VARIANT_TYPE ("(a{sv})")) &&
      !g_variant_is_of_type (variant_, G_VARIANT_TYPE ("a{sv}")))
  {
    return false;
  }

  g_variant_get(variant_, g_variant_get_type_string(variant_), &hints_iter);

  while (g_variant_iter_loop(hints_iter, "{sv}", &key, &value))
  {
    hints[key] = value;
  }

  g_variant_iter_free (hints_iter);

  return true;
}

Here is the caller graph for this function:

Definition at line 69 of file Variant.cpp.

{
  return (g_variant_get_boolean (variant_) != FALSE);
}

Definition at line 59 of file Variant.cpp.

{
  return static_cast<int>(g_variant_get_int32 (variant_));
}
std::string unity::glib::Variant::GetString ( ) const

Definition at line 52 of file Variant.cpp.

{
  // g_variant_get_string doesn't duplicate the string
  const gchar *result = g_variant_get_string (variant_, NULL);
  return result != NULL ? result : "";
}
unsigned unity::glib::Variant::GetUInt ( ) const

Definition at line 64 of file Variant.cpp.

{
  return static_cast<unsigned>(g_variant_get_uint32 (variant_));
}
unity::glib::Variant::operator GVariant * ( ) const

Definition at line 106 of file Variant.cpp.

{
  return variant_;
}
Variant & unity::glib::Variant::operator= ( GVariant *  val)

Definition at line 98 of file Variant.cpp.

{
  if (variant_) g_variant_unref (variant_);
  variant_ = g_variant_ref_sink (val);

  return *this;
}

Member Data Documentation

GVariant* unity::glib::Variant::variant_ [private]

Definition at line 59 of file Variant.h.


The documentation for this class was generated from the following files: