// Generated by gmmproc 2.38.1 -- DO NOT MODIFY!


#include <glibmm.h>

#include <libgdamm/sqlstatement.h>
#include <libgdamm/private/sqlstatement_p.h>


// -*- C++ -*- //

/* quarklist.ccg
 *
 * Copyright 2001      Free Software Foundation
 *
 * 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 <libgdamm/connection.h>
#include <libgda/sql-parser/gda-statement-struct.h>
#include <sql-parser/gda-sql-parser-enum-types.h>

namespace Gnome
{

namespace Gda
{

SqlStatement::SqlStatement(SqlStatementType type)
: gobject_(gda_sql_statement_new((GdaSqlStatementType)type))
{
}


bool SqlStatement::empty() const
{
  return !gobject_;
}

} // namespace Gda

} // namesoace Gnome

namespace
{
} // anonymous namespace

// static
GType Glib::Value<Gnome::Gda::SqlStatementType>::value_type()
{
  return gda_sql_statement_type_get_type();
}


namespace Glib
{

Gnome::Gda::SqlStatement wrap(GdaSqlStatement* object, bool take_copy)
{
  return Gnome::Gda::SqlStatement(object, take_copy);
}

} // namespace Glib


namespace Gnome
{

namespace Gda
{


// static
GType SqlStatement::get_type()
{
  return gda_sql_statement_get_type();
}

SqlStatement::SqlStatement()
:
  gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
{}

SqlStatement::SqlStatement(const SqlStatement& other)
:
  gobject_ ((other.gobject_) ? gda_sql_statement_copy(other.gobject_) : 0)
{}

SqlStatement::SqlStatement(GdaSqlStatement* gobject, bool make_a_copy)
:
  // For BoxedType wrappers, make_a_copy is true by default.  The static
  // BoxedType wrappers must always take a copy, thus make_a_copy = true
  // ensures identical behaviour if the default argument is used.
  gobject_ ((make_a_copy && gobject) ? gda_sql_statement_copy(gobject) : gobject)
{}

SqlStatement& SqlStatement::operator=(const SqlStatement& other)
{
  SqlStatement temp (other);
  swap(temp);
  return *this;
}

SqlStatement::~SqlStatement()
{
  if(gobject_)
    gda_sql_statement_free(gobject_);
}

void SqlStatement::swap(SqlStatement& other)
{
  GdaSqlStatement *const temp = gobject_;
  gobject_ = other.gobject_;
  other.gobject_ = temp;
}

GdaSqlStatement* SqlStatement::gobj_copy() const
{
  return gda_sql_statement_copy(gobject_);
}


Glib::ustring SqlStatement::serialize() const
{
  return Glib::convert_return_gchar_ptr_to_ustring(gda_sql_statement_serialize(const_cast<GdaSqlStatement*>(gobj())));
}

SqlStatementType SqlStatement::string_to_type(const Glib::ustring& type)
{
  return ((SqlStatementType)(gda_sql_statement_string_to_type(type.c_str())));
}


bool SqlStatement::check_structure() const
{
  GError* gerror = 0;
  bool retvalue = gda_sql_statement_check_structure(const_cast<GdaSqlStatement*>(gobj()), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool SqlStatement::check_validity(const Glib::RefPtr<Connection>& cnc)
{
  GError* gerror = 0;
  bool retvalue = gda_sql_statement_check_validity(gobj(), Glib::unwrap(cnc), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

void SqlStatement::check_clean()
{
  gda_sql_statement_check_clean(gobj());
}

bool SqlStatement::normalize(const Glib::RefPtr<Connection>& cnc)
{
  GError* gerror = 0;
  bool retvalue = gda_sql_statement_normalize(gobj(), Glib::unwrap(cnc), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}


} // namespace Gda

} // namespace Gnome


