// Generated by gtkmmproc -- DO NOT MODIFY!


#include <libgdamm/serverprovider.h>
#include <libgdamm/private/serverprovider_p.h>

/* $Id: serverprovider.ccg,v 1.5 2006/05/08 10:18:53 murrayc Exp $ */
// -*- C++ -*- // this is for the .ccg, I realize gensig puts one in

/* connection.cc
 * 
 * Copyright 2001      Free Software Foundation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library 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/gda-enum-types.h>

namespace Gnome
{

namespace Gda
{


#ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<DataModel> ServerProvider::get_schema(const Glib::RefPtr<Connection>& cnc, ConnectionSchema schema)
#else
Glib::RefPtr<DataModel> ServerProvider::get_schema(const Glib::RefPtr<Connection>& cnc, ConnectionSchema schema, std::auto_ptr<Glib::Error>& error)
#endif // GLIBMM_EXCEPTIONS_ENABLED
{
  GError *gerror = 0;
  Glib::RefPtr<DataModel> retvalue = Glib::wrap(gda_server_provider_get_schema(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc), ((GdaConnectionSchema)(schema)), 0, &(gerror)));

#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror) ::Glib::Error::throw_exception(gerror);
#else
  if(gerror) error = ::Glib::Error::throw_exception(gerror);
#endif // GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;
}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<const DataModel> ServerProvider::get_schema(const Glib::RefPtr<Connection>& cnc, ConnectionSchema schema) const
#else
Glib::RefPtr<const DataModel> ServerProvider::get_schema(const Glib::RefPtr<Connection>& cnc, ConnectionSchema schema, std::auto_ptr<Glib::Error>& error) const
#endif // GLIBMM_EXCEPTIONS_ENABLED
{
  ServerProvider* this_nonconst = const_cast<ServerProvider*>(this);

#ifdef GLIBMM_EXCEPTIONS_ENABLED
  return this_nonconst->get_schema(cnc, schema);
#else
  return this_nonconst->get_schema(cnc, schema, error);
#endif
}


} // namespace Gda

} // namespace Gnome


namespace
{
} // anonymous namespace

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


namespace Glib
{

Glib::RefPtr<Gnome::Gda::ServerProvider> wrap(GdaServerProvider* object, bool take_copy)
{
  return Glib::RefPtr<Gnome::Gda::ServerProvider>( dynamic_cast<Gnome::Gda::ServerProvider*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} /* namespace Glib */


namespace Gnome
{

namespace Gda
{


/* The *_Class implementation: */

const Glib::Class& ServerProvider_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Class has to know the class init function to clone custom types.
    class_init_func_ = &ServerProvider_Class::class_init_function;

    // This is actually just optimized away, apparently with no harm.
    // Make sure that the parent type has been created.
    //CppClassParent::CppObjectType::get_type();

    // Create the wrapper type, with the same class/instance size as the base type.
    register_derived_type(gda_server_provider_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:

  }

  return *this;
}

void ServerProvider_Class::class_init_function(void* g_class, void* class_data)
{
  BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
  CppClassParent::class_init_function(klass, class_data);

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
}

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED


Glib::ObjectBase* ServerProvider_Class::wrap_new(GObject* object)
{
  return new ServerProvider((GdaServerProvider*)object);
}


/* The implementation: */

GdaServerProvider* ServerProvider::gobj_copy()
{
  reference();
  return gobj();
}

ServerProvider::ServerProvider(const Glib::ConstructParams& construct_params)
:
  Glib::Object(construct_params)
{

}

ServerProvider::ServerProvider(GdaServerProvider* castitem)
:
  Glib::Object((GObject*)(castitem))
{}

ServerProvider::~ServerProvider()
{}


ServerProvider::CppClassType ServerProvider::serverprovider_class_; // initialize static member

GType ServerProvider::get_type()
{
  return serverprovider_class_.init().get_type();
}

GType ServerProvider::get_base_type()
{
  return gda_server_provider_get_type();
}


Glib::ustring ServerProvider::get_version() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gda_server_provider_get_version(const_cast<GdaServerProvider*>(gobj())));
}

bool ServerProvider::open_connection(const Glib::RefPtr<Connection>& cnc, GdaQuarkList * params, const Glib::ustring& username, const Glib::ustring& password)
{
  return gda_server_provider_open_connection(gobj(), Glib::unwrap(cnc), params, username.c_str(), password.c_str());
}

