// -*- c++ -*-
// Generated by gtkmmproc -- DO NOT MODIFY!
#ifndef _GLIBMM_VARIANTTYPE_H
#define _GLIBMM_VARIANTTYPE_H


/* Copyright 2010 The glibmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */


#include <glibmmconfig.h>
#include <glib-object.h> //For gsize
#include <string>

#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GVariantType GVariantType;
#endif //DOXYGEN_SHOULD_SKIP_THIS

namespace Glib
{

/** TODO
 * @newin{2,26}
 * @ingroup glibmmVariant
 */
class VariantType
{
  public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  typedef VariantType CppObjectType;
  typedef GVariantType BaseObjectType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

  VariantType();

  // Use make_a_copy=true when getting it directly from a struct.
  explicit VariantType(GVariantType* castitem, bool make_a_copy = false);

  VariantType(const VariantType& src);
  VariantType& operator=(const VariantType& src);

  ~VariantType();

  GVariantType*       gobj()       { return gobject_; }
  const GVariantType* gobj() const { return gobject_; }

  ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
  GVariantType* gobj_copy() const;

protected:
  GVariantType* gobject_;

private:

  
public:

  /** Copy the C item into a new VariantType instance.
   */
  explicit VariantType(const GVariantType* castitem);

  //TODO: Docuementation
  explicit VariantType(const std::string& type_string);

  VariantType& operator=(const GVariantType* castitem);


//The C parameters are actually const, but gmmproc doesn't understand that,
//so we add a m4 conversion to satisfy it:
 

  /** Constructs the type corresponding to an array of elements of the
   * type @a type.
   * 
   * It is appropriate to call g_variant_type_free() on the return value.
   * 
   * Since 2.24
   * @return A new array VariantType.
   */
  static VariantType create_array(const VariantType& element);
  
  /** Constructs the type corresponding to a maybe instance containing
   * type @a type or Nothing.
   * 
   * It is appropriate to call g_variant_type_free() on the return value.
   * 
   * Since 2.24
   * @return A new maybe VariantType.
   */
  static VariantType create_maybe(const VariantType& element);

  //TODO: Use a single list parameter:
  //_WRAP_METHOD(static VariantType create_tuple(const GVariantType * const *items, gint length), g_variant_type_new_tuple)

  
  /** Constructs the type corresponding to a dictionary entry with a key
   * of type @a key and a value of type @a value.
   * 
   * It is appropriate to call g_variant_type_free() on the return value.
   * 
   * Since 2.24
   * @param value A VariantType.
   * @return A new dictionary entry VariantType.
   */
  static VariantType create_dict_entry(const VariantType& key, const VariantType& value);

  //TODO: Use something instead of gsize?
  
  /** Returns the length of the type string corresponding to the given
   *  @a type.  This function must be used to determine the valid extent of
   * the memory region returned by g_variant_type_peek_string().
   * 
   * Since 2.24
   * @return The length of the corresponding type string.
   */
  gsize _get_string_length() const;
  
  /** Returns the type string corresponding to the given @a type.  The
   * result is not nul-terminated; in order to determine its length you
   * must call g_variant_type_get_string_length().
   * 
   * To get a nul-terminated string, see g_variant_type_dup_string().
   * 
   * Since 2.24
   * @return The corresponding type string (not nul-terminated).
   */
  std::string get_string() const;
  

  /** Determines if the given @a type is definite (ie: not indefinite).
   * 
   * A type is definite if its type string does not contain any indefinite
   * type characters ('*', '?', or 'r').
   * 
   * A Variant instance may not have an indefinite type, so calling
   * this function on the result of g_variant_get_type() will always
   * result in <tt>true</tt> being returned.  Calling this function on an
   * indefinite type like VARIANT_TYPE_ARRAY, however, will result in
   * <tt>false</tt> being returned.
   * 
   * Since 2.24
   * @return <tt>true</tt> if @a type is definite.
   */
  bool is_definite() const;
  
