// Generated by gtkmmproc -- DO NOT MODIFY!


#include <libgdamm/datasourceinfo.h>
#include <libgdamm/private/datasourceinfo_p.h>

/* $Id: datasourceinfo.ccg,v 1.3 2006/10/21 14:40:28 murrayc Exp $ */
// -*- C++ -*- //

/* datasourceinfo.cc
 * 
 * Copyright 2003 libgdamm Development Team
 *
 * 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 <libgda/gda-config.h> //For GdaDataSourceInfo
#include <libgda/gda-enum-types.h>

namespace Gnome
{

namespace Gda
{

DataSourceInfo::DataSourceInfo()
{
  gobject_ = g_new0 (GdaDataSourceInfo, 1);

  set_cnc_string(""); //libgda prints a warning if this is NULL.
}
 
DataSourceInfo::operator bool() const
{
  return gobj() != 0;
}

void DataSourceInfo::set_name(const Glib::ustring& value)
{
  if(gobj()->name)
  {
    g_free(gobj()->name);
    gobj()->name = 0;
  }
    
  gobj()->name = g_strdup( (value).c_str() );
}

void DataSourceInfo::set_provider(const Glib::ustring& value)
{
  if(gobj()->provider)
  {
    g_free(gobj()->provider);
    gobj()->provider = 0;
  }
  
  gobj()->provider = g_strdup( (value).c_str() );
}

void DataSourceInfo::set_cnc_string(const Glib::ustring& value)
{
  if(gobj()->cnc_string)
  {
    g_free(gobj()->cnc_string);
    gobj()->cnc_string = 0;
  }
  
  gobj()->cnc_string = g_strdup( (value).c_str() );
}

void DataSourceInfo::set_description(const Glib::ustring& value)
{
  if(gobj()->description)
  {
    g_free(gobj()->description);
    gobj()->description = 0;
  }
  
  gobj()->description = g_strdup( (value).c_str() );
}


void DataSourceInfo::set_username(const Glib::ustring& value)
{
  if(gobj()->username)
  {
    g_free(gobj()->username);
    gobj()->username = 0;
  }
  
  gobj()->username = g_strdup( (value).c_str() );
}


void DataSourceInfo::set_password(const Glib::ustring& value)
{
  if(gobj()->password)
  {
    g_free(gobj()->password);
    gobj()->password = 0;
  }
  
  gobj()->password = g_strdup( (value).c_str() );
}


} //namespace Gda

} // namespace Gnome


namespace
{
} // anonymous namespace


namespace Glib
{

Gnome::Gda::DataSourceInfo wrap(GdaDataSourceInfo* object, bool take_copy /* = false */)
{
  return Gnome::Gda::DataSourceInfo(object, take_copy);
}

} // namespace Glib


namespace Gnome
{

namespace Gda
{


DataSourceInfo::DataSourceInfo(const DataSourceInfo& src)
:
  gobject_ ((src.gobject_) ? gda_data_source_info_copy(src.gobject_) : 0)
{}

DataSourceInfo::DataSourceInfo(GdaDataSourceInfo* castitem, bool make_a_copy /* = false */)
{
  if(!make_a_copy)
  {
    // It was given to us by a function which has already made a copy for us to keep.
    gobject_ = castitem;
  }
  else
  {
    // We are probably getting it via direct access to a struct,
    // so we can not just take it - we have to take a copy of it.
    if(castitem)
      gobject_ = gda_data_source_info_copy(castitem);
    else
      gobject_ = 0;
  }
}

DataSourceInfo& DataSourceInfo::operator=(const DataSourceInfo& src)
{
  GdaDataSourceInfo *const new_gobject = (src.gobject_) ? gda_data_source_info_copy(src.gobject_) : 0;

  if(gobject_)
    gda_data_source_info_free(gobject_);

  gobject_ = new_gobject;

  return *this;
}

DataSourceInfo::~DataSourceInfo()
{
  if(gobject_)
    gda_data_source_info_free(gobject_);
}

GdaDataSourceInfo* DataSourceInfo::gobj_copy() const
{
  return gda_data_source_info_copy(gobject_);
}


 Glib::ustring DataSourceInfo::get_name() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gobj()->name);
}
 
 Glib::ustring DataSourceInfo::get_provider() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gobj()->provider);
}
 
 Glib::ustring DataSourceInfo::get_cnc_string() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gobj()->cnc_string);
}
 
 Glib::ustring DataSourceInfo::get_description() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gobj()->description);
}
 
 Glib::ustring DataSourceInfo::get_username() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gobj()->username);
}
 
 Glib::ustring DataSourceInfo::get_password() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gobj()->password);
}
 

} // namespace Gda

} // namespace Gnome


