// Generated by gtkmmproc -- DO NOT MODIFY!


#include <glibmm.h>

#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 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 <libgdamm/sqlparser.h>
#include <libgda/gda-enum-types.h>
#include <libgda/gda-server-provider.h>
#include <libgda/gda-server-provider-extra.h>

namespace Gnome
{

namespace Gda
{

Value ServerProvider::string_to_value(const Glib::RefPtr<Connection>& cnc, 
                                                const Glib::ustring& string, 
                                                GType prefered_type, 
                                                Glib::ustring& dbms_type) const
{
  Value retval;
  gchar* dmbs_type_c = NULL;
  GValue* value = gda_server_provider_string_to_value(const_cast<GdaServerProvider*>(gobj()),
                                                      cnc->gobj(),
                                                      string.c_str(),
                                                      prefered_type,
                                                      &dmbs_type_c);
  retval.init(value);
  g_free(value);
  value = NULL;

  if(dmbs_type_c)
  {
    dbms_type = dmbs_type_c;
    g_free(dmbs_type_c);
  }

  return retval;
}

Glib::RefPtr<ServerOperation> ServerProvider::create_operation(const Glib::RefPtr<Connection>& cnc, ServerOperationType type)
{
  GError* gerror = 0;
  Glib::RefPtr<ServerOperation> retvalue = Glib::wrap(gda_server_provider_create_operation(gobj(), Glib::unwrap(cnc), ((GdaServerOperationType)(type)), 0, &(gerror)));

  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}

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

} // namespace Gda

} // namespace Gnome


namespace
{
} // anonymous namespace


Gnome::Gda::ServerProviderError::ServerProviderError(Gnome::Gda::ServerProviderError::Code error_code, const Glib::ustring& error_message)
:
  Glib::Error (GDA_SERVER_PROVIDER_ERROR, error_code, error_message)
{}

Gnome::Gda::ServerProviderError::ServerProviderError(GError* gobject)
:
  Glib::Error (gobject)
{}

Gnome::Gda::ServerProviderError::Code Gnome::Gda::ServerProviderError::code() const
{
  return static_cast<Code>(Glib::Error::code());
}

void Gnome::Gda::ServerProviderError::throw_func(GError* gobject)
{
  throw Gnome::Gda::ServerProviderError(gobject);
}

// static
GType Glib::Value<Gnome::Gda::ServerProviderError::Code>::value_type()
{
  return gda_server_provider_error_get_type();
}

// static
GType Glib::Value<Gnome::Gda::ConnectionFeature>::value_type()
{
  return gda_connection_feature_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);


}


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())));
}

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)));
}

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

Glib::RefPtr<ServerOperation> ServerProvider::create_operation(const Glib::RefPtr<Connection>& cnc, ServerOperationType type, const Glib::RefPtr<Set>& options)
{
  GError* gerror = 0;
  Glib::RefPtr<ServerOperation> retvalue = Glib::wrap(gda_server_provider_create_operation(gobj(), Glib::unwrap(cnc), ((GdaServerOperationType)(type)), Glib::unwrap(options), &(gerror)));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;

}

Glib::ustring ServerProvider::render_operation(const Glib::RefPtr<Connection>& cnc, const Glib::RefPtr<ServerOperation>& op)
{
  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)));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;

}

bool ServerProvider::perform_operation(const Glib::RefPtr<Connection>& cnc, const Glib::RefPtr<ServerOperation>& op)
{
  GError* gerror = 0;
  bool retvalue = gda_server_provider_perform_operation(gobj(), Glib::unwrap(cnc), Glib::unwrap(op), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  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)));
}

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::escape_string(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& str) const
{
  return Glib::convert_return_gchar_ptr_to_ustring(gda_server_provider_escape_string(const_cast<GdaServerProvider*>(gobj()), Glib::unwrap(cnc), str.c_str()));
}

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

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_g_type(const Glib::RefPtr<Connection>& cnc, GType for_type)
{

  Glib::RefPtr<DataHandler> retvalue = Glib::wrap(gda_server_provider_get_data_handler_g_type(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_g_type(const Glib::RefPtr<Connection>& cnc, GType for_type) const
{
  return const_cast<ServerProvider*>(this)->get_data_handler_g_type(cnc, for_type);
}

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

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

Glib::RefPtr<SqlParser> ServerProvider::create_parser(const Glib::RefPtr<Connection>& cnc)
{
  return Glib::wrap(gda_server_provider_create_parser(gobj(), Glib::unwrap(cnc)));
}

Glib::RefPtr<DataHandler> ServerProvider::get_data_handler_default(const Glib::RefPtr<Connection>& cnc, GType type, const Glib::ustring& dbms_type)
{
  return Glib::wrap(gda_server_provider_get_data_handler_default(gobj(), Glib::unwrap(cnc), type, dbms_type.c_str()));
}

std::string ServerProvider::find_file(const std::string& inst_dir, const std::string& filename)
{
  return Glib::convert_return_gchar_ptr_to_stdstring(gda_server_provider_find_file(gobj(), inst_dir.c_str(), filename.c_str()));
}

bool ServerProvider::perform_operation_default(const Glib::RefPtr<Connection>& cnc, const Glib::RefPtr<ServerOperation>& op)
{
  GError* gerror = 0;
  bool retvalue = gda_server_provider_perform_operation_default(gobj(), Glib::unwrap(cnc), Glib::unwrap(op), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;

}


} // namespace Gda

} // namespace Gnome