  /** Determines if the given @a type is a container type.
   * 
   * Container types are any array, maybe, tuple, or dictionary
   * entry types plus the variant type.
   * 
   * This function returns <tt>true</tt> for any indefinite type for which every
   * definite subtype is a container -- VARIANT_TYPE_ARRAY, for
   * example.
   * 
   * Since 2.24
   * @return <tt>true</tt> if @a type is a container type.
   */
  bool is_container() const;
  
  /** Determines if the given @a type is a basic type.
   * 
   * Basic types are booleans, bytes, integers, doubles, strings, object
   * paths and signatures.
   * 
   * Only a basic type may be used as the key of a dictionary entry.
   * 
   * This function returns <tt>false</tt> for all indefinite types except
   * VARIANT_TYPE_BASIC.
   * 
   * Since 2.24
   * @return <tt>true</tt> if @a type is a basic type.
   */
  bool is_basic() const;
  
  /** Determines if the given @a type is a maybe type.  This is true if the
   * type string for @a type starts with an 'm'.
   * 
   * This function returns <tt>true</tt> for any indefinite type for which every
   * definite subtype is a maybe type -- VARIANT_TYPE_MAYBE, for
   * example.
   * 
   * Since 2.24
   * @return <tt>true</tt> if @a type is a maybe type.
   */
  bool is_maybe() const;
  
  /** Determines if the given @a type is an array type.  This is true if the
   * type string for @a type starts with an 'a'.
   * 
   * This function returns <tt>true</tt> for any indefinite type for which every
   * definite subtype is an array type -- VARIANT_TYPE_ARRAY, for
   * example.
   * 
   * Since 2.24
   * @return <tt>true</tt> if @a type is an array type.
   */
  bool is_array() const;
  
  /** Determines if the given @a type is a tuple type.  This is true if the
   * type string for @a type starts with a '(' or if @a type is
   * VARIANT_TYPE_TUPLE.
   * 
   * This function returns <tt>true</tt> for any indefinite type for which every
   * definite subtype is a tuple type -- VARIANT_TYPE_TUPLE, for
   * example.
   * 
   * Since 2.24
   * @return <tt>true</tt> if @a type is a tuple type.
   */
  bool is_tuple() const;
  
  /** Determines if the given @a type is a dictionary entry type.  This is
   * true if the type string for @a type starts with a '{'.
   * 
   * This function returns <tt>true</tt> for any indefinite type for which every
   * definite subtype is a dictionary entry type --
   * VARIANT_TYPE_DICT_ENTRY, for example.
   * 
   * Since 2.24
   * @return <tt>true</tt> if @a type is a dictionary entry type.
   */
  bool is_dict_entry() const;
  
  /** Determines if the given @a type is the variant type.
   * 
   * Since 2.24
   * @return <tt>true</tt> if @a type is the variant type.
   */
  bool is_variant() const;

   
  /** Hashes @a type.
   * 
   * The argument type of @a type is only #gconstpointer to allow use with
   * HashTable without function pointer casting.  A valid
   * VariantType must be provided.
   * 
   * Since 2.24
   * @param type A VariantType.
   * @return The hash value.
   */
  guint hash() const;
  
  /** Compares @a type1 and @a type2 for equality.
   * 
   * Only returns <tt>true</tt> if the types are exactly equal.  Even if one type
   * is an indefinite type and the other is a subtype of it, <tt>false</tt> will
   * be returned if they are not exactly equal.  If you want to check for
   * subtypes, use g_variant_type_is_subtype_of().
   * 
   * The argument types of @a type1 and @a type2 are only #gconstpointer to
   * allow use with HashTable without function pointer casting.  For
   * both arguments, a valid VariantType must be provided.
   * 
   * Since 2.24
   * @param type1 A VariantType.
   * @param type2 A VariantType.
   * @return <tt>true</tt> if @a type1 and @a type2 are exactly equal.
   */
  bool equal(const VariantType& other) const;

  
  /** Checks if @a type is a subtype of @a supertype.
   * 
   * This function returns <tt>true</tt> if @a type is a subtype of @a supertype.  All
   * types are considered to be subtypes of themselves.  Aside from that,
   * only indefinite types can have subtypes.
   * 
   * Since 2.24
   * @param supertype A VariantType.
   * @return <tt>true</tt> if @a type is a subtype of @a supertype.
   */
  bool is_subtype_of(const VariantType& supertype) const;

  
  /** Determines the element type of an array or maybe type.
   * 
   * This function may only be used with array or maybe types.
   * 
   * Since 2.24
   * @return The element type of @a type.
   */
  VariantType element() const;
  