bool ServerProvider::close_connection(const Glib::RefPtr<Connection>& cnc)
{
  return gda_server_provider_close_connection(gobj(), Glib::unwrap(cnc));
}

Glib::ustring ServerProvider::get_server_version(const Glib::RefPtr<Connection>& cnc) const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gda_server_provider_get_server_version(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc)));
}

Glib::ustring ServerProvider::get_database(const Glib::RefPtr<Connection>& cnc) const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gda_server_provider_get_database(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc)));
}

bool ServerProvider::change_database(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name)
{
  return gda_server_provider_change_database(gobj(), Glib::unwrap(cnc), name.c_str());
}

const ServerProviderInfo* ServerProvider::get_info(const Glib::RefPtr<Connection>& cnc) const
{
  return static_cast<ServerProviderInfo*>(gda_server_provider_get_info(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc)));
}

bool ServerProvider::supports_operation(const Glib::RefPtr<Connection>& cnc, ServerOperationType type, const Glib::RefPtr<ParameterList>& options) const
{
  return gda_server_provider_supports_operation(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc), ((GdaServerOperationType)(type)), Glib::unwrap(options));
}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<ServerOperation> ServerProvider::create_operation(const Glib::RefPtr<Connection>& cnc, ServerOperationType type, const Glib::RefPtr<ParameterList>& options)
#else
Glib::RefPtr<ServerOperation> ServerProvider::create_operation(const Glib::RefPtr<Connection>& cnc, ServerOperationType type, const Glib::RefPtr<ParameterList>& options, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  Glib::RefPtr<ServerOperation> retvalue = Glib::wrap(gda_server_provider_create_operation(gobj(), Glib::unwrap(cnc), ((GdaServerOperationType)(type)), Glib::unwrap(options), &(gerror)));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::ustring ServerProvider::render_operation(const Glib::RefPtr<Connection>& cnc, const Glib::RefPtr<ServerOperation>& op)
#else
Glib::ustring ServerProvider::render_operation(const Glib::RefPtr<Connection>& cnc, const Glib::RefPtr<ServerOperation>& op, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(gda_server_provider_render_operation(gobj(), Glib::unwrap(cnc), Glib::unwrap(op), &(gerror)));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool ServerProvider::perform_operation(const Glib::RefPtr<Connection>& cnc, const Glib::RefPtr<ServerOperation>& op)
#else
bool ServerProvider::perform_operation(const Glib::RefPtr<Connection>& cnc, const Glib::RefPtr<ServerOperation>& op, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_server_provider_perform_operation(gobj(), Glib::unwrap(cnc), Glib::unwrap(op), &(gerror));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

Glib::ListHandle< Glib::RefPtr<DataModel> > ServerProvider::execute_command(const Glib::RefPtr<Connection>& cnc, const Command& cmd, const Glib::RefPtr<ParameterList>& params)
{
  return Glib::ListHandle< Glib::RefPtr<DataModel> >(gda_server_provider_execute_command(gobj(), Glib::unwrap(cnc), const_cast<GdaCommand*>((cmd).gobj()), Glib::unwrap(params)), Glib::OWNERSHIP_SHALLOW);
}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool ServerProvider::begin_transaction(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name, TransactionIsolation level)
#else
bool ServerProvider::begin_transaction(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name, TransactionIsolation level, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_server_provider_begin_transaction(gobj(), Glib::unwrap(cnc), name.c_str(), ((GdaTransactionIsolation)(level)), &(gerror));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool ServerProvider::commit_transaction(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name)
#else
bool ServerProvider::commit_transaction(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_server_provider_commit_transaction(gobj(), Glib::unwrap(cnc), name.c_str(), &(gerror));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool ServerProvider::rollback_transaction(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name)
#else
bool ServerProvider::rollback_transaction(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_server_provider_rollback_transaction(gobj(), Glib::unwrap(cnc), name.c_str(), &(gerror));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool ServerProvider::add_savepoint(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name)
#else
bool ServerProvider::add_savepoint(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_server_provider_add_savepoint(gobj(), Glib::unwrap(cnc), name.c_str(), &(gerror));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool ServerProvider::rollback_savepoint(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name)
#else
bool ServerProvider::rollback_savepoint(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_server_provider_rollback_savepoint(gobj(), Glib::unwrap(cnc), name.c_str(), &(gerror));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool ServerProvider::delete_savepoint(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name)
#else
bool ServerProvider::delete_savepoint(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& name, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_server_provider_delete_savepoint(gobj(), Glib::unwrap(cnc), name.c_str(), &(gerror));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

bool ServerProvider::supports_feature(const Glib::RefPtr<Connection>& cnc, ConnectionFeature feature) const
{
  return gda_server_provider_supports_feature(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc), ((GdaConnectionFeature)(feature)));
}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<DataModel> ServerProvider::get_schema(const Glib::RefPtr<Connection>& cnc, ConnectionSchema schema, const Glib::RefPtr<ParameterList>& params)
#else
Glib::RefPtr<DataModel> ServerProvider::get_schema(const Glib::RefPtr<Connection>& cnc, ConnectionSchema schema, const Glib::RefPtr<ParameterList>& params, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  Glib::RefPtr<DataModel> retvalue = Glib::wrap(gda_server_provider_get_schema(gobj(), Glib::unwrap(cnc), ((GdaConnectionSchema)(schema)), Glib::unwrap(params), &(gerror)));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<const DataModel> ServerProvider::get_schema(const Glib::RefPtr<Connection>& cnc, ConnectionSchema schema, const Glib::RefPtr<ParameterList>& params) const
#else
Glib::RefPtr<const DataModel> ServerProvider::get_schema(const Glib::RefPtr<Connection>& cnc, ConnectionSchema schema, const Glib::RefPtr<ParameterList>& params, std::auto_ptr<Glib::Error>& error) const
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  Glib::RefPtr<const DataModel> retvalue = Glib::wrap(gda_server_provider_get_schema(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc), ((GdaConnectionSchema)(schema)), Glib::unwrap(params), &(gerror)));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

Glib::ustring ServerProvider::value_to_sql_string(const Glib::RefPtr<Connection>& cnc, const Value& from) const
{
  return Glib::convert_return_gchar_ptr_to_ustring(gda_server_provider_value_to_sql_string(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc), const_cast<GValue*>((from).gobj())));
}

Glib::ustring ServerProvider::get_last_insert_id(const Glib::RefPtr<Connection>& cnc, const Glib::RefPtr<DataModel>& recset) const
{
  return Glib::convert_return_gchar_ptr_to_ustring(gda_server_provider_get_last_insert_id(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc), Glib::unwrap(recset)));
}

Glib::ustring ServerProvider::escape_string(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& str)
{
  return Glib::convert_return_gchar_ptr_to_ustring(gda_server_provider_escape_string(gobj(), Glib::unwrap(cnc), str.c_str()));
}

Glib::ustring ServerProvider::unescape_string(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& str)
{
  return Glib::convert_return_gchar_ptr_to_ustring(gda_server_provider_unescape_string(gobj(), Glib::unwrap(cnc), str.c_str()));
}

Glib::RefPtr<Gda::Object> ServerProvider::execute_query(const Glib::RefPtr<Connection>& cnc, const Glib::RefPtr<Query>& query, const Glib::RefPtr<ParameterList>& params)
{
  return Glib::wrap(gda_server_provider_execute_query(gobj(), Glib::unwrap(cnc), Glib::unwrap(query), Glib::unwrap(params)));
}

Glib::RefPtr<DataHandler> ServerProvider::get_data_handler_dbms(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& for_type)
{

  Glib::RefPtr<DataHandler> retvalue = Glib::wrap(gda_server_provider_get_data_handler_dbms(gobj(), Glib::unwrap(cnc), for_type.c_str()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

Glib::RefPtr<const DataHandler> ServerProvider::get_data_handler_dbms(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& for_type) const
{
  return const_cast<ServerProvider*>(this)->get_data_handler_dbms(cnc, for_type);
}

Glib::RefPtr<DataHandler> ServerProvider::get_data_handler_gtype(const Glib::RefPtr<Connection>& cnc, GType for_type)
{

  Glib::RefPtr<DataHandler> retvalue = Glib::wrap(gda_server_provider_get_data_handler_gtype(gobj(), Glib::unwrap(cnc), for_type));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

Glib::RefPtr<const DataHandler> ServerProvider::get_data_handler_gtype(const Glib::RefPtr<Connection>& cnc, GType for_type) const
{
  return const_cast<ServerProvider*>(this)->get_data_handler_gtype(cnc, for_type);
}

Glib::ustring ServerProvider::get_default_dbms_type(const Glib::RefPtr<Connection>& cnc, GType type)
{
  return Glib::convert_const_gchar_ptr_to_ustring(gda_server_provider_get_default_dbms_type(gobj(), Glib::unwrap(cnc), type));
}


#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED


} // namespace Gda

} // namespace Gnome