  /** Determines the first item type of a tuple or dictionary entry
   * type.
   * 
   * This function may only be used with tuple or dictionary entry types,
   * but must not be used with the generic tuple type
   * VARIANT_TYPE_TUPLE.
   * 
   * In the case of a dictionary entry type, this returns the type of
   * the key.
   * 
   * <tt>0</tt> is returned in case of @a type being VARIANT_TYPE_UNIT.
   * 
   * This call, together with g_variant_type_next() provides an iterator
   * interface over tuple and dictionary entry types.
   * 
   * Since 2.24
   * @return The first item type of @a type, or <tt>0</tt>.
   */
  VariantType first() const;
  
  /** Determines the next item type of a tuple or dictionary entry
   * type.
   * 
   *  @a type must be the result of a previous call to
   * g_variant_type_first() or g_variant_type_next().
   * 
   * If called on the key type of a dictionary entry then this call
   * returns the value type.  If called on the value type of a dictionary
   * entry then this call returns <tt>0</tt>.
   * 
   * For tuples, <tt>0</tt> is returned when @a type is the last item in a tuple.
   * 
   * Since 2.24
   * @return The next VariantType after @a type, or <tt>0</tt>.
   */
  VariantType next () const;
  
  /** Determines the number of items contained in a tuple or
   * dictionary entry type.
   * 
   * This function may only be used with tuple or dictionary entry types,
   * but must not be used with the generic tuple type
   * VARIANT_TYPE_TUPLE.
   * 
   * In the case of a dictionary entry type, this function will always
   * return 2.
   * 
   * Since 2.24
   * @return The number of items in @a type.
   */
  gsize n_items() const;
  
  /** Determines the key type of a dictionary entry type.
   * 
   * This function may only be used with a dictionary entry type.  Other
   * than the additional restriction, this call is equivalent to
   * g_variant_type_first().
   * 
   * Since 2.24
   * @return The key type of the dictionary entry.
   */
  VariantType key() const;
  
  /** Determines the value type of a dictionary entry type.
   * 
   * This function may only be used with a dictionary entry type.
   * 
   * Since 2.24
   * @return The value type of the dictionary entry.
   */
  VariantType value() const;


};

extern const VariantType VariantTypeBool;

extern const VariantType VariantTypeByte;

extern const VariantType VariantTypeInt16;

extern const VariantType VariantTypeUint16;

extern const VariantType VariantTypeInt32;

extern const VariantType VariantTypeUint32;

extern const VariantType VariantTypeInt64;

extern const VariantType VariantTypeUint64;

extern const VariantType VariantTypeDouble;

extern const VariantType VariantTypeString;

extern const VariantType VariantTypeObjectPath;

extern const VariantType VariantTypeSignature;

extern const VariantType VariantTypeVariant;

extern const VariantType VariantTypeHandle;

extern const VariantType VariantTypeUnit;

extern const VariantType VariantTypeAny;

extern const VariantType VariantTypeBasic;

extern const VariantType VariantTypeMaybe;

extern const VariantType VariantTypeArray;

extern const VariantType VariantTypeTuple;

extern const VariantType VariantTypeDictEntry;

extern const VariantType VariantTypeDictionary;

extern const VariantType VariantTypeStringArray;

extern const VariantType VariantTypeByteString;

extern const VariantType VariantTypeByteStringArray;


} // namespace Glib


namespace Glib
{

  /** A Glib::wrap() method for this object.
   * 
   * @param object The C instance.
   * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
   * @result A C++ instance that wraps this C instance.
   *
   * @relates Glib::VariantType
   */
Glib::VariantType wrap(GVariantType* object, bool take_copy = false);

} // namespace Glib


#endif /* _GLIBMM_VARIANTTYPE_H */

