upgrade to glibmm 2.16

git-svn-id: svn://localhost/ardour2/branches/3.0@5303 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2009-07-02 13:12:38 +00:00
parent 5b97b13766
commit e916ac2821
211 changed files with 26478 additions and 4168 deletions

View file

@ -3,6 +3,7 @@
sublib_name = glibmm
sublib_namespace = Glib
sublib_parentdir = glibmm
files_defs = glib.defs glib_enums.defs glib_functions.defs gobject.defs gobject_enums.defs gobject_functions.defs gmodule_enums.defs gmodule_functions.defs glib_docs.xml glib_docs_override.xml
include $(top_srcdir)/build_shared/Makefile_gensrc.am_fragment

View file

@ -1,8 +1,8 @@
# Makefile.in generated by automake 1.10 from Makefile.am.
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -13,6 +13,8 @@
# PARTICULAR PURPOSE.
@SET_MAKE@
# Built files
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@ -31,16 +33,23 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/Makefile_list_of_hg.am_fragment \
DIST_COMMON = $(srcdir)/../src/Makefile_list_of_hg.am_fragment \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(top_srcdir)/build_shared/Makefile_build_gensrc.am_fragment \
$(top_srcdir)/build_shared/Makefile_gensrc.am_fragment \
$(top_srcdir)/build_shared/Makefile_gensrc_platform.am_fragment \
$(top_srcdir)/tools/Makefile_list_of_sources.am_fragment \
$(top_srcdir)/tools/m4/Makefile_list_of_sources.am_fragment \
$(top_srcdir)/tools/pm/Makefile_list_of_sources.am_fragment
subdir = glib/src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/scripts/c_std.m4 \
$(top_srcdir)/scripts/cxx.m4 $(top_srcdir)/scripts/cxx_std.m4 \
$(top_srcdir)/scripts/dk-feature.m4 \
$(top_srcdir)/scripts/docgen.m4 \
$(top_srcdir)/scripts/glibmm_check_perl.m4 \
$(top_srcdir)/scripts/macros.m4 \
$(top_srcdir)/scripts/reduced.m4 $(top_srcdir)/scripts/sun.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@ -71,8 +80,10 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DISABLE_DEPRECATED_API_CFLAGS = @DISABLE_DEPRECATED_API_CFLAGS@
DISABLE_DEPRECATED_CFLAGS = @DISABLE_DEPRECATED_CFLAGS@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@ -94,6 +105,8 @@ GMMPROC_DIR = @GMMPROC_DIR@
GREP = @GREP@
GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
GTHREAD_LIBS = @GTHREAD_LIBS@
GTKMMPROC_MERGECDOCS = @GTKMMPROC_MERGECDOCS@
GTKMM_DOXYGEN_INPUT = @GTKMM_DOXYGEN_INPUT@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@ -106,9 +119,11 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
M4 = @M4@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
@ -118,6 +133,7 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL_PATH = @PERL_PATH@
PKG_CONFIG = @PKG_CONFIG@
RANLIB = @RANLIB@
SED = @SED@
@ -174,11 +190,14 @@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
sublib_name = glibmm
sublib_namespace = Glib
sublib_parentdir = glibmm
files_defs = glib.defs glib_enums.defs glib_functions.defs gobject.defs gobject_enums.defs gobject_functions.defs gmodule_enums.defs gmodule_functions.defs glib_docs.xml glib_docs_override.xml
tools_dir = $(top_srcdir)/tools
tools_dir_m4 = $(top_srcdir)/tools/m4
tools_dir_pm = $(top_srcdir)/tools/pm
gensrc_destdir = $(srcdir)/../$(sublib_name)
@ -188,41 +207,84 @@ files_tools_m4 = base.m4 class_shared.m4 class_boxedtype.m4 class_boxedtype_stat
class_interface.m4 class_opaque_refcounted.m4 class_opaque_copyable.m4 \
gerror.m4 \
compare.m4 convert.m4 convert_base.m4 convert_gtkmm.m4 convert_atk.m4 convert_gdk.m4 \
convert_glib.m4 convert_gtk.m4 convert_pango.m4 ctor.m4 doc.m4 enum.m4 list.m4 member.m4 \
convert_glib.m4 convert_gio.m4 convert_gtk.m4 convert_pango.m4 ctor.m4 doc.m4 enum.m4 list.m4 member.m4 \
method.m4 property.m4 signal.m4 vfunc.m4
files_tools_pm = DocsParser.pm GtkDefs.pm Enum.pm Function.pm FunctionBase.pm Object.pm Output.pm Property.pm Util.pm WrapParser.pm
files_tools_genwrap = generate_wrap_init.pl
files_tools_perl = $(files_tools_genwrap) gmmproc.in
tools_m4 = $(files_tools_m4:%.m4=$(tools_dir_m4)/%.m4)
tools_pm = $(files_tools_pm:%.pm=$(tools_dir_pm)/%.pm)
files_posix_hg =
files_win32_hg =
files_general_hg = convert.hg date.hg fileutils.hg iochannel.hg keyfile.hg markup.hg module.hg optioncontext.hg optionentry.hg optiongroup.hg regex.hg shell.hg spawn.hg thread.hg unicode.hg
files_all_hg = $(files_general_hg) $(files_posix_hg) $(files_win32_hg)
@OS_WIN32_FALSE@files_hg = $(files_general_hg) $(files_posix_hg)
@OS_WIN32_TRUE@files_hg = $(files_general_hg) $(files_win32_hg)
files_general_hg = checksum.hg convert.hg date.hg fileutils.hg iochannel.hg keyfile.hg markup.hg \
module.hg optioncontext.hg optionentry.hg optiongroup.hg regex.hg \
shell.hg spawn.hg thread.hg nodetree.hg unicode.hg uriutils.hg
files_general_deprecated_hg =
files_all_hg = \
$(files_posix_hg) \
$(files_win32_hg) \
$(files_general_hg) \
$(files_general_deprecated_hg)
@OS_WIN32_FALSE@files_hg = $(files_general_hg) $(files_posix_hg) $(files_general_deprecated_hg)
@OS_WIN32_TRUE@files_hg = $(files_general_hg) $(files_win32_hg) $(files_general_deprecated_hg)
files_built_cc = $(files_hg:.hg=.cc) wrap_init.cc
files_built_h = $(files_hg:.hg=.h)
files_all_built_cc = $(files_all_hg:.hg=.cc) wrap_init.cc
files_all_built_h = $(files_all_hg:.hg=.h)
# Extra files
files_all_extra_cc = \
$(sublib_files_extra_posix_cc) \
$(sublib_files_extra_win32_cc) \
$(sublib_files_extra_general_cc) \
$(sublib_files_extra_general_deprecated_cc)
files_all_extra_h = $(sublib_files_extra_posix_h) \
$(sublib_files_extra_win32_h) $(sublib_files_extra_general_h) \
$(sublib_files_extra_general_deprecated_h) wrap_init.h
@OS_WIN32_FALSE@files_extra_cc = \
@OS_WIN32_FALSE@ $(sublib_files_extra_posix_cc) \
@OS_WIN32_FALSE@ $(sublib_files_extra_general_cc)
@OS_WIN32_TRUE@files_extra_cc = \
@OS_WIN32_TRUE@ $(sublib_files_extra_win32_cc) \
@OS_WIN32_TRUE@ $(sublib_files_extra_general_cc)
@OS_WIN32_FALSE@files_extra_h = $(sublib_files_extra_posix_h) \
@OS_WIN32_FALSE@ $(sublib_files_extra_general_h) wrap_init.h
@OS_WIN32_TRUE@files_extra_h = $(sublib_files_extra_win32_h) \
@OS_WIN32_TRUE@ $(sublib_files_extra_general_h) wrap_init.h
# tools_pm = $(files_tools_pm:%.pm=$(tools_dir_pm)/%.pm)
files_all_ccg = $(files_all_hg:%.hg=%.ccg)
files_h = $(files_all_hg:%.hg=$(gensrc_destdir)/%.h)
files_cc = $(files_all_hg:%.hg=$(gensrc_destdir)/%.cc)
files_stamp = $(files_all_hg:%.hg=$(stamp_dir)/stamp-%) \
$(glibmm_files_m4:%.m4=$(gensrc_destdir)/%)
#The gmmproc from this glibmm:
gmmproc_in = $(top_srcdir)/tools/gmmproc.in
gmmproc_path = $(top_builddir)/tools/gmmproc
# We use our own m4 and pm files as well as the ones installed by gtkmm:
# Our override m4 include seems to need to be before the default one.
gmmproc_args = -I $(tools_dir_m4) --defs $(srcdir)
run_gmmproc = $(PERL_PATH) -I$(tools_dir_pm) $(gmmproc_path) $(gmmproc_args)
gen_wrap_init_in = $(top_srcdir)/tools/generate_wrap_init.pl.in
gen_wrap_init_path = $(top_builddir)/tools/generate_wrap_init.pl
gen_wrap_init_args = --namespace=$(sublib_namespace)
gen_wrap_init_args = --namespace=$(sublib_namespace) --parent_dir=$(sublib_parentdir)
run_gen_wrap_init = $(PERL_PATH) $(gen_wrap_init_path) $(gen_wrap_init_args)
EXTRA_DIST = Makefile_list_of_hg.am_fragment $(files_defs) \
$(files_all_hg) $(files_all_ccg) $(glibmm_files_m4) \
template.macros.m4
sublib_srcdir = $(srcdir)/../src
files_hg_with_path = $(patsubst %.hg,$(sublib_srcdir)/%.hg,$(files_all_hg))
glibmm_files_m4 = signalproxy.h.m4 value_basictypes.cc.m4 value_basictypes.h.m4
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/build_shared/Makefile_gensrc.am_fragment $(top_srcdir)/tools/Makefile_list_of_sources.am_fragment $(top_srcdir)/tools/m4/Makefile_list_of_sources.am_fragment $(top_srcdir)/tools/pm/Makefile_list_of_sources.am_fragment $(srcdir)/Makefile_list_of_hg.am_fragment $(top_srcdir)/build_shared/Makefile_gensrc_platform.am_fragment $(am__configure_deps)
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/build_shared/Makefile_gensrc.am_fragment $(top_srcdir)/tools/Makefile_list_of_sources.am_fragment $(top_srcdir)/tools/m4/Makefile_list_of_sources.am_fragment $(top_srcdir)/tools/pm/Makefile_list_of_sources.am_fragment $(srcdir)/../src/Makefile_list_of_hg.am_fragment $(top_srcdir)/build_shared/Makefile_build_gensrc.am_fragment $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@ -389,11 +451,11 @@ uninstall-am:
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
$(stamp_dir)/stamp-%: %.hg %.ccg $(gmmproc_in) $(tools_m4) $(tools_pm) $(files_defs)
$(stamp_dir)/stamp-%: %.hg %.ccg $(tools_m4) $(files_defs)
$(run_gmmproc) $(notdir $*) $(srcdir) $(gensrc_destdir)
@echo 'timestamp' >$@
@echo 'timestamp' > $@
$(gensrc_destdir)/wrap_init.cc: $(gen_wrap_init_in) $(files_all_hg)
$(gensrc_destdir)/wrap_init.cc: $(gen_wrap_init_path) $(files_hg_with_path)
$(run_gen_wrap_init) $(files_all_hg:%.hg=$(srcdir)/%.hg) >$@
create-stamp-dir:
@ -404,8 +466,6 @@ create-stamp-dir:
maintainer-clean-local:
rm -rf $(stamp_dir)
.PHONY: create-stamp-dir
$(gensrc_destdir)/%.cc: %.cc.m4 template.macros.m4
$(M4) -I$(srcdir) $< >$@

View file

@ -5,4 +5,9 @@
files_posix_hg =
files_win32_hg =
files_general_hg = convert.hg date.hg fileutils.hg iochannel.hg keyfile.hg markup.hg module.hg optioncontext.hg optionentry.hg optiongroup.hg regex.hg shell.hg spawn.hg thread.hg unicode.hg
files_general_hg = checksum.hg convert.hg date.hg fileutils.hg iochannel.hg keyfile.hg markup.hg \
module.hg optioncontext.hg optionentry.hg optiongroup.hg regex.hg \
shell.hg spawn.hg thread.hg nodetree.hg unicode.hg uriutils.hg
files_general_deprecated_hg =
include $(top_srcdir)/build_shared/Makefile_build_gensrc.am_fragment

View file

@ -0,0 +1,53 @@
/* $Id$ */
/* Copyright (C) 2002 The gtkmm 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 <glibmm/utility.h>
#include <glibmm/checksum.h>
namespace Glib
{
Checksum::Checksum(ChecksumType type)
: gobject_(g_checksum_new((GChecksumType)type))
{
}
Checksum::operator bool() const
{
return gobject_ != 0;
}
gssize Checksum::get_length(ChecksumType checksum_type)
{
return g_checksum_type_get_length((GChecksumType)checksum_type);
}
std::string Checksum::compute_checksum(ChecksumType type, const std::string& data)
{
return Glib::convert_return_gchar_ptr_to_ustring(g_compute_checksum_for_string(((GChecksumType)type), data.c_str(), data.size()));
}
void Checksum::update(const std::string& data)
{
g_checksum_update(gobj(), (const guchar*)data.c_str(), data.size());
}
} // Glib namespace

View file

@ -0,0 +1,116 @@
/* $Id$ */
/* Copyright (C) 2002 The gtkmm 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.
*/
_DEFS(glibmm,glib)
#include <glib.h>
#include <string>
#ifndef DOXYGEN_SHOUD_SKIP_THIS
extern "C" { typedef struct _GChecksum GChecksum; }
#endif
namespace Glib
{
/** Computes the checksum for data.
* This is a generic API for computing checksums (or "digests") for a sequence of arbitrary bytes,
* using various hashing algorithms like MD5, SHA-1 and SHA-256. Checksums are commonly used in various environments and specifications.
*
* glibmm supports incremental checksums by calling update() as long as there's data available and then using get_string()
* or get_digest() to compute the checksum and return it either as a string in hexadecimal form, or as a raw sequence of bytes.
* To compute the checksum for binary blobs and NULL-terminated strings in one go, use the static compute_checksum() convenience functions().
*
* @newin2p16
*/
class Checksum
{
_CLASS_OPAQUE_COPYABLE(Checksum, GChecksum, NONE, g_checksum_copy, g_checksum_free)
_IGNORE(g_checksum_copy, g_checksum_free)
public:
/**
* @class ChecksumType:
* @a CHECKSUM_MD5: Use the MD5 hashing algorithm
* @a CHECKSUM_SHA1: Use the SHA-1 hashing algorithm
* @a CHECKSUM_SHA256: Use the SHA-256 hashing algorithm
*
* The hashing algorithm to be used by Checksum when performing the
* digest of some data.
*
* Note that the ChecksumType enumeration may be extended at a later
* date to include new hashing algorithm types.
*
* @newin2p16
*/
_WRAP_ENUM(ChecksumType, GChecksumType, NO_GTYPE)
#m4 _CONVERSION(`ChecksumType', `GChecksumType', `(($2)$3)')
/** Creates a new Checksum, using the checksum algorithm @a checksum_type.
* If the checksum_type is not known, then operator bool() will return false.
*
* @param type checksum type, one of defined above.
*/
explicit Checksum(ChecksumType checksum_type);
/** Returns true if the Checksum object is valid.
* This will return false, for instance, if an unsupported checksum type was provided to the constructor.
*/
operator bool() const;
_WRAP_METHOD(void reset(), g_checksum_reset)
_WRAP_METHOD(void update(const guchar* data, gsize length), g_checksum_update)
/** Feeds data into an existing Checksum.
* The checksum must still be open, that is get_string() or get_digest() must not have been called on the checksum.
*
* @param data Buffer used to compute the checksum
*/
void update(const std::string& data);
_WRAP_METHOD(void get_digest(guint8 *buffer, gsize *digest_len) const, g_checksum_get_digest)
_WRAP_METHOD(std::string get_string() const, g_checksum_get_string)
_WRAP_METHOD(static std::string compute_checksum(ChecksumType type, const guchar* data, gsize length), g_compute_checksum_for_data)
/** Computes the checksum of a string.
*
* @param checksum_type A ChecksumType
* @param str The string to compute the checksum of.
* @result The checksum as a hexadecimal string.
*/
static std::string compute_checksum(ChecksumType type, const std::string& str);
_IGNORE(g_compute_checksum_for_string)
//We don't use _WRAP_METHOD because this is not really a GCheckSum function:
/** Gets the length in bytes of digests of type @a checksum_type.
*
* @param checksum_type A ChecksumType.
* @result The checksum length, or -1 if @a checksum_type is not supported.
*/
static gssize get_length(ChecksumType checksum_type);
};
} //namespace Glib

View file

@ -4,23 +4,24 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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 <glib/gconvert.h>
#include <glib.h>
#include <glib/gunicode.h>
//#include <glib/gtestutils.h> //For g_assert() in glib >= 2.15.0
//#include <glib/gmessages.h> //For g_assert() in glib < 2.15.0
#include <glib.h> //For g_assert() in all versions of glib.
#include <glibmm/utility.h>

View file

@ -3,23 +3,23 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
_DEFS(glibmm,glib)
#include <glib/gtypes.h> /* for gsize */
#include <glib.h> /* for gsize */
#include <glibmm/error.h>
#include <glibmm/ustring.h>

View file

@ -4,22 +4,23 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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 <glib/gmem.h>
#include <glib.h>
//#include <glib/gtestutils.h> //For g_assert() in glib >= 2.15.0
//#include <glib/gmessages.h> //For g_assert() in glib < 2.15.0
#include <glib.h> //For g_assert() in all versions of glib.
#include <ctime>
#include <algorithm>
@ -55,6 +56,20 @@ Date::Date(const GDate& castitem)
gobject_ (castitem)
{}
Date::Date(const Date& other)
{
g_date_clear(&gobject_, 1);
g_date_set_julian(&gobject_, other.get_julian());
}
Date& Date::operator=(const Date& other)
{
if (&other != this)
g_date_set_julian(&gobject_, other.get_julian());
return *this;
}
void Date::clear()
{
g_date_clear(&gobject_, 1);

View file

@ -3,16 +3,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -25,8 +25,7 @@ _DEFS(glibmm,glib)
#include <glibmm/ustring.h>
#include <glib/gdate.h>
#include <glib/gtypes.h>
#include <glib.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C" { struct tm; }
@ -51,18 +50,63 @@ public:
static const Year BAD_YEAR = 0;
static const guint32 BAD_JULIAN = 0;
/** Construct an undefined date.
*/
Date();
/** Construct a date with the given day, month and year.
* @param day The day.
* @param month The month.
* @param year The year.
*/
Date(Day day, Month month, Year year);
/** Construct a date from a julian day.
* @param julian_day The julian day (guint32).
*/
explicit Date(guint32 julian_day);
#ifndef DOXYGEN_SHOULD_SKIP_THIS
explicit Date(const GDate& castitem);
#endif
void clear();
/** Clear the date. The cleared dates will not represent an existing date, but will not contain garbage.
* @param month Month to set.
/** Construct a Glib::Date by copying the contents of a GDate.
* @param castitem The GDate.
*
* @newin2p18
*/
explicit Date(const GDate& castitem);
/** Construct a Glib::Date from another.
* @param other the other Glib::Date.
*
* @newin2p18
*/
Date(const Date& other);
/** Assign another date to this one. For example:
* @code
* ...
* Glib::Date my_date;
* my_date = other_date;
* @endcode
*
* @param other The other Glib::Date.
*
* @newin2p18
*/
Date& operator=(const Date& other);
/// Provides access to the underlying C instance.
GDate* gobj() { return &gobject_; }
/// Provides access to the underlying C instance.
const GDate* gobj() const { return &gobject_; }
private:
GDate gobject_;
public:
/** Clear the date. The cleared dates will not represent an existing date,
* but will not contain garbage.
*/
void clear();
/** Parses a user-inputted string str, and try to figure out what date it represents, taking the current locale into account. If the string is successfully parsed, the date will be valid after the call. Otherwise, it will be invalid.
* This function is not appropriate for file formats and the like; it isn't very precise, and its exact behavior varies with the locale. It's intended to be a heuristic routine that guesses what the user means by a given string (and it does work pretty well in that capacity).
@ -110,6 +154,8 @@ public:
*/
void set_time(const GTimeVal& timeval);
/** Set this Glib::Date to the current time.
*/
void set_time_current();
/** Sets the month of the year. If the resulting day-month-year triplet is invalid, the date will be invalid.
@ -141,7 +187,6 @@ public:
//TODO: Why return Date& (which is always *this) from these methods?
//Isn't it enough to also change the current instance?
//Maybe we need a copy constructor too.
//murrayc
/** Add a number of days to a Date.
@ -369,14 +414,6 @@ public:
* @return true if the date is a valid one.
*/
static bool valid_dmy(Day day, Month month, Year year);
#ifndef DOXYGEN_SHOULD_SKIP_THIS
GDate* gobj() { return &gobject_; }
const GDate* gobj() const { return &gobject_; }
#endif
private:
GDate gobject_;
};

View file

@ -4,23 +4,21 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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 <glib/gdir.h>
#include <glib/gfileutils.h>
#include <glib/gstrfuncs.h>
#include <glib.h>
#include <glibmm/utility.h>
@ -52,7 +50,7 @@ Dir::~Dir()
std::string Dir::read_name()
{
const char *const name = g_dir_read_name(gobject_);
return (name) ? std::string(name) : std::string();
return Glib::convert_const_gchar_ptr_to_stdstring(name);
}
void Dir::rewind()

View file

@ -3,16 +3,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/

File diff suppressed because it is too large Load diff

View file

@ -147,5 +147,69 @@ Since: 2.14
</function>
<function name="g_key_file_load_from_file">
<description>
Loads a key file into an empty KeyFile instance.
If the file could not be loaded then a FileError or KeyFileError exception is thrown.
@throw Glib::FileError
@throw Glib::KeyFileError
</description>
<parameters>
<parameter name="key_file">
<parameter_description> an empty #GKeyFile struct
</parameter_description>
</parameter>
<parameter name="file">
<parameter_description> the path of a filename to load, in the GLib file name encoding
</parameter_description>
</parameter>
<parameter name="flags">
<parameter_description> flags from #GKeyFileFlags
</parameter_description>
</parameter>
<parameter name="error">
<parameter_description> return location for a #GError, or %NULL
</parameter_description>
</parameter>
</parameters>
<return> %TRUE if a key file could be loaded, %FALSE othewise
Since: 2.6
</return>
</function>
<function name="g_key_file_get_value">
<description>
Returns the value associated with @key under @group_name.
@throw Glib::FileError in the event the key cannot be found (with the Glib::KEY_FILE_ERROR_KEY_NOT_FOUND code).
@throw Glib::KeyFileError in the event that the @group_name cannot be found (with the Glib::KEY_FILE_ERROR_GROUP_NOT_FOUND).
</description>
<parameters>
<parameter name="key_file">
<parameter_description> a #GKeyFile
</parameter_description>
</parameter>
<parameter name="group_name">
<parameter_description> a group name
</parameter_description>
</parameter>
<parameter name="key">
<parameter_description> a key
</parameter_description>
</parameter>
<parameter name="error">
<parameter_description> return location for a #GError, or %NULL
</parameter_description>
</parameter>
</parameters>
<return> The value as a string.
Since: 2.6
</return>
</function>
</root>

View file

@ -1,4 +1,4 @@
;; From /opt/gnome218/include/glib-2.0/glib/gbookmarkfile.h
;; From /opt/gnome2/include/glib-2.0/glib/gbookmarkfile.h
(define-enum-extended BookmarkFileError
(in-module "G")
@ -15,7 +15,19 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gconvert.h
;; From /opt/gnome2/include/glib-2.0/glib/gchecksum.h
(define-enum-extended ChecksumType
(in-module "G")
(c-name "GChecksumType")
(values
'("md5" "G_CHECKSUM_MD5" "0")
'("sha1" "G_CHECKSUM_SHA1" "1")
'("sha256" "G_CHECKSUM_SHA256" "2")
)
)
;; From /opt/gnome2/include/glib-2.0/glib/gconvert.h
(define-enum-extended ConvertError
(in-module "G")
@ -30,7 +42,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gdate.h
;; From /opt/gnome2/include/glib-2.0/glib/gdate.h
(define-enum-extended DateDMY
(in-module "G")
@ -77,7 +89,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gfileutils.h
;; From /opt/gnome2/include/glib-2.0/glib/gfileutils.h
(define-enum-extended FileError
(in-module "G")
@ -123,7 +135,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/ghook.h
;; From /opt/gnome2/include/glib-2.0/glib/ghook.h
(define-flags-extended HookFlagMask
(in-module "G")
@ -135,7 +147,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/giochannel.h
;; From /opt/gnome2/include/glib-2.0/glib/giochannel.h
(define-enum-extended IOError
(in-module "G")
@ -206,7 +218,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gkeyfile.h
;; From /opt/gnome2/include/glib-2.0/glib/gkeyfile.h
(define-enum-extended KeyFileError
(in-module "G")
@ -231,7 +243,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gmarkup.h
;; From /opt/gnome2/include/glib-2.0/glib/gmarkup.h
(define-enum-extended MarkupError
(in-module "G")
@ -243,6 +255,7 @@
'("unknown-element" "G_MARKUP_ERROR_UNKNOWN_ELEMENT" "3")
'("unknown-attribute" "G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE" "4")
'("invalid-content" "G_MARKUP_ERROR_INVALID_CONTENT" "5")
'("missing-attribute" "G_MARKUP_ERROR_MISSING_ATTRIBUTE" "6")
)
)
@ -252,10 +265,24 @@
(values
'("do-not-use-this-unsupported-flag" "G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG" "1 << 0")
'("treat-cdata-as-text" "G_MARKUP_TREAT_CDATA_AS_TEXT" "1 << 1")
'("prefix-error-position" "G_MARKUP_PREFIX_ERROR_POSITION" "1 << 2")
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gmessages.h
(define-flags-extended MarkupCollectType
(in-module "G")
(c-name "GMarkupCollectType")
(values
'("invalid" "G_MARKUP_COLLECT_INVALID" "0")
'("string" "G_MARKUP_COLLECT_STRING" "1")
'("strdup" "G_MARKUP_COLLECT_STRDUP" "2")
'("boolean" "G_MARKUP_COLLECT_BOOLEAN" "3")
'("tristate" "G_MARKUP_COLLECT_TRISTATE" "4")
'("optional" "G_MARKUP_COLLECT_OPTIONAL" "1 << 16")
)
)
;; From /opt/gnome2/include/glib-2.0/glib/gmessages.h
(define-flags-extended LogLevelFlags
(in-module "G")
@ -273,7 +300,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gnode.h
;; From /opt/gnome2/include/glib-2.0/glib/gnode.h
(define-flags-extended TraverseFlags
(in-module "G")
@ -299,7 +326,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/goption.h
;; From /opt/gnome2/include/glib-2.0/glib/goption.h
(define-flags-extended OptionFlags
(in-module "G")
@ -341,7 +368,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gregex.h
;; From /opt/gnome2/include/glib-2.0/glib/gregex.h
(define-enum-extended RegexError
(in-module "G")
@ -351,6 +378,44 @@
'("optimize" "G_REGEX_ERROR_OPTIMIZE" "1")
'("replace" "G_REGEX_ERROR_REPLACE" "2")
'("match" "G_REGEX_ERROR_MATCH" "3")
'("internal" "G_REGEX_ERROR_INTERNAL" "4")
'("stray-backslash" "G_REGEX_ERROR_STRAY_BACKSLASH" "101")
'("missing-control-char" "G_REGEX_ERROR_MISSING_CONTROL_CHAR" "102")
'("unrecognized-escape" "G_REGEX_ERROR_UNRECOGNIZED_ESCAPE" "103")
'("quantifiers-out-of-order" "G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER" "104")
'("quantifier-too-big" "G_REGEX_ERROR_QUANTIFIER_TOO_BIG" "105")
'("unterminated-character-class" "G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS" "106")
'("invalid-escape-in-character-class" "G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS" "107")
'("range-out-of-order" "G_REGEX_ERROR_RANGE_OUT_OF_ORDER" "108")
'("nothing-to-repeat" "G_REGEX_ERROR_NOTHING_TO_REPEAT" "109")
'("unrecognized-character" "G_REGEX_ERROR_UNRECOGNIZED_CHARACTER" "112")
'("posix-named-class-outside-class" "G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS" "113")
'("unmatched-parenthesis" "G_REGEX_ERROR_UNMATCHED_PARENTHESIS" "114")
'("inexistent-subpattern-reference" "G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE" "115")
'("unterminated-comment" "G_REGEX_ERROR_UNTERMINATED_COMMENT" "118")
'("expression-too-large" "G_REGEX_ERROR_EXPRESSION_TOO_LARGE" "120")
'("memory-error" "G_REGEX_ERROR_MEMORY_ERROR" "121")
'("variable-length-lookbehind" "G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND" "125")
'("malformed-condition" "G_REGEX_ERROR_MALFORMED_CONDITION" "126")
'("too-many-conditional-branches" "G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES" "127")
'("assertion-expected" "G_REGEX_ERROR_ASSERTION_EXPECTED" "128")
'("unknown-posix-class-name" "G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME" "130")
'("posix-collating-elements-not-supported" "G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED" "131")
'("hex-code-too-large" "G_REGEX_ERROR_HEX_CODE_TOO_LARGE" "134")
'("invalid-condition" "G_REGEX_ERROR_INVALID_CONDITION" "135")
'("single-byte-match-in-lookbehind" "G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND" "136")
'("infinite-loop" "G_REGEX_ERROR_INFINITE_LOOP" "140")
'("missing-subpattern-name-terminator" "G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR" "142")
'("duplicate-subpattern-name" "G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME" "143")
'("malformed-property" "G_REGEX_ERROR_MALFORMED_PROPERTY" "146")
'("unknown-property" "G_REGEX_ERROR_UNKNOWN_PROPERTY" "147")
'("subpattern-name-too-long" "G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG" "148")
'("too-many-subpatterns" "G_REGEX_ERROR_TOO_MANY_SUBPATTERNS" "149")
'("invalid-octal-value" "G_REGEX_ERROR_INVALID_OCTAL_VALUE" "151")
'("too-many-branches-in-define" "G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE" "154")
'("define-repetion" "G_REGEX_ERROR_DEFINE_REPETION" "155")
'("inconsistent-newline-options" "G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS" "156")
'("missing-back-reference" "G_REGEX_ERROR_MISSING_BACK_REFERENCE" "157")
)
)
@ -391,7 +456,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gscanner.h
;; From /opt/gnome2/include/glib-2.0/glib/gscanner.h
(define-enum-extended ErrorType
(in-module "G")
@ -408,7 +473,38 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gshell.h
(define-enum-extended TokenType
(in-module "G")
(c-name "GTokenType")
(values
'("eof" "G_TOKEN_EOF" "0")
'("left-paren" "G_TOKEN_LEFT_PAREN" "'('")
'("right-paren" "G_TOKEN_RIGHT_PAREN" "')'")
'("left-curly" "G_TOKEN_LEFT_CURLY" "'{'")
'("right-curly" "G_TOKEN_RIGHT_CURLY" "']'")
'("left-brace" "G_TOKEN_LEFT_BRACE" "'['")
'("right-brace" "G_TOKEN_RIGHT_BRACE" "']'")
'("equal-sign" "G_TOKEN_EQUAL_SIGN" "'='")
'("comma" "G_TOKEN_COMMA" "','")
'("none" "G_TOKEN_NONE" "256")
'("error" "G_TOKEN_ERROR" "257")
'("char" "G_TOKEN_CHAR" "258")
'("binary" "G_TOKEN_BINARY" "259")
'("octal" "G_TOKEN_OCTAL" "260")
'("int" "G_TOKEN_INT" "261")
'("hex" "G_TOKEN_HEX" "262")
'("float" "G_TOKEN_FLOAT" "263")
'("string" "G_TOKEN_STRING" "264")
'("symbol" "G_TOKEN_SYMBOL" "265")
'("identifier" "G_TOKEN_IDENTIFIER" "266")
'("identifier-null" "G_TOKEN_IDENTIFIER_NULL" "267")
'("comment-single" "G_TOKEN_COMMENT_SINGLE" "268")
'("comment-multi" "G_TOKEN_COMMENT_MULTI" "269")
'("last" "G_TOKEN_LAST" "270")
)
)
;; From /opt/gnome2/include/glib-2.0/glib/gshell.h
(define-enum-extended ShellError
(in-module "G")
@ -420,7 +516,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gslice.h
;; From /opt/gnome2/include/glib-2.0/glib/gslice.h
(define-enum-extended SliceConfig
(in-module "G")
@ -435,7 +531,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gspawn.h
;; From /opt/gnome2/include/glib-2.0/glib/gspawn.h
(define-enum-extended SpawnError
(in-module "G")
@ -477,7 +573,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gstrfuncs.h
;; From /opt/gnome2/include/glib-2.0/glib/gstrfuncs.h
(define-flags-extended AsciiType
(in-module "G")
@ -497,7 +593,36 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gthread.h
;; From /opt/gnome2/include/glib-2.0/glib/gtestutils.h
(define-flags-extended TestTrapFlags
(in-module "G")
(c-name "GTestTrapFlags")
(values
'("silence-stdout" "G_TEST_TRAP_SILENCE_STDOUT" "1 << 7")
'("silence-stderr" "G_TEST_TRAP_SILENCE_STDERR" "1 << 8")
'("inherit-stdin" "G_TEST_TRAP_INHERIT_STDIN" "1 << 9")
)
)
(define-enum-extended TestLogType
(in-module "G")
(c-name "GTestLogType")
(values
'("none" "G_TEST_LOG_NONE" "0")
'("error" "G_TEST_LOG_ERROR" "1")
'("start-binary" "G_TEST_LOG_START_BINARY" "2")
'("list-case" "G_TEST_LOG_LIST_CASE" "3")
'("skip-case" "G_TEST_LOG_SKIP_CASE" "4")
'("start-case" "G_TEST_LOG_START_CASE" "5")
'("stop-case" "G_TEST_LOG_STOP_CASE" "6")
'("min-result" "G_TEST_LOG_MIN_RESULT" "7")
'("max-result" "G_TEST_LOG_MAX_RESULT" "8")
'("message" "G_TEST_LOG_MESSAGE" "9")
)
)
;; From /opt/gnome2/include/glib-2.0/glib/gthread.h
(define-enum-extended ThreadError
(in-module "G")
@ -528,7 +653,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gunicode.h
;; From /opt/gnome2/include/glib-2.0/glib/gunicode.h
(define-enum-extended UnicodeType
(in-module "G")
@ -682,6 +807,17 @@
'("phoenician" "G_UNICODE_SCRIPT_PHOENICIAN" "64")
'("phags-pa" "G_UNICODE_SCRIPT_PHAGS_PA" "65")
'("nko" "G_UNICODE_SCRIPT_NKO" "66")
'("kayah-li" "G_UNICODE_SCRIPT_KAYAH_LI" "67")
'("lepcha" "G_UNICODE_SCRIPT_LEPCHA" "68")
'("rejang" "G_UNICODE_SCRIPT_REJANG" "69")
'("sundanese" "G_UNICODE_SCRIPT_SUNDANESE" "70")
'("saurashtra" "G_UNICODE_SCRIPT_SAURASHTRA" "71")
'("cham" "G_UNICODE_SCRIPT_CHAM" "72")
'("ol-chiki" "G_UNICODE_SCRIPT_OL_CHIKI" "73")
'("vai" "G_UNICODE_SCRIPT_VAI" "74")
'("carian" "G_UNICODE_SCRIPT_CARIAN" "75")
'("lycian" "G_UNICODE_SCRIPT_LYCIAN" "76")
'("lydian" "G_UNICODE_SCRIPT_LYDIAN" "77")
)
)
@ -700,7 +836,7 @@
)
)
;; From /opt/gnome218/include/glib-2.0/glib/gutils.h
;; From /opt/gnome2/include/glib-2.0/glib/gutils.h
(define-enum-extended UserDirectory
(in-module "G")

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
;; From /home/murrayc/cvs/gnome212/glib/gmodule/gmodule.h
;; From /opt/gnome2/include/glib-2.0/gmodule.h
(define-flags-extended ModuleFlags
(in-module "G")

View file

@ -14,11 +14,7 @@
)
;; From /home/murrayc/cvs/gnome212/glib/gmodule/gmoduleconf.h
;; From /home/murrayc/cvs/gnome212/glib/gmodule/gmodule.h
;; From gmodule.h
(define-function g_module_supported
(c-name "g_module_supported")

View file

@ -1,4 +1,4 @@
;; From gobject/gparam.h
;; From /opt/gnome2/include/glib-2.0/gobject/gparam.h
(define-flags-extended ParamFlags
(in-module "G")
@ -9,11 +9,12 @@
'("construct" "G_PARAM_CONSTRUCT" "1 << 2")
'("construct-only" "G_PARAM_CONSTRUCT_ONLY" "1 << 3")
'("lax-validation" "G_PARAM_LAX_VALIDATION" "1 << 4")
'("private" "G_PARAM_PRIVATE" "1 << 5")
'("static-name" "G_PARAM_STATIC_NAME" "1 << 5")
'("static-blurb" "G_PARAM_STATIC_BLURB" "1 << 7")
)
)
;; From gobject/gsignal.h
;; From /opt/gnome2/include/glib-2.0/gobject/gsignal.h
(define-flags-extended SignalFlags
(in-module "G")
@ -51,7 +52,7 @@
)
)
;; From gobject/gtype.h
;; From /opt/gnome2/include/glib-2.0/gobject/gtype.h
(define-flags-extended TypeDebugFlags
(in-module "G")
@ -64,17 +65,23 @@
)
)
(define-enum-extended TypeFundamentalFlags
(define-flags-extended TypeFundamentalFlags
(in-module "G")
(c-name "GTypeFundamentalFlags")
(values
'("classed" "G_TYPE_FLAG_CLASSED" "1 << 0")
'("instantiatable" "G_TYPE_FLAG_INSTANTIATABLE" "1 << 1")
'("derivable" "G_TYPE_FLAG_DERIVABLE" "1 << 2")
'("deep-derivable" "G_TYPE_FLAG_DEEP_DERIVABLE" "1 << 3")
)
)
(define-enum-extended TypeFlags
(define-flags-extended TypeFlags
(in-module "G")
(c-name "GTypeFlags")
(values
'("abstract" "G_TYPE_FLAG_ABSTRACT" "1 << 4")
'("value-abstract" "G_TYPE_FLAG_VALUE_ABSTRACT" "1 << 5")
)
)

View file

@ -1,16 +1,22 @@
;; -*- scheme -*-
; object definitions ...
(define-object TypeModule
(in-module "G")
(define-object Module
(in-module "GType")
(parent "GObject")
(c-name "GTypeModule")
(gtype-id "G_TYPE_TYPE_MODULE")
)
(define-object Plugin
(in-module "GType")
(c-name "GTypePlugin")
(gtype-id "G_TYPE_TYPE_PLUGIN")
)
;; Enumerations and flags ...
(define-flags ParamFlags
(in-module "G")
(define-flags Flags
(in-module "GParam")
(c-name "GParamFlags")
(gtype-id "G_TYPE_PARAM_FLAGS")
(values
@ -19,12 +25,15 @@
'("construct" "G_PARAM_CONSTRUCT")
'("construct-only" "G_PARAM_CONSTRUCT_ONLY")
'("lax-validation" "G_PARAM_LAX_VALIDATION")
'("static-name" "G_PARAM_STATIC_NAME")
'("private" "G_PARAM_PRIVATE")
'("static-nick" "G_PARAM_STATIC_NICK")
'("static-blurb" "G_PARAM_STATIC_BLURB")
)
)
(define-flags SignalFlags
(in-module "G")
(define-flags Flags
(in-module "GSignal")
(c-name "GSignalFlags")
(gtype-id "G_TYPE_SIGNAL_FLAGS")
(values
@ -38,8 +47,8 @@
)
)
(define-flags ConnectFlags
(in-module "G")
(define-flags Flags
(in-module "GConnect")
(c-name "GConnectFlags")
(gtype-id "G_TYPE_CONNECT_FLAGS")
(values
@ -48,8 +57,8 @@
)
)
(define-flags SignalMatchType
(in-module "G")
(define-flags MatchType
(in-module "GSignal")
(c-name "GSignalMatchType")
(gtype-id "G_TYPE_SIGNAL_MATCH_TYPE")
(values
@ -62,8 +71,8 @@
)
)
(define-flags TypeDebugFlags
(in-module "G")
(define-flags DebugFlags
(in-module "GType")
(c-name "GTypeDebugFlags")
(gtype-id "G_TYPE_TYPE_DEBUG_FLAGS")
(values
@ -74,8 +83,8 @@
)
)
(define-flags TypeFundamentalFlags
(in-module "G")
(define-flags FundamentalFlags
(in-module "GType")
(c-name "GTypeFundamentalFlags")
(gtype-id "G_TYPE_TYPE_FUNDAMENTAL_FLAGS")
(values
@ -86,8 +95,8 @@
)
)
(define-flags TypeFlags
(in-module "G")
(define-flags Flags
(in-module "GType")
(c-name "GTypeFlags")
(gtype-id "G_TYPE_TYPE_FLAGS")
(values
@ -97,7 +106,16 @@
)
;; From gobject/gboxed.h
;; From gboxed.h
(define-function g_boxed_copy
(c-name "g_boxed_copy")
(return-type "gpointer")
(parameters
'("GType" "boxed_type")
'("gconstpointer" "src_boxed")
)
)
(define-function g_boxed_free
(c-name "g_boxed_free")
@ -148,6 +166,15 @@
)
)
(define-method take_boxed
(of-object "GValue")
(c-name "g_value_take_boxed")
(return-type "none")
(parameters
'("gconstpointer" "v_boxed")
)
)
(define-method set_boxed_take_ownership
(of-object "GValue")
(c-name "g_value_set_boxed_take_ownership")
@ -172,17 +199,38 @@
(return-type "GType")
)
(define-function g_date_get_type
(c-name "g_date_get_type")
(return-type "GType")
)
(define-function g_strv_get_type
(c-name "g_strv_get_type")
(return-type "GType")
)
(define-function g_gstring_get_type
(c-name "g_gstring_get_type")
(return-type "GType")
)
(define-function g_hash_table_get_type
(c-name "g_hash_table_get_type")
(return-type "GType")
)
(define-function g_regex_get_type
(c-name "g_regex_get_type")
(return-type "GType")
)
;; From gobject/gclosure.h
;; From gclosure.h
(define-function g_cclosure_new
(c-name "g_cclosure_new")
(is-constructor-of "GCclosure")
(return-type "GClosure*")
(parameters
'("GCallback" "callback_func")
@ -203,6 +251,7 @@
(define-function g_signal_type_cclosure_new
(c-name "g_signal_type_cclosure_new")
(is-constructor-of "GSignalTypeCclosure")
(return-type "GClosure*")
(parameters
'("GType" "itype")
@ -328,7 +377,7 @@
;; From gobject/genums.h
;; From genums.h
(define-function g_enum_get_value
(c-name "g_enum_get_value")
@ -454,11 +503,16 @@
;; From gobject/gmarshal.h
;; From gmarshal.h
;; From gobject/gobject.h
;; From gobject.h
(define-function g_initially_unowned_get_type
(c-name "g_initially_unowned_get_type")
(return-type "GType")
)
(define-method install_property
(of-object "GObjectClass")
@ -479,6 +533,57 @@
)
)
(define-method list_properties
(of-object "GObjectClass")
(c-name "g_object_class_list_properties")
(return-type "GParamSpec**")
(parameters
'("guint*" "n_properties")
)
)
(define-method override_property
(of-object "GObjectClass")
(c-name "g_object_class_override_property")
(return-type "none")
(parameters
'("guint" "property_id")
'("const-gchar*" "name")
)
)
(define-function g_object_interface_install_property
(c-name "g_object_interface_install_property")
(return-type "none")
(parameters
'("gpointer" "g_iface")
'("GParamSpec*" "pspec")
)
)
(define-function g_object_interface_find_property
(c-name "g_object_interface_find_property")
(return-type "GParamSpec*")
(parameters
'("gpointer" "g_iface")
'("const-gchar*" "property_name")
)
)
(define-function g_object_interface_list_properties
(c-name "g_object_interface_list_properties")
(return-type "GParamSpec**")
(parameters
'("gpointer" "g_iface")
'("guint*" "n_properties_p")
)
)
(define-function g_object_get_type
(c-name "g_object_get_type")
(return-type "GType")
)
(define-function g_object_new
(c-name "g_object_new")
(return-type "gpointer")
@ -610,6 +715,22 @@
(return-type "none")
)
(define-function g_object_is_floating
(c-name "g_object_is_floating")
(return-type "gboolean")
(parameters
'("gpointer" "object")
)
)
(define-function g_object_ref_sink
(c-name "g_object_ref_sink")
(return-type "gpointer")
(parameters
'("gpointer" "object")
)
)
(define-function g_object_ref
(c-name "g_object_ref")
(return-type "gpointer")
@ -664,6 +785,26 @@
)
)
(define-method add_toggle_ref
(of-object "GObject")
(c-name "g_object_add_toggle_ref")
(return-type "none")
(parameters
'("GToggleNotify" "notify")
'("gpointer" "data")
)
)
(define-method remove_toggle_ref
(of-object "GObject")
(c-name "g_object_remove_toggle_ref")
(return-type "none")
(parameters
'("GToggleNotify" "notify")
'("gpointer" "data")
)
)
(define-method get_qdata
(of-object "GObject")
(c-name "g_object_get_qdata")
@ -796,7 +937,7 @@
(define-method dup_object
(of-object "GValue")
(c-name "g_value_dup_object")
(return-type "GObject*")
(return-type "gpointer")
)
(define-function g_signal_connect_object
@ -811,12 +952,27 @@
)
)
(define-method force_floating
(of-object "GObject")
(c-name "g_object_force_floating")
(return-type "none")
)
(define-method run_dispose
(of-object "GObject")
(c-name "g_object_run_dispose")
(return-type "none")
)
(define-method take_object
(of-object "GValue")
(c-name "g_value_take_object")
(return-type "none")
(parameters
'("gpointer" "v_object")
)
)
(define-method set_object_take_ownership
(of-object "GValue")
(c-name "g_value_set_object_take_ownership")
@ -826,9 +982,18 @@
)
)
(define-function g_object_compat_control
(c-name "g_object_compat_control")
(return-type "gsize")
(parameters
'("gsize" "what")
'("gpointer" "data")
)
)
;; From gobject/gparam.h
;; From gparam.h
(define-method ref
(of-object "GParamSpec")
@ -848,6 +1013,12 @@
(return-type "none")
)
(define-method ref_sink
(of-object "GParamSpec")
(c-name "g_param_spec_ref_sink")
(return-type "GParamSpec*")
)
(define-method get_qdata
(of-object "GParamSpec")
(c-name "g_param_spec_get_qdata")
@ -887,6 +1058,12 @@
)
)
(define-method get_redirect_target
(of-object "GParamSpec")
(c-name "g_param_spec_get_redirect_target")
(return-type "GParamSpec*")
)
(define-function g_param_value_set_default
(c-name "g_param_value_set_default")
(return-type "none")
@ -974,6 +1151,15 @@
(return-type "GParamSpec*")
)
(define-method take_param
(of-object "GValue")
(c-name "g_value_take_param")
(return-type "none")
(parameters
'("GParamSpec*" "param")
)
)
(define-method set_param_take_ownership
(of-object "GValue")
(c-name "g_value_set_param_take_ownership")
@ -992,16 +1178,6 @@
)
)
(define-function _g_param_type_register_static_constant
(c-name "_g_param_type_register_static_constant")
(return-type "GType")
(parameters
'("const-gchar*" "name")
'("const-GParamSpecTypeInfo*" "pspec_info")
'("GType" "opt_type")
)
)
(define-function g_param_spec_internal
(c-name "g_param_spec_internal")
(return-type "gpointer")
@ -1016,6 +1192,7 @@
(define-function g_param_spec_pool_new
(c-name "g_param_spec_pool_new")
(is-constructor-of "GParamSpecPool")
(return-type "GParamSpecPool*")
(parameters
'("gboolean" "type_prefixing")
@ -1073,7 +1250,7 @@
;; From gobject/gparamspecs.h
;; From gparamspecs.h
(define-function g_param_spec_char
(c-name "g_param_spec_char")
@ -1336,9 +1513,30 @@
)
)
(define-function g_param_spec_override
(c-name "g_param_spec_override")
(return-type "GParamSpec*")
(parameters
'("const-gchar*" "name")
'("GParamSpec*" "overridden")
)
)
(define-function g_param_spec_gtype
(c-name "g_param_spec_gtype")
(return-type "GParamSpec*")
(parameters
'("const-gchar*" "name")
'("const-gchar*" "nick")
'("const-gchar*" "blurb")
'("GType" "is_a_type")
'("GParamFlags" "flags")
)
)
;; From gobject/gsignal.h
;; From gsignal.h
(define-function g_signal_newv
(c-name "g_signal_newv")
@ -1391,6 +1589,23 @@
(varargs #t)
)
(define-function g_signal_new_class_handler
(c-name "g_signal_new_class_handler")
(return-type "guint")
(parameters
'("const-gchar*" "signal_name")
'("GType" "itype")
'("GSignalFlags" "signal_flags")
'("GCallback" "class_handler")
'("GSignalAccumulator" "accumulator")
'("gpointer" "accu_data")
'("GSignalCMarshaller" "c_marshaller")
'("GType" "return_type")
'("guint" "n_params")
)
(varargs #t)
)
(define-function g_signal_emitv
(c-name "g_signal_emitv")
(return-type "none")
@ -1513,7 +1728,7 @@
(return-type "gulong")
(parameters
'("guint" "signal_id")
'("GQuark" "quark")
'("GQuark" "detail")
'("GSignalEmissionHook" "hook_func")
'("gpointer" "hook_data")
'("GDestroyNotify" "data_destroy")
@ -1678,6 +1893,16 @@
)
)
(define-function g_signal_override_class_handler
(c-name "g_signal_override_class_handler")
(return-type "none")
(parameters
'("const-gchar*" "signal_name")
'("GType" "instance_type")
'("GCallback" "class_handler")
)
)
(define-function g_signal_chain_from_overridden
(c-name "g_signal_chain_from_overridden")
(return-type "none")
@ -1687,17 +1912,46 @@
)
)
(define-function _g_signals_destroy
(c-name "_g_signals_destroy")
(define-function g_signal_chain_from_overridden_handler
(c-name "g_signal_chain_from_overridden_handler")
(return-type "none")
(parameters
'("GType" "itype")
'("gpointer" "instance")
)
(varargs #t)
)
(define-function g_signal_accumulator_true_handled
(c-name "g_signal_accumulator_true_handled")
(return-type "gboolean")
(parameters
'("GSignalInvocationHint*" "ihint")
'("GValue*" "return_accu")
'("const-GValue*" "handler_return")
'("gpointer" "dummy")
)
)
(define-function g_signal_handlers_destroy
(c-name "g_signal_handlers_destroy")
(return-type "none")
(parameters
'("gpointer" "instance")
)
)
;; From gobject/gsourceclosure.h
;; From gsourceclosure.h
(define-method set_closure
(of-object "GSource")
(c-name "g_source_set_closure")
(return-type "none")
(parameters
'("GClosure*" "closure")
)
)
(define-function g_io_channel_get_type
(c-name "g_io_channel_get_type")
@ -1711,7 +1965,7 @@
;; From gobject/gtype.h
;; From gtype.h
(define-function g_type_init
(c-name "g_type_init")
@ -1788,6 +2042,12 @@
(return-type "gpointer")
)
(define-method class_peek_static
(of-object "GType")
(c-name "g_type_class_peek_static")
(return-type "gpointer")
)
(define-function g_type_class_unref
(c-name "g_type_class_unref")
(return-type "none")
@ -1821,6 +2081,26 @@
)
)
(define-method default_interface_ref
(of-object "GType")
(c-name "g_type_default_interface_ref")
(return-type "gpointer")
)
(define-method default_interface_peek
(of-object "GType")
(c-name "g_type_default_interface_peek")
(return-type "gpointer")
)
(define-function g_type_default_interface_unref
(c-name "g_type_default_interface_unref")
(return-type "none")
(parameters
'("gpointer" "g_iface")
)
)
(define-method children
(of-object "GType")
(c-name "g_type_children")
@ -1878,6 +2158,20 @@
)
)
(define-method register_static_simple
(of-object "GType")
(c-name "g_type_register_static_simple")
(return-type "GType")
(parameters
'("const-gchar*" "type_name")
'("guint" "class_size")
'("GClassInitFunc" "class_init")
'("guint" "instance_size")
'("GInstanceInitFunc" "instance_init")
'("GTypeFlags" "flags")
)
)
(define-method register_dynamic
(of-object "GType")
(c-name "g_type_register_dynamic")
@ -1930,6 +2224,33 @@
)
)
(define-method interface_prerequisites
(of-object "GType")
(c-name "g_type_interface_prerequisites")
(return-type "GType*")
(parameters
'("guint*" "n_prerequisites")
)
)
(define-function g_type_class_add_private
(c-name "g_type_class_add_private")
(return-type "none")
(parameters
'("gpointer" "g_class")
'("gsize" "private_size")
)
)
(define-method get_private
(of-object "GTypeInstance")
(c-name "g_type_instance_get_private")
(return-type "gpointer")
(parameters
'("GType" "private_type")
)
)
(define-method get_plugin
(of-object "GType")
(c-name "g_type_get_plugin")
@ -1941,7 +2262,7 @@
(c-name "g_type_interface_get_plugin")
(return-type "GTypePlugin*")
(parameters
'("GType" "implementation_type")
'("GType" "interface_type")
)
)
@ -1996,6 +2317,24 @@
)
)
(define-function g_type_add_interface_check
(c-name "g_type_add_interface_check")
(return-type "none")
(parameters
'("gpointer" "check_data")
'("GTypeInterfaceCheckFunc" "check_func")
)
)
(define-function g_type_remove_interface_check
(c-name "g_type_remove_interface_check")
(return-type "none")
(parameters
'("gpointer" "check_data")
'("GTypeInterfaceCheckFunc" "check_func")
)
)
(define-method value_table_peek
(of-object "GType")
(c-name "g_type_value_table_peek")
@ -2096,7 +2435,7 @@
;; From gobject/gtypemodule.h
;; From gtypemodule.h
(define-function g_type_module_get_type
(c-name "g_type_module_get_type")
@ -2147,9 +2486,29 @@
)
)
(define-method register_enum
(of-object "GTypeModule")
(c-name "g_type_module_register_enum")
(return-type "GType")
(parameters
'("const-gchar*" "name")
'("const-GEnumValue*" "const_static_values")
)
)
(define-method register_flags
(of-object "GTypeModule")
(c-name "g_type_module_register_flags")
(return-type "GType")
(parameters
'("const-gchar*" "name")
'("const-GFlagsValue*" "const_static_values")
)
)
;; From gobject/gtypeplugin.h
;; From gtypeplugin.h
(define-function g_type_plugin_get_type
(c-name "g_type_plugin_get_type")
@ -2184,27 +2543,28 @@
(c-name "g_type_plugin_complete_interface_info")
(return-type "none")
(parameters
'("GType" "interface_type")
'("GType" "instance_type")
'("GType" "interface_type")
'("GInterfaceInfo*" "info")
)
)
;; From gobject/gvaluearray.h
;; From gvaluearray.h
(define-method get_nth
(of-object "GValueArray")
(c-name "g_value_array_get_nth")
(return-type "GValue*")
(parameters
'("guint" "index")
'("guint" "index_")
)
)
(define-function g_value_array_new
(c-name "g_value_array_new")
(is-constructor-of "GValueArray")
(return-type "GValueArray*")
(parameters
'("guint" "n_prealloced")
@ -2246,7 +2606,7 @@
(c-name "g_value_array_insert")
(return-type "GValueArray*")
(parameters
'("guint" "index")
'("guint" "index_")
'("const-GValue*" "value")
)
)
@ -2256,7 +2616,7 @@
(c-name "g_value_array_remove")
(return-type "GValueArray*")
(parameters
'("guint" "index")
'("guint" "index_")
)
)
@ -2281,11 +2641,11 @@
;; From gobject/gvaluecollector.h
;; From gvaluecollector.h
;; From gobject/gvalue.h
;; From gvalue.h
(define-method init
(of-object "GValue")
@ -2377,7 +2737,16 @@
;; From gobject/gvaluetypes.h
;; From gvaluetypes.h
(define-method set_char
(of-object "GValue")
(c-name "g_value_set_char")
(return-type "none")
(parameters
'("gchar" "v_char")
)
)
(define-method get_char
(of-object "GValue")
@ -2580,6 +2949,26 @@
(return-type "gpointer")
)
(define-function g_gtype_get_type
(c-name "g_gtype_get_type")
(return-type "GType")
)
(define-method set_gtype
(of-object "GValue")
(c-name "g_value_set_gtype")
(return-type "none")
(parameters
'("GType" "v_gtype")
)
)
(define-method get_gtype
(of-object "GValue")
(c-name "g_value_get_gtype")
(return-type "GType")
)
(define-function g_pointer_type_register_static
(c-name "g_pointer_type_register_static")
(return-type "GType")
@ -2596,6 +2985,15 @@
)
)
(define-method take_string
(of-object "GValue")
(c-name "g_value_take_string")
(return-type "none")
(parameters
'("gchar*" "v_string")
)
)
(define-method set_string_take_ownership
(of-object "GValue")
(c-name "g_value_set_string_take_ownership")

View file

@ -4,16 +4,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -22,7 +22,6 @@
#include <glibmm/iochannel.h>
#include <glibmm/utility.h>
#include <glibmm/main.h>
#include <glib.h>
namespace
@ -443,12 +442,15 @@ Glib::RefPtr<IOChannel> wrap(GIOChannel* gobject, bool take_copy)
/**** Glib::GlibmmIOChannel ************************************************/
// static
#ifdef GLIBMM_EXCEPTIONS_ENABLED
GIOStatus GlibmmIOChannel::io_read(GIOChannel* channel, char* buf, gsize count,
gsize* bytes_read, GError** err)
#else
//Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
GIOStatus GlibmmIOChannel::io_read(GIOChannel* channel, char* buf, gsize count,
gsize* bytes_read, GError** /* err */)
#endif
{
if(!&err) err = err; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
IOChannel *const wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
@ -471,12 +473,15 @@ GIOStatus GlibmmIOChannel::io_read(GIOChannel* channel, char* buf, gsize count,
return G_IO_STATUS_ERROR;
}
// static
#ifdef GLIBMM_EXCEPTIONS_ENABLED
GIOStatus GlibmmIOChannel::io_write(GIOChannel* channel, const char* buf, gsize count,
gsize* bytes_written, GError** err)
#else
//Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
GIOStatus GlibmmIOChannel::io_write(GIOChannel* channel, const char* buf, gsize count,
gsize* bytes_written, GError** /* err */)
#endif
{
if(!&err) err = err; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
IOChannel *const wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
@ -499,11 +504,13 @@ GIOStatus GlibmmIOChannel::io_write(GIOChannel* channel, const char* buf, gsize
return G_IO_STATUS_ERROR;
}
// static
#ifdef GLIBMM_EXCEPTIONS_ENABLED
GIOStatus GlibmmIOChannel::io_seek(GIOChannel* channel, gint64 offset, GSeekType type, GError** err)
#else
//Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
GIOStatus GlibmmIOChannel::io_seek(GIOChannel* channel, gint64 offset, GSeekType type, GError** /* err */)
#endif
{
if(!&err) err = err; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
IOChannel *const wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
@ -526,11 +533,13 @@ GIOStatus GlibmmIOChannel::io_seek(GIOChannel* channel, gint64 offset, GSeekType
return G_IO_STATUS_ERROR;
}
// static
#ifdef GLIBMM_EXCEPTIONS_ENABLED
GIOStatus GlibmmIOChannel::io_close(GIOChannel* channel, GError** err)
#else
//Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
GIOStatus GlibmmIOChannel::io_close(GIOChannel* channel, GError** /* err */)
#endif
{
if(!&err) err = err; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
IOChannel *const wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
@ -588,11 +597,13 @@ void GlibmmIOChannel::io_free(GIOChannel* channel)
g_free(channel);
}
// static
#ifdef GLIBMM_EXCEPTIONS_ENABLED
GIOStatus GlibmmIOChannel::io_set_flags(GIOChannel* channel, GIOFlags flags, GError** err)
#else
//Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
GIOStatus GlibmmIOChannel::io_set_flags(GIOChannel* channel, GIOFlags flags, GError** /* err */)
#endif
{
if(!&err) err = err; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
IOChannel *const wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
#ifdef GLIBMM_EXCEPTIONS_ENABLED

View file

@ -4,16 +4,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -24,7 +24,7 @@ _DEFS(glibmm,glib)
#include <glibmm/main.h>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <glib/gtypes.h>
#include <glib.h>
#include <string>
#include <glibmmconfig.h>

View file

@ -1,16 +1,16 @@
/* Copyright 2006 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -35,61 +35,94 @@ KeyFile::KeyFile(GKeyFile* castitem, bool takes_ownership)
KeyFile::~KeyFile()
{
if (owns_gobject_)
g_key_file_free(gobject_);
g_key_file_free(gobject_);
}
bool KeyFile::load_from_data(const Glib::ustring& data, KeyFileFlags flags)
{
GError *error = 0;
bool retvalue = g_key_file_load_from_data(gobj(), data.c_str(), data.bytes(), ((GKeyFileFlags)(flags)), &(error));
if(error) :: Glib::Error::throw_exception(error);
return retvalue;
GError* error = 0;
const gboolean result = g_key_file_load_from_data(
gobj(), data.c_str(), data.bytes(),
static_cast<GKeyFileFlags>(unsigned(flags)),
&error);
if(error)
Glib::Error::throw_exception(error);
return (result != 0);
}
bool KeyFile::load_from_data_dirs(const std::string& file, std::string& full_path, KeyFileFlags flags)
bool KeyFile::load_from_data_dirs(const std::string& file, std::string& full_path,
KeyFileFlags flags)
{
GError *error = 0;
char *full_path_c;
bool retvalue = g_key_file_load_from_data_dirs(gobj(), file.c_str(), &full_path_c, ((GKeyFileFlags)(flags)), &(error));
full_path = Glib::convert_return_gchar_ptr_to_ustring(full_path_c);
if(error) :: Glib::Error::throw_exception(error);
return retvalue;
GError* error = 0;
char* full_path_c = 0;
const gboolean result = g_key_file_load_from_data_dirs(
gobj(), file.c_str(), &full_path_c,
static_cast<GKeyFileFlags>(unsigned(flags)),
&error);
if(error)
Glib::Error::throw_exception(error);
if(full_path_c)
full_path = Glib::ScopedPtr<char>(full_path_c).get();
else
full_path.erase();
return (result != 0);
}
Glib::ustring KeyFile::to_data()
{
GError *error = 0;
gsize size;
Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(g_key_file_to_data(gobj(), &size, &error));
if(error) :: Glib::Error::throw_exception(error);
return retvalue;
GError* error = 0;
char *const str = g_key_file_to_data(gobj(), 0, &error);
if(error)
Glib::Error::throw_exception(error);
return Glib::convert_return_gchar_ptr_to_ustring(str);
}
Glib::ArrayHandle<Glib::ustring> KeyFile::get_groups() const
{
gchar** group_names = 0;
gsize number_of_groups = 0;
group_names = g_key_file_get_groups(const_cast<GKeyFile*>(gobj()), &number_of_groups);
return Glib::ArrayHandle<Glib::ustring>(group_names, number_of_groups, Glib::OWNERSHIP_DEEP);
gsize length = 0;
char** const array = g_key_file_get_groups(const_cast<GKeyFile*>(gobj()), &length);
return Glib::ArrayHandle<Glib::ustring>(array, length, Glib::OWNERSHIP_DEEP);
}
Glib::ArrayHandle<Glib::ustring> KeyFile::get_keys(const Glib::ustring& group_name) const
{
gchar** key_names = 0;
gsize number_of_keys = 0;
GError* error = 0;
key_names = g_key_file_get_keys(const_cast<GKeyFile*>(gobj()), group_name.c_str(), &number_of_keys, &error);
gsize length = 0;
GError* error = 0;
char** const array = g_key_file_get_keys(
const_cast<GKeyFile*>(gobj()),
(group_name.empty()) ? 0 : group_name.c_str(),
&length, &error);
if(error)
Glib::Error::throw_exception(error);
return Glib::ArrayHandle<Glib::ustring>(key_names, number_of_keys, Glib::OWNERSHIP_DEEP);
return Glib::ArrayHandle<Glib::ustring>(array, length, Glib::OWNERSHIP_DEEP);
}
Glib::ustring KeyFile::get_locale_string(const Glib::ustring& group_name, const Glib::ustring& key) const
Glib::ustring KeyFile::get_locale_string(const Glib::ustring& group_name,
const Glib::ustring& key) const
{
GError *error = 0;
Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(g_key_file_get_locale_string(const_cast<GKeyFile*>(gobj()), group_name.c_str(), key.c_str(), 0, &(error)));
if(error) ::Glib::Error::throw_exception(error);
return retvalue;
GError* error = 0;
char *const str = g_key_file_get_locale_string(
const_cast<GKeyFile*>(gobj()),
(group_name.empty()) ? 0 : group_name.c_str(),
key.c_str(), 0, &error);
if(error)
Glib::Error::throw_exception(error);
return Glib::convert_return_gchar_ptr_to_ustring(str);
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
@ -99,19 +132,17 @@ int KeyFile::get_integer(const Glib::ustring& key, std::auto_ptr<Glib::Error>& e
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
GError* gerror = 0;
int retvalue = g_key_file_get_integer(const_cast<GKeyFile*>(gobj()), NULL, key.c_str(), &(gerror));
const int value = g_key_file_get_integer(const_cast<GKeyFile*>(gobj()),
0, key.c_str(), &gerror);
if(gerror)
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
::Glib::Error::throw_exception(gerror);
Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
return retvalue;
error = Glib::Error::throw_exception(gerror);
#endif
return value;
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
double KeyFile::get_double(const Glib::ustring& key) const
#else
@ -136,49 +167,76 @@ void KeyFile::set_double(const Glib::ustring& key, double value)
g_key_file_set_double(gobj(), 0, key.c_str(), value);
}
Glib::ArrayHandle<Glib::ustring> KeyFile::get_string_list(const Glib::ustring& group_name, const Glib::ustring& key) const
// TODO: alternative code path with exceptions disabled
Glib::ArrayHandle<Glib::ustring> KeyFile::get_string_list(const Glib::ustring& group_name,
const Glib::ustring& key) const
{
gchar** string_list = 0;
gsize length_of_list = 0;
GError* error = 0;
string_list = g_key_file_get_string_list(const_cast<GKeyFile*>(gobj()), group_name.c_str(), key.c_str(), &length_of_list, &error);
gsize length = 0;
GError* error = 0;
char** const array = g_key_file_get_string_list(
const_cast<GKeyFile*>(gobj()),
(group_name.empty()) ? 0 : group_name.c_str(),
key.c_str(), &length, &error);
if(error)
Glib::Error::throw_exception(error);
return Glib::ArrayHandle<Glib::ustring>(string_list, length_of_list, Glib::OWNERSHIP_DEEP);
return Glib::ArrayHandle<Glib::ustring>(array, length, Glib::OWNERSHIP_DEEP);
}
Glib::ArrayHandle<Glib::ustring> KeyFile::get_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& locale) const
// TODO: alternative code path with exceptions disabled
Glib::ArrayHandle<Glib::ustring> KeyFile::get_locale_string_list(const Glib::ustring& group_name,
const Glib::ustring& key,
const Glib::ustring& locale) const
{
gchar** string_list = 0;
gsize length_of_list = 0;
GError* error = 0;
string_list = g_key_file_get_locale_string_list(const_cast<GKeyFile*>(gobj()), group_name.c_str(), key.c_str(), locale.c_str(), &length_of_list, &error);
gsize length = 0;
GError* error = 0;
char** const array = g_key_file_get_locale_string_list(
const_cast<GKeyFile*>(gobj()),
(group_name.empty()) ? 0 : group_name.c_str(),
key.c_str(), locale.c_str(), &length, &error);
if(error)
Glib::Error::throw_exception(error);
return Glib::ArrayHandle<Glib::ustring>(string_list, length_of_list, Glib::OWNERSHIP_DEEP);
return Glib::ArrayHandle<Glib::ustring>(array, length, Glib::OWNERSHIP_DEEP);
}
Glib::ArrayHandle<bool> KeyFile::get_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key) const
// TODO: alternative code path with exceptions disabled
Glib::ArrayHandle<bool> KeyFile::get_boolean_list(const Glib::ustring& group_name,
const Glib::ustring& key) const
{
gboolean* bool_list = 0;
gsize length_of_list = 0;
GError* error = 0;
bool_list = g_key_file_get_boolean_list(const_cast<GKeyFile*>(gobj()), group_name.c_str(), key.c_str(), &length_of_list, &error);
gsize length = 0;
GError* error = 0;
gboolean *const array = g_key_file_get_boolean_list(
const_cast<GKeyFile*>(gobj()),
(group_name.empty()) ? 0 : group_name.c_str(),
key.c_str(), &length, &error);
if(error)
Glib::Error::throw_exception(error);
return Glib::ArrayHandle<bool>(&bool_list, length_of_list, Glib::OWNERSHIP_DEEP);
return Glib::ArrayHandle<bool>(array, length, Glib::OWNERSHIP_SHALLOW);
}
Glib::ArrayHandle<int> KeyFile::get_integer_list(const Glib::ustring& group_name, const Glib::ustring& key) const
Glib::ArrayHandle<int> KeyFile::get_integer_list(const Glib::ustring& group_name,
const Glib::ustring& key) const
{
gint* integer_list = 0;
gsize length_of_list = 0;
GError* error = 0;
integer_list = g_key_file_get_integer_list(const_cast<GKeyFile*>(gobj()), group_name.c_str(), key.c_str(), &length_of_list, &error);
gsize length = 0;
GError* error = 0;
int *const array = g_key_file_get_integer_list(
const_cast<GKeyFile*>(gobj()),
(group_name.empty()) ? 0 : group_name.c_str(),
key.c_str(), &length, &error);
if(error)
Glib::Error::throw_exception(error);
return Glib::ArrayHandle<int>(integer_list, length_of_list, Glib::OWNERSHIP_DEEP);
return Glib::ArrayHandle<int>(array, length, Glib::OWNERSHIP_SHALLOW);
}
Glib::ArrayHandle<double> KeyFile::get_double_list(const Glib::ustring& group_name, const Glib::ustring& key) const
@ -192,64 +250,81 @@ Glib::ArrayHandle<double> KeyFile::get_double_list(const Glib::ustring& group_na
return Glib::ArrayHandle<double>(integer_list, length_of_list, Glib::OWNERSHIP_DEEP);
}
void KeyFile::set_string_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<Glib::ustring>& list)
void KeyFile::set_string_list(const Glib::ustring& group_name, const Glib::ustring& key,
const Glib::ArrayHandle<Glib::ustring>& list)
{
gsize length_of_list = list.size();
g_key_file_set_string_list(gobj(), group_name.c_str(), key.c_str(), list.data(), length_of_list);
g_key_file_set_string_list(gobj(), (group_name.empty()) ? 0 : group_name.c_str(),
key.c_str(), list.data(), list.size());
}
void KeyFile::set_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& locale, const Glib::ArrayHandle<Glib::ustring>& list)
void KeyFile::set_locale_string_list(const Glib::ustring& group_name,
const Glib::ustring& key, const Glib::ustring& locale,
const Glib::ArrayHandle<Glib::ustring>& list)
{
gsize length_of_list = list.size();
g_key_file_set_locale_string_list(gobj(), group_name.c_str(), key.c_str(), locale.c_str(), list.data(), length_of_list);
g_key_file_set_locale_string_list(gobj(), (group_name.empty()) ? 0 : group_name.c_str(),
key.c_str(), locale.c_str(), list.data(), list.size());
}
void KeyFile::set_integer_list(const Glib::ustring& group_name, const Glib::ustring& key, Glib::ArrayHandle<int>& list)
void KeyFile::set_integer_list(const Glib::ustring& group_name, const Glib::ustring& key,
const Glib::ArrayHandle<int>& list)
{
gsize length_of_list = list.size();
g_key_file_set_integer_list(gobj(), group_name.c_str(), key.c_str(), const_cast<int*>(list.data()), length_of_list);
g_key_file_set_integer_list(gobj(), (group_name.empty()) ? 0 : group_name.c_str(),
key.c_str(), const_cast<int*>(list.data()), list.size());
}
void KeyFile::set_double_list(const Glib::ustring& group_name, const Glib::ustring& key, Glib::ArrayHandle<double>& list)
void KeyFile::set_double_list(const Glib::ustring& group_name, const Glib::ustring& key,
const Glib::ArrayHandle<double>& list)
{
gsize length_of_list = list.size();
g_key_file_set_double_list(gobj(), group_name.c_str(), key.c_str(), const_cast<double*>(list.data()), length_of_list);
g_key_file_set_double_list(gobj(), group_name.c_str(), key.c_str(),
const_cast<double*>(list.data()), list.size());
}
void KeyFile::set_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key, Glib::ArrayHandle<bool>& list)
void KeyFile::set_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key,
const Glib::ArrayHandle<bool>& list)
{
gsize length_of_list = list.size();
g_key_file_set_boolean_list(gobj(), group_name.c_str(), key.c_str(), *(list.data()), length_of_list);
g_key_file_set_boolean_list(gobj(), (group_name.empty()) ? 0 : group_name.c_str(),
key.c_str(), const_cast<gboolean*>(list.data()), list.size());
}
Glib::ustring KeyFile::get_comment() const
{
GError *error = 0;
Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(g_key_file_get_comment(const_cast<GKeyFile*>(gobj()), 0, 0, &(error)));
if(error) ::Glib::Error::throw_exception(error);
return retvalue;
GError* error = 0;
char *const str = g_key_file_get_comment(const_cast<GKeyFile*>(gobj()), 0, 0, &error);
if(error)
Glib::Error::throw_exception(error);
return Glib::convert_return_gchar_ptr_to_ustring(str);
}
Glib::ustring KeyFile::get_comment(const Glib::ustring& group_name) const
{
GError *error = 0;
Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(g_key_file_get_comment(const_cast<GKeyFile*>(gobj()), group_name.c_str(), 0, &(error)));
if(error) ::Glib::Error::throw_exception(error);
return retvalue;
GError* error = 0;
char *const str = g_key_file_get_comment(const_cast<GKeyFile*>(gobj()),
(group_name.empty()) ? 0 : group_name.c_str(),
0, &error);
if(error)
Glib::Error::throw_exception(error);
return Glib::convert_return_gchar_ptr_to_ustring(str);
}
void KeyFile::set_comment(const Glib::ustring& comment)
{
GError *error = 0;
g_key_file_set_comment(gobj(), 0, 0, comment.c_str(), &(error));
if(error) ::Glib::Error::throw_exception(error);
GError* error = 0;
g_key_file_set_comment(gobj(), 0, 0, comment.c_str(), &error);
if(error)
Glib::Error::throw_exception(error);
}
void KeyFile::set_comment(const Glib::ustring& group_name, const Glib::ustring& comment)
{
GError *error = 0;
g_key_file_set_comment(gobj(), group_name.c_str(), 0, comment.c_str(), &(error));
if(error) ::Glib::Error::throw_exception(error);
GError* error = 0;
g_key_file_set_comment(gobj(), (group_name.empty()) ? 0 : group_name.c_str(),
0, comment.c_str(), &error);
if(error)
Glib::Error::throw_exception(error);
}
}
} // namespace Glib

View file

@ -1,16 +1,16 @@
/* Copyright(C) 2006 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or(at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -21,7 +21,7 @@ _DEFS(glibmm,glib)
#include <glibmm/arrayhandle.h>
#include <glibmm/error.h>
#include <glibmm/utility.h>
#include <glib/gkeyfile.h>
#include <glib.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C" { typedef struct _GKeyFile GKeyFile; }
@ -71,8 +71,8 @@ _WRAP_GERROR(KeyFileError, GKeyFileError, G_KEY_FILE_ERROR, NO_GTYPE)
*
* Key-value pairs generally have the form key=value, with the exception of localized strings, which have the form
* key[locale]=value. Space before and after the '=' character are ignored. Newline, tab, carriage return and
* backslash characters in value are escaped as \n, \t, \r, and \\, respectively. To preserve leading spaces in
* values, these can also be escaped as \s.
* backslash characters in value are escaped as \\n, \\t, \\r, and \\\\, respectively. To preserve leading spaces in
* values, these can also be escaped as \\s.
*
* Key files can store strings (possibly with localized variants), integers, booleans and lists of these. Lists are
* separated by a separator character, typically ';' or ','. To use the list separator character in a value in a
@ -324,7 +324,7 @@ public:
* @param key The name of a key
* @param list A list holding object of type bool
*/
void set_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key, Glib::ArrayHandle<bool>& list);
void set_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<bool>& list);
_IGNORE(g_key_file_set_boolean_list)
/** Sets a list of integers for the @a key under @a group_name.
@ -333,7 +333,7 @@ public:
* @param key The name of a key
* @param list A list holding object of type int
*/
void set_integer_list(const Glib::ustring& group_name, const Glib::ustring& key, Glib::ArrayHandle<int>& list);
void set_integer_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<int>& list);
_IGNORE(g_key_file_set_integer_list)
/** Sets a list of doubles for the @a key under @a group_name.
@ -344,7 +344,7 @@ public:
*
* @newin2p14
*/
void set_double_list(const Glib::ustring& group_name, const Glib::ustring& key, Glib::ArrayHandle<double>& list);
void set_double_list(const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<double>& list);
_IGNORE(g_key_file_set_double_list)

View file

@ -4,16 +4,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -98,7 +98,7 @@ void ParserCallbacks::start_element(GMarkupParseContext* context,
void* user_data,
GError** error)
{
if(!&error) error = error; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
(void)error; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
ParseContext& cpp_context = *static_cast<ParseContext*>(user_data);
g_return_if_fail(context == cpp_context.gobj());
@ -139,7 +139,7 @@ void ParserCallbacks::end_element(GMarkupParseContext* context,
void* user_data,
GError** error)
{
if(!&error) error = error; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
(void)error; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
ParseContext& cpp_context = *static_cast<ParseContext*>(user_data);
g_return_if_fail(context == cpp_context.gobj());
@ -168,7 +168,7 @@ void ParserCallbacks::text(GMarkupParseContext* context,
void* user_data,
GError** error)
{
if(!&error) error = error; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
(void)error; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
ParseContext& cpp_context = *static_cast<ParseContext*>(user_data);
g_return_if_fail(context == cpp_context.gobj());
@ -197,7 +197,7 @@ void ParserCallbacks::passthrough(GMarkupParseContext* context,
void* user_data,
GError** error)
{
if(!&error) error = error; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
(void)error; //Avoid an unused parameter warning when GLIBMM_EXCEPTIONS_ENABLED is used.
ParseContext& cpp_context = *static_cast<ParseContext*>(user_data);
g_return_if_fail(context == cpp_context.gobj());

View file

@ -3,16 +3,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/

View file

@ -4,16 +4,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/

View file

@ -3,16 +3,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/

View file

@ -0,0 +1 @@
#include <glibmm/nodetree.h>

View file

@ -0,0 +1,760 @@
/* Copyright (C) 2007 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.
*/
_DEFS(glibmm,glib)
#include <map>
#include <stack>
#include <deque>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <glibmm/error.h>
#include <glibmm/arrayhandle.h>
#include <glib.h>
namespace Glib
{
//Hand-written, instead of using _WRAP_ENUM,
//because the C enum values don't have a prefix.
/** Specifies the type of traveral performed by methods such as NodeTree::_traverse() and NodeTree::find().
*
* @ingroup glibmmEnums
*/
enum TraverseType
{
TRAVERSE_IN_ORDER = G_IN_ORDER, /*!< Visits a node's left child first, then the node itself, then its right child. This is the one to use if you want the output sorted according to the compare function. */
TRAVERSE_PRE_ORDER = G_PRE_ORDER, /*!< Visits a node, then its children. */
TRAVERSE_POST_ORDER = G_POST_ORDER, /*!< Visits the node's children, then the node itself. */
TRAVERSE_LEVEL_ORDER = G_LEVEL_ORDER /*!< For NodeTree, it vists the root node first, then its children, then its grandchildren, and so on. Note that this is less efficient than the other orders. This is not implemented for Glib::Tree. */
};
/** N-ary Trees - trees of data with any number of branches
* The NodeTree class and its associated functions provide an N-ary tree data structure, in which nodes in the tree can contain arbitrary data.
*
* To insert a node into a tree use insert(), insert_before(), append() or prepend().
*
* To create a new node and insert it into a tree use insert_data(), insert_data_before(), append_data() and prepend_data().
*
* To reverse the children of a node use reverse_children().
*
* To find a node use root(), find(), find_child(), index_of(), child_index(), first_child(), last_child(), nth_child(), first_sibling(), prev_sibling(), next_sibling() or last_sibling().
*
* To get information about a node or tree use is_leaf(), is_root(), depth(), node_count(), child_count(), is_ancestor() or max_height().
*
* To traverse a tree, calling a function for each node visited in the traversal, use traverse() or foreach().
*
* To remove a node or subtree from a tree use unlink().
*
* @newin2p18
*/
template <typename T>
class NodeTree
{
_CLASS_GENERIC(NodeTree, GNode)
public:
typedef sigc::slot<bool, NodeTree<T>&> TraverseFunc;
typedef sigc::slot<void, NodeTree<T>&> ForeachFunc;
private:
static NodeTree<T>* wrap(GNode* node)
{
if (!node)
return 0;
return reinterpret_cast<NodeTree<T>* >(node->data);
}
public:
NodeTree()
{
clone();
}
explicit NodeTree(const T& the_data) :
data_(the_data)
{
clone();
}
_IGNORE(g_node_new)
NodeTree(const NodeTree<T>& node) :
data_(node.data())
{
clone(&node);
}
/** Removes the instance and its children from the tree,
* freeing any memory allocated.
*/
~NodeTree()
{
if(!is_root())
unlink();
clear();
}
_IGNORE(g_node_destroy)
NodeTree<T>& operator=(const NodeTree<T>& node)
{
clear();
clone(&node);
data_ = node.data();
return *this;
}
/// Provides access to the underlying C GObject.
inline GNode* gobj()
{
return gobject_;
}
/// Provides access to the underlying C GObject.
inline const GNode* gobj() const
{
return gobject_;
}
/** Inserts a NodeTree beneath the parent at the given position.
*
* @param position the position to place node at, with respect to its siblings
* If position is -1, node is inserted as the last child of parent
* @param node the NodeTree to insert
* @return the inserted NodeTree
*/
NodeTree<T>& insert(int position, NodeTree<T>& node)
{
g_node_insert(gobj(), position, node.gobj());
return node;
}
_IGNORE(g_node_insert)
/** Inserts a NodeTree beneath the parent before the given sibling.
*
* @param sibling the sibling NodeTree to place node before.
* @param node the NodeTree to insert
* @return the inserted NodeTree
*/
NodeTree<T>& insert_before(NodeTree<T>& sibling, NodeTree<T>& node)
{
g_node_insert_before(gobj(), sibling.gobj(), node.gobj());
return node;
}
_IGNORE(g_node_insert_before)
/** Inserts a NodeTree beneath the parent after the given sibling.
*
* @param sibling the sibling NodeTree to place node after.
* @param node the NodeTree to insert
* @return the inserted NodeTree
*/
NodeTree<T>& insert_after(NodeTree<T>& sibling, NodeTree<T>& node)
{
g_node_insert_after(gobj(), sibling.gobj(), node.gobj());
return node;
}
_IGNORE(g_node_insert_after)
/** Inserts a NodeTree as the last child.
*
* @param node the NodeTree to append
* @return the new NodeTree
*/
NodeTree<T>& append(NodeTree<T>& node)
{
g_node_append(gobj(), node.gobj());
return node;
}
_IGNORE(g_node_append)
/** Inserts a NodeTree as the first child.
*
* @param data the data for the NodeTree
* @return the NodeTree
*/
NodeTree<T>& prepend(NodeTree<T>& node)
{
g_node_prepend(gobj(), node.gobj());
return node;
}
_IGNORE(g_node_prepend)
/** Inserts a new NodeTree at the given position.
*
* @param position the position to place the new NodeTree at.
* If position is -1, the new NodeTree is inserted as the last child of parent
* @param data the data for the new NodeTree
* @return the new NodeTree
*/
NodeTree<T>* insert_data(int position, const T& the_data)
{
NodeTree<T>* node = new NodeTree<T>(the_data);
insert(position, *node);
return node;
}
_IGNORE(g_node_insert_data)
/** Inserts a new NodeTree before the given sibling.
*
* @param sibling the sibling NodeTree to place node before.
* @param data the data for the new NodeTree
* @return the new NodeTree
*/
NodeTree<T>* insert_data_before(NodeTree<T>& sibling, const T& the_data)
{
NodeTree<T>* node = new NodeTree<T>(the_data);
insert_before(sibling, *node);
return node;
}
_IGNORE(g_node_insert_data_before)
/** Inserts a new NodeTree as the last child.
*
* @param data the data for the new NodeTree
* @return the new NodeTree
*/
NodeTree<T>* append_data(const T& the_data)
{
NodeTree<T>* node = new NodeTree<T>(the_data);
append(*node);
return node;
}
_IGNORE(g_node_append_data)
/** Inserts a new NodeTree as the first child.
*
* @param data the data for the new NodeTree
* @return the new NodeTree
*/
NodeTree<T>* prepend_data(const T& the_data)
{
NodeTree<T>* node = new NodeTree<T>(the_data);
prepend(*node);
return node;
}
_IGNORE(g_node_prepend_data)
/** Reverses the order of the children.
*/
void reverse_children()
{
g_node_reverse_children(gobj());
}
_IGNORE(g_node_reverse_children)
/** Returns a pointer to the root of the tree.
*
* @return A pointer to the root of the tree.
*/
NodeTree<T>* get_root()
{
return wrap(g_node_get_root(gobj()));
}
const NodeTree<T>* get_root() const
{
return wrap(g_node_get_root(gobj()));
}
_IGNORE(g_node_get_root)
/** Specifies which nodes are visited during several of the NodeTree methods,
* including traverse() and find().
*
* @ingroup glibmmEnums
*/
enum TraverseFlags
{
TRAVERSE_LEAVES = G_TRAVERSE_LEAVES, /*!< Only leaf nodes should be visited. */
TRAVERSE_NON_LEAVES = G_TRAVERSE_NON_LEAVES, /*!< Only non-leaf nodes should be visited. */
TRAVERSE_ALL = G_TRAVERSE_ALL, /*!< All nodes should be visited. */
TRAVERSE_MASK = G_TRAVERSE_MASK /*!< A mask of all traverse flags. */
};
/** Traverses a tree starting at the current node.
* It calls the given function for each node visited.
* The traversal can be halted at any point by returning true from @a func.
*
* @param order The order in which nodes are visited.
* @param flags Which types of children are to be visited.
* @param max_depth The maximum depth of the traversal.
* Nodes below this depth will not be visited.
* If max_depth is -1 all nodes in the tree are visited.
* If max_depth is 1, only the root is visited.
* If max_depth is 2, the root and its children are visited. And so on.
* @param func the slot to invoke for each visited child
*/
void traverse(const TraverseFunc& func, TraverseType order = TRAVERSE_IN_ORDER, TraverseFlags flags = TRAVERSE_ALL, int max_depth = -1)
{
TraverseFunc func_copy = func;
g_node_traverse(gobj(), (GTraverseType)order, (GTraverseFlags)flags, max_depth, c_callback_traverse, reinterpret_cast<gpointer>(&func_copy));
}
_IGNORE(g_node_traverse);
/** Calls a function for each of the children of a NodeTree.
* Note that it doesn't descend beneath the child nodes.
*
* @param flags Wwhich types of children are to be visited.
* @param func The slot to invoke for each visited node.
*/
void foreach(const ForeachFunc& func, TraverseFlags flags = TRAVERSE_ALL)
{
ForeachFunc func_copy = func;
g_node_children_foreach(gobj(), (GTraverseFlags)flags, c_callback_foreach, reinterpret_cast<gpointer>(&func_copy));
}
_IGNORE(g_node_children_foreach)
/** Finds the first child of a NodeTree with the given data.
*
* @param flags Which types of children are to be visited, one of TRAVERSE_ALL, TRAVERSE_LEAVES and TRAVERSE_NON_LEAVES.
* @param data The data for which to search.
* @return the found child, or 0 if the data is not found
*/
NodeTree<T>* find_child(const T& the_data, TraverseFlags flags = TRAVERSE_ALL)
{
sigc::slot<void, GNode*, const T&, GNode**> real_slot = sigc::ptr_fun(on_compare_child);
GNode* child = 0;
typedef sigc::slot<void, GNode*> type_foreach_gnode_slot;
type_foreach_gnode_slot bound_slot = sigc::bind(real_slot, the_data, &child);
g_node_children_foreach(gobj(), (GTraverseFlags)flags, c_callback_foreach_compare_child, reinterpret_cast<gpointer>(&bound_slot));
return wrap(child);
}
/** Finds the first child of a NodeTree with the given data.
*
* @param flags Which types of children are to be visited, one of TRAVERSE_ALL, TRAVERSE_LEAVES and TRAVERSE_NON_LEAVES.
* @param data The data for which to search.
* @return the found child, or 0 if the data is not found
*/
const NodeTree<T>* find_child(const T& the_data, TraverseFlags flags = TRAVERSE_ALL) const
{
return const_cast<NodeTree<T>*>(this)->find_child(flags, the_data);
}
_IGNORE(g_node_find_child)
/** Finds a node in a tree.
*
* @param order The order in which nodes are visited: IN_ORDER, TRAVERSE_PRE_ORDER, TRAVERSE_POST_ORDER, or TRAVERSE_LEVEL_ORDER
* @param flags Which types of children are to be visited: one of TRAVERSE_ALL, TRAVERSE_LEAVES and TRAVERSE_NON_LEAVES.
* @param data The data for which to search.
* @return The found node, or 0 if the data is not found.
*/
NodeTree<T>* find(const T& the_data, TraverseType order = TRAVERSE_IN_ORDER, TraverseFlags flags = TRAVERSE_ALL)
{
//We use a sigc::slot for the C callback, so we can bind some extra data.
sigc::slot<gboolean, GNode*, const T&, GNode**> real_slot = sigc::ptr_fun(on_compare_node);
GNode* child = 0;
typedef sigc::slot<gboolean, GNode*> type_traverse_gnode_slot;
type_traverse_gnode_slot bound_slot = sigc::bind(real_slot, the_data, &child);
g_node_traverse(const_cast<GNode*>(gobj()), (GTraverseType)order, (GTraverseFlags)flags, -1, c_callback_traverse_compare_node, reinterpret_cast<gpointer>(&bound_slot));
return wrap(child);
}
/** Finds a node in a tree.
*
* @param order The order in which nodes are visited.
* @param flags Which types of children are to be visited.
* @param data The data for which to search.
* @return The found node, or 0 if the data is not found.
*/
const NodeTree<T>* find(const T& the_data, TraverseType order = TRAVERSE_IN_ORDER, TraverseFlags flags = TRAVERSE_ALL) const
{
return const_cast<NodeTree<T>*>(this)->find(order, flags, the_data);
}
_IGNORE(g_node_find)
/** Gets the position of the first child which contains the given data.
*
* @param data The data to find.
* @return The index of the child which contains data, or -1 if the data is not found.
*/
int child_index(const T& the_data) const
{
int n = 0;
for(const NodeTree<T>* i = first_child(); i != 0; i = i->next_sibling())
{
if((i->data()) == the_data)
return n;
n++;
}
return -1;
}
_IGNORE(g_node_child_index)
/** Gets the position with respect to its siblings.
* child must be a child of node.
* The first child is numbered 0, the second 1, and so on.
*
* @param child A child
* @return The position of @a child with respect to its siblings.
*/
int child_position(const NodeTree<T>& child) const
{
return g_node_child_position(const_cast<GNode*>(gobj()), const_cast<GNode*>(child.gobj()));
}
_IGNORE(g_node_child_position)
/** Gets the first child.
*
* @return The first child, or 0 if the node has no children.
*/
NodeTree<T>* first_child()
{
return wrap(g_node_first_child(gobj()));
}
/** Gets the first child.
*
* @return The first child, or 0 if the node has no children.
*/
const NodeTree<T>* first_child() const
{
return const_cast<NodeTree<T>*>(this)->first_child();
}
_IGNORE(g_node_first_child)
/** Gets the last child.
*
* @return The last child, or 0 if the node has no children.
*/
NodeTree<T>* last_child()
{
return wrap(g_node_last_child(gobj()));
}
/** Gets the last child.
*
* @return The last child, or 0 if the node has no children.
*/
const NodeTree<T>* last_child() const
{
return const_cast<NodeTree<T>*>(this)->last_child();
}
_IGNORE(g_node_last_child)
/** Gets the nth child.
*
* @return The nth child, or 0 if n is too large.
*/
NodeTree<T>* nth_child(int n)
{
return wrap(g_node_nth_child(gobj(), n));
}
/** Gets the nth child.
*
* @return The nth child, or 0 if n is too large.
*/
const NodeTree<T>* nth_child(int n) const
{
return const_cast<NodeTree<T>*>(this)->nth_child(n);
}
_IGNORE(g_node_nth_child)
/** Gets the first sibling
* @return The first sibling, or 0 if the node has no siblings.
*/
NodeTree<T>* first_sibling()
{
return wrap(g_node_first_sibling(gobj()));
}
/** Gets the first sibling
* @return The first sibling, or 0 if the node has no siblings.
*/
const NodeTree<T>* first_sibling() const
{
return const_cast<NodeTree<T>*>(this)->first_sibling();
}
_IGNORE(g_node_first_sibling)
/** Gets the previous sibling.
*
* @return The previous sibling, or 0 if the node has no siblings.
*/
NodeTree<T>* prev_sibling()
{
return wrap(g_node_prev_sibling(gobj()));
}
/** Gets the previous sibling.
*
* @return The previous sibling, or 0 if the node has no siblings.
*/
const NodeTree<T>* prev_sibling() const
{
return const_cast<NodeTree<T>*>(this)->prev_sibling();
}
_IGNORE(g_node_prev_sibling)
/** Gets the next sibling
*
* @return The next sibling, or 0 if the node has no siblings.
*/
NodeTree<T>* next_sibling()
{
return wrap(g_node_next_sibling(gobj()));
}
/** Gets the next sibling
*
* @return The next sibling, or 0 if the node has no siblings.
*/
const NodeTree<T>* next_sibling() const
{
return const_cast<NodeTree<T>*>(this)->next_sibling();
}
_IGNORE(g_node_next_sibling)
/** Gets the last sibling.
*
* @return The last sibling, or 0 if the node has no siblings.
*/
NodeTree<T>* last_sibling()
{
return wrap(g_node_last_sibling(gobj()));
}
/** Gets the last sibling.
*
* @return The last sibling, or 0 if the node has no siblings.
*/
const NodeTree<T>* last_sibling() const
{
return const_cast<NodeTree<T>*>(this)->last_sibling();
}
_IGNORE(g_node_last_sibling)
/** Returns true if this is a leaf node.
*
* @return true if this is a leaf node.
*/
bool is_leaf() const
{
return G_NODE_IS_LEAF(const_cast<GNode*>(gobj()));
}
/** Returns true if this is the root node.
*
* @return true if this is the root node.
*/
bool is_root() const
{
return G_NODE_IS_ROOT(const_cast<GNode*>(gobj()));
}
/** Gets the depth of this node.
* The root node has a depth of 1.
* For the children of the root node the depth is 2. And so on.
*
* @return the depth of this node
*/
guint depth() const
{
return g_node_depth(const_cast<GNode*>(gobj()));
}
_IGNORE(g_node_depth)
/** Gets the number of nodes in a tree.
*
* @param flags Which types of children are to be counted: one of TRAVERSE_ALL, TRAVERSE_LEAVES and TRAVERSE_NON_LEAVES
* @return The number of nodes in the tree.
*/
guint node_count(TraverseFlags flags = TRAVERSE_ALL) const
{
return g_node_n_nodes(const_cast<GNode*>(gobj()), (GTraverseFlags)flags);
}
_IGNORE(g_node_n_nodes)
/** Gets the number children.
*
* @return The number of children.
*/
guint child_count() const
{
return g_node_n_children(const_cast<GNode*>(gobj()));
}
_IGNORE(g_node_n_children)
/** Returns true if this is an ancestor of @a descendant.
* This is true if this is the parent of @a descendant,
* or if this is the grandparent of @a descendant etc.
*
* @param descendant A node.
* @return true if this is an ancestor of descendant.
*/
bool is_ancestor(const NodeTree<T>& descendant) const
{
return g_node_is_ancestor(const_cast<GNode*>(gobj()), const_cast<GNode*>(descendant.gobj()));
}
_IGNORE(g_node_is_ancestor)
/** Gets the maximum height of all branches beneath this node.
* This is the maximum distance from the node to all leaf nodes.
* If root has no children, 1 is returned. If root has children, 2 is returned. And so on.
*
* @return The maximum height of all branches.
*/
guint get_max_height() const
{
return g_node_max_height(const_cast<GNode*>(gobj()));
}
_IGNORE(g_node_max_height)
/** Unlinks a node from a tree, resulting in two separate trees.
*/
void unlink()
{
g_node_unlink(gobj());
}
_IGNORE(g_node_unlink)
#if 0 //Commented-out because people can just use the copy constructor.
/** Recursively copies a node and it's data.
*
* Returns: a new node containing the copies of the data.
*/
NodeTree<T>* copy_deep() const
{
//Use copy constructor instead of g_node_copy_deep to create C++ wrappers also not only the wrapped C objects.
return new NodeTree<T>(*this);
}
#endif
_IGNORE(g_node_copy_deep)
/// Accessor for this node's data
T& data()
{
return data_;
}
/// Accessor for this node's data
const T& data() const
{
return data_;
}
/** Accessor for this node's parent.
*
* @return The node's parent.
*/
const NodeTree<T>* parent() const
{
return wrap(gobj()->parent);
}
// Do not wrap this shallow copy function, because it is not useful:
_IGNORE(g_node_copy)
private:
void clear()
{
//Free the children (not just with g_node_destroy(), to avoid the leaking of C++ wrapper objects):
while(NodeTree<T>* i = first_child())
delete i;
//Free the wrapped object (g_node_free not available)
g_slice_free(GNode, gobject_);
gobject_ = 0;
}
///Create a new GNode, taking the contents of an existing node if one is specified.
void clone(const NodeTree<T>* node = 0)
{
//Store the this pointer in the GNode so we can discover this wrapper later:
gobject_ = g_node_new(reinterpret_cast<gpointer>(this));
if(node)
{
//Prepend the copied children of @node to the constructing node.
for(const NodeTree<T>* i = node->last_child(); i != 0; i = i->prev_sibling())
prepend(*(new NodeTree<T>(*i)));
}
}
/// Wrapper for invoking a TraverseFunc.
static gboolean c_callback_traverse(GNode* node, gpointer slot)
{
const TraverseFunc* tf = reinterpret_cast<const TraverseFunc*>(slot);
return (*tf)(*wrap(node));
}
/// Wrapper for invoking a ForeachFunc.
static void c_callback_foreach(GNode* node, gpointer slot)
{
const ForeachFunc* ff = reinterpret_cast<const ForeachFunc*>(slot);
(*ff)(*wrap(node));
}
/// Method for comparing a single child (Internal use).
static void on_compare_child(GNode* node, const T& needle, GNode** result)
{
if((0 != result) && (wrap(node)->data() == needle))
{
*result = node;
}
}
/// Wrapper for invoking a sigc::slot<void,GNode*> (Internal use).
static void c_callback_foreach_compare_child(GNode* node, gpointer data)
{
const ForeachFunc* slot = reinterpret_cast<const ForeachFunc*>(data);
(*slot)(*wrap(node));
}
/// Method for comparing a single node (Internal use).
static gboolean on_compare_node(GNode* node, const T& needle, GNode** result)
{
if(wrap(node)->data() == needle)
{
*result = node;
return TRUE;
}
return FALSE;
}
/// Wrapper for invoking a sigc::slot<gboolean,GNode*> (Internal use).
static gboolean c_callback_traverse_compare_node(GNode* node, gpointer data)
{
const TraverseFunc* slot = reinterpret_cast<const TraverseFunc*>(data);
return (*slot)(*wrap(node));
}
GNode* gobject_;
T data_;
};
} // namespace Glib

View file

@ -4,23 +4,23 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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 <glibmm/utility.h>
#include <glibmm/exceptionhandler.h>
#include <glib/goption.h>
#include <glib.h>
namespace Glib
{
@ -109,4 +109,9 @@ void OptionContext::set_translate_func (const SlotTranslate& slot)
&Private::SignalProxy_translate_gtk_callback_destroy);
}
Glib::ustring OptionContext::get_help(bool main_help) const
{
return Glib::convert_return_gchar_ptr_to_ustring(g_option_context_get_help(const_cast<GOptionContext*>(gobj()), static_cast<int>(main_help), NULL));
}
} // namespace Glib

View file

@ -3,16 +3,16 @@
/* Copyright (C) 2004 The glibmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -41,6 +41,7 @@ _WRAP_GERROR(OptionError, GOptionError, G_OPTION_ERROR, NO_GTYPE)
class OptionContext
{
_CLASS_GENERIC(OptionContext, GOptionContext)
_IGNORE(g_option_context_free)
public:
/** Creates a new option context.
@ -87,6 +88,11 @@ public:
//const OptionGroup& get_main_group() const;
_IGNORE(g_option_context_get_main_group)
#m4 _CONVERSION(`const OptionGroup&',`GOptionGroup*',`const_cast<GOptionGroup*>(($3).gobj())')
_WRAP_METHOD(Glib::ustring get_help(bool main_help, const OptionGroup& group) const, g_option_context_get_help)
//TODO: Documentation.
Glib::ustring get_help(bool main_help = true) const;
GOptionContext* gobj() { return gobject_; }
const GOptionContext* gobj() const { return gobject_; }

View file

@ -4,23 +4,22 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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 <glibmm/utility.h>
#include <glib/goption.h>
#include <glib/gmem.h>
#include <glib.h>
namespace Glib
{
@ -74,6 +73,42 @@ OptionEntry& OptionEntry::operator=(const OptionEntry& src)
return *this;
}
void OptionEntry::set_long_name(const Glib::ustring& value)
{
if(gobject_->long_name)
{
g_free((gchar*)(gobject_->long_name));
gobject_->long_name = NULL;
}
//Note that we do not use NULL for an empty string,
//because G_OPTION_REMAINING is actually a "", so it actually has a distinct meaning:
//TODO: Wrap G_OPTION_REMAINING in C++ somehow, maybe as an explicit set_long_name(void) or set_is_remaining()? murrayc.
gobj()->long_name = (value).c_str() ? g_strdup((value).c_str()) : NULL;
}
void OptionEntry::set_description(const Glib::ustring& value)
{
if(gobject_->description)
{
g_free((gchar*)(gobject_->description));
gobject_->description = NULL;
}
gobj()->description = (value).empty() ? NULL : g_strdup((value).c_str());
}
void OptionEntry::set_arg_description(const Glib::ustring& value)
{
if(gobject_->arg_description)
{
g_free((gchar*)(gobject_->arg_description));
gobject_->arg_description = NULL;
}
gobj()->arg_description = (value).empty() ? NULL : g_strdup((value).c_str());
}
} // namespace Glib

View file

@ -3,16 +3,16 @@
/* Copyright (C) 2004 The glibmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -65,10 +65,11 @@ public:
OptionEntry& operator=(const OptionEntry& src);
#m4 _CONVERSION(`Glib::ustring',`const gchar*',`g_strdup(($3).c_str())')
//#m4 _CONVERSION(`Glib::ustring',`const gchar*',`($3).empty() ? NULL : g_strdup(($3).c_str())')
_MEMBER_GET(long_name, long_name, Glib::ustring, const char*)
_MEMBER_SET(long_name, long_name, Glib::ustring, const char*)
void set_long_name(const Glib::ustring& value);
_MEMBER_GET(short_name, short_name, gchar, gchar)
_MEMBER_SET(short_name, short_name, gchar, gchar)
@ -79,10 +80,14 @@ public:
//TODO: G_OPTION_ARG_CALLBACK,
_MEMBER_GET(description, description, Glib::ustring, const char*)
_MEMBER_SET(description, description, Glib::ustring, const char*)
void set_description(const Glib::ustring& value);
_MEMBER_GET(arg_description, arg_description, Glib::ustring, const char*)
_MEMBER_SET(arg_description, arg_description, Glib::ustring, const char*)
void set_arg_description(const Glib::ustring& value);
GOptionEntry* gobj() { return gobject_; }
const GOptionEntry* gobj() const { return gobject_; }

View file

@ -4,16 +4,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -22,8 +22,7 @@
#include <glibmm/optioncontext.h>
#include <glibmm/utility.h>
//#include <glibmm/containers.h>
#include <glib/gmem.h> // g_malloc
#include <glib/goption.h>
#include <glib.h> // g_malloc
namespace Glib
{

View file

@ -3,16 +3,16 @@
/* Copyright (C) 2004 The glibmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -22,7 +22,7 @@ _DEFS(glibmm,glib)
#include <glibmm/ustring.h>
#include <map>
#include <vector>
#include <glib/goption.h> //TODO: Try to hide this.
#include <glib.h> //TODO: Try to hide this.
#ifndef DOXYGEN_SHOULD_SKIP_THIS

View file

@ -1,16 +1,16 @@
/* Copyright (C) 2007 The glibmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/

View file

@ -1,16 +1,16 @@
/* Copyright (C) 2007 The glibmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -21,7 +21,7 @@ _DEFS(glibmm,glib)
#include <glibmm/ustring.h>
#include <glibmm/error.h>
#include <glibmm/arrayhandle.h>
#include <glib/gregex.h>
#include <glib.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GRegex GRegex;
@ -99,7 +99,7 @@ public:
#ifdef GLIBMM_EXCEPTIONS_ENABLED
static Glib::RefPtr<Glib::Regex> create(const Glib::ustring& pattern, RegexCompileFlags compile_options = static_cast<RegexCompileFlags>(0), RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0));
#else
static Glib::RefPtr<Glib::Regex> create(const Glib::ustring& pattern, RegexCompileFlags compile_options = static_cast<RegexCompileFlags>(0), RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0), std::auto_ptr<Glib::Error>& error);
static Glib::RefPtr<Glib::Regex> create(const Glib::ustring& pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
#endif /* !GLIBMM_EXCEPTIONS_ENABLED */
_WRAP_METHOD(Glib::ustring get_pattern() const, g_regex_get_pattern)

View file

@ -4,16 +4,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/

View file

@ -3,23 +3,23 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
_DEFS(glibmm,glib)
#include <glib/gshell.h>
#include <glib.h>
#include <string>
#include <glibmm/arrayhandle.h>

View file

@ -6,16 +6,16 @@ dnl Copyright 2001 Free Software Foundation
dnl Copyright 1999 Karl Nelson <kenelson@ece.ucdavis.edu>
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Library General Public
dnl modify it under the terms of the GNU Lesser General Public
dnl License as published by the Free Software Foundation; either
dnl version 2 of the License, or (at your option) any later version.
dnl version 2.1 of the License, or (at your option) any later version.
dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Library General Public License for more details.
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Library General Public
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free
dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
dnl

View file

@ -4,21 +4,21 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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 <glib/gspawn.h>
#include <glib.h>
#include <glibmm/exceptionhandler.h>
#include <glibmm/utility.h>
@ -70,6 +70,7 @@ namespace Glib
/**** process spawning functions *******************************************/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
@ -79,10 +80,21 @@ void spawn_async_with_pipes(const std::string& working_directory,
int* standard_input,
int* standard_output,
int* standard_error)
#else
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid,
int* standard_input,
int* standard_output,
int* standard_error, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
GError* error = 0;
GError* gerror = 0;
g_spawn_async_with_pipes(
working_directory.c_str(),
@ -93,12 +105,18 @@ void spawn_async_with_pipes(const std::string& working_directory,
(setup_slot) ? &child_setup_ : 0,
child_pid,
standard_input, standard_output, standard_error,
&error);
&gerror);
if(error)
Glib::Error::throw_exception(error);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
@ -107,10 +125,20 @@ void spawn_async_with_pipes(const std::string& working_directory,
int* standard_input,
int* standard_output,
int* standard_error)
#else
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid,
int* standard_input,
int* standard_output,
int* standard_error, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
GError* error = 0;
GError* gerror = 0;
g_spawn_async_with_pipes(
working_directory.c_str(),
@ -120,22 +148,36 @@ void spawn_async_with_pipes(const std::string& working_directory,
(setup_slot) ? &child_setup_ : 0,
child_pid,
standard_input, standard_output, standard_error,
&error);
&gerror);
if(error)
Glib::Error::throw_exception(error);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid)
#else
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
GError* error = 0;
GError* gerror = 0;
g_spawn_async(
working_directory.c_str(),
@ -145,21 +187,34 @@ void spawn_async(const std::string& working_directory,
(setup_slot) ? &child_setup_callback : 0,
(setup_slot) ? &child_setup_ : 0,
child_pid,
&error);
&gerror);
if(error)
Glib::Error::throw_exception(error);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid)
#else
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
GError* error = 0;
GError* gerror = 0;
g_spawn_async(
working_directory.c_str(),
@ -168,12 +223,18 @@ void spawn_async(const std::string& working_directory,
(setup_slot) ? &child_setup_callback : 0,
(setup_slot) ? &child_setup_ : 0,
child_pid,
&error);
&gerror);
if(error)
Glib::Error::throw_exception(error);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
@ -182,13 +243,23 @@ void spawn_sync(const std::string& working_directory,
std::string* standard_output,
std::string* standard_error,
int* exit_status)
#else
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
std::string* standard_output,
std::string* standard_error,
int* exit_status, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
Glib::ScopedPtr<char> buf_standard_output;
Glib::ScopedPtr<char> buf_standard_error;
GError* error = 0;
GError* gerror = 0;
g_spawn_sync(
working_directory.c_str(),
@ -200,15 +271,21 @@ void spawn_sync(const std::string& working_directory,
(standard_output) ? buf_standard_output.addr() : 0,
(standard_error) ? buf_standard_error.addr() : 0,
exit_status,
&error);
&gerror);
if(error)
Glib::Error::throw_exception(error);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
copy_output_buf(standard_output, buf_standard_output.get());
copy_output_buf(standard_error, buf_standard_error.get());
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
@ -216,13 +293,22 @@ void spawn_sync(const std::string& working_directory,
std::string* standard_output,
std::string* standard_error,
int* exit_status)
#else
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
std::string* standard_output,
std::string* standard_error,
int* exit_status, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
Glib::ScopedPtr<char> buf_standard_output;
Glib::ScopedPtr<char> buf_standard_error;
GError* error = 0;
GError* gerror = 0;
g_spawn_sync(
working_directory.c_str(),
@ -233,42 +319,68 @@ void spawn_sync(const std::string& working_directory,
(standard_output) ? buf_standard_output.addr() : 0,
(standard_error) ? buf_standard_error.addr() : 0,
exit_status,
&error);
&gerror);
if(error)
Glib::Error::throw_exception(error);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
copy_output_buf(standard_output, buf_standard_output.get());
copy_output_buf(standard_error, buf_standard_error.get());
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_command_line_async(const std::string& command_line)
#else
void spawn_command_line_async(const std::string& command_line, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
GError* error = 0;
g_spawn_command_line_async(command_line.c_str(), &error);
GError* gerror = 0;
g_spawn_command_line_async(command_line.c_str(), &gerror);
if(error)
Glib::Error::throw_exception(error);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_command_line_sync(const std::string& command_line,
std::string* standard_output,
std::string* standard_error,
int* exit_status)
#else
void spawn_command_line_sync(const std::string& command_line,
std::string* standard_output,
std::string* standard_error,
int* exit_status, std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
Glib::ScopedPtr<char> buf_standard_output;
Glib::ScopedPtr<char> buf_standard_error;
GError* error = 0;
GError* gerror = 0;
g_spawn_command_line_sync(
command_line.c_str(),
(standard_output) ? buf_standard_output.addr() : 0,
(standard_error) ? buf_standard_error.addr() : 0,
exit_status,
&error);
&gerror);
if(error)
Glib::Error::throw_exception(error);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
copy_output_buf(standard_output, buf_standard_output.get());
copy_output_buf(standard_error, buf_standard_error.get());

View file

@ -3,16 +3,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -44,7 +44,155 @@ _WRAP_ENUM(SpawnFlags, GSpawnFlags, NO_GTYPE)
*/
_WRAP_GERROR(SpawnError, GSpawnError, G_SPAWN_ERROR, NO_GTYPE, s#^2BIG$#TOOBIG#)
/** Executes a child program asynchronously (your program will not
* block waiting for the child to exit). The child program is
* specified by the only argument that must be provided, @a argv.
* The first string in @a argv is of
* course the name of the program to execute. By default, the name of
* the program must be a full path; the PATH shell variable
* will only be searched if you pass the SPAWN_SEARCH_PATH flag.
*
* On Windows, note that all the string or string vector arguments to
* this function and the other spawn*() functions are in UTF-8, the
* GLib file name encoding. Unicode characters that are not part of
* the system codepage passed in these arguments will be correctly
* available in the spawned program only if it uses wide character API
* to retrieve its command line. For C programs built with Microsoft's
* tools it is enough to make the program have a wmain() instead of
* main(). wmain() has a wide character argument vector as parameter.
*
* At least currently, mingw doesn't support wmain(), so if you use
* mingw to develop the spawned program, it will have to call the
* undocumented function __wgetmainargs() to get the wide character
* argument vector and environment. See gspawn-win32-helper.c in the
* GLib sources or init.c in the mingw runtime sources for a prototype
* for that function. Alternatively, you can retrieve the Win32 system
* level wide character command line passed to the spawned program
* using the GetCommandLineW() function.
*
* On Windows the low-level child process creation API
* CreateProcess() doesn't use argument vectors,
* but a command line. The C runtime library's
* spawn*() family of functions (which
* spawn_async_with_pipes() eventually calls) paste the argument
* vector elements together into a command line, and the C runtime startup code
* does a corresponding reconstruction of an argument vector from the
* command line, to be passed to main(). Complications arise when you have
* argument vector elements that contain spaces of double quotes. The
* spawn*() functions don't do any quoting or
* escaping, but on the other hand the startup code does do unquoting
* and unescaping in order to enable receiving arguments with embedded
* spaces or double quotes. To work around this asymmetry,
* spawn_async_with_pipes() will do quoting and escaping on argument
* vector elements that need it before calling the C runtime
* spawn() function.
*
* @a envp is a lists of strings, where each string
* has the form KEY=VALUE. This will become
* the child's environment.
*
* @a flags should be the bitwise OR of any flags you want to affect the
* function's behaviour. The SPAWN_DO_NOT_REAP_CHILD flags means that
* the child will not automatically be reaped; you must use a
* ChildWatch source to be notified about the death of the child
* process. Eventually you must call spawn_close_pid() on the
* @a child_pid, in order to free resources which may be associated
* with the child process. (On Unix, using a ChildWatch source is
* equivalent to calling waitpid() or handling the SIGCHLD signal
* manually. On Windows, calling spawn_close_pid() is equivalent
* to calling CloseHandle() on the process handle returned in
* @a child_pid).
*
* PAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
* descriptors will be inherited by the child; otherwise all
* descriptors except stdin/stdout/stderr will be closed before
* calling exec() in the child. SPAWN_SEARCH_PATH
* means that argv[0] need not be an absolute path, it
* will be looked for in the user's PATH.
* SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will
* be discarded, instead of going to the same location as the parent's
* standard output. If you use this flag, @a standard_output must be NULL.
* SPAWN_STDERR_TO_DEV_NULL means that the child's standard error
* will be discarded, instead of going to the same location as the parent's
* standard error. If you use this flag, @a standard_error must be NULL.
* SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's
* standard input (by default, the child's standard input is attached to
* /dev/null). If you use this flag, @a standard_input must be NULL.
* G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @a argv is
* the file to execute, while the remaining elements are the
* actual argument vector to pass to the file. Normally
* spawn_async_with_pipes() uses argv[0] as the file to execute, and
* passes all of @a argv to the child.
*
* @a child_setup is a callback slot. On POSIX
* platforms, the function is called in the child after GLib has
* performed all the setup it plans to perform (including creating
* pipes, closing file descriptors, etc.) but before calling
* exec(). That is, @a child_setup is called just
* before calling exec() in the child. Obviously
* actions taken in this function will only affect the child, not the
* parent. On Windows, there is no separate fork() and exec()
* functionality. Child processes are created and run with
* a single API call, CreateProcess(). @a child_setup is
* called in the parent process just before creating the child
* process. You should carefully consider what you do in @a child_setup
* if you intend your software to be portable to Windows.
*
* If non-NULL, @a child_pid will on Unix be filled with the child's
* process ID. You can use the process ID to send signals to the
* child, or to use child_watch_add() (or waitpid()) if you specified the
* SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @a child_pid will be
* filled with a handle to the child process only if you specified the
* SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
* process using the Win32 API, for example wait for its termination
* with the WaitFor*() functions, or examine its
* exit code with GetExitCodeProcess(). You should close the handle
* with CloseHandle() or spawn_close_pid() when you no longer need it.
*
* If non-NULL, the @a standard_input, @a standard_output, @a standard_error
* locations will be filled with file descriptors for writing to the child's
* standard input or reading from its standard output or standard error.
* The caller of pawn_async_with_pipes() must close these file descriptors
* when they are no longer in use. If these parameters are NULL, the corresponding
* pipe won't be created.
*
* If @a standard_input is NULL, the child's standard input is attached to
* /dev/null unless SPAWN_CHILD_INHERITS_STDIN is set.
*
* If @a standard_error is NULL, the child's standard error goes to the same
* location as the parent's standard error unless SPAWN_STDERR_TO_DEV_NULL
* is set.
*
* If @a standard_output is NULL, the child's standard output goes to the same
* location as the parent's standard output unless SPAWN_STDOUT_TO_DEV_NULL
* is set.
*
* If @a child_pid is not NULL and an error does not occur then the returned
* pid must be closed using spawn_close_pid().
*
* @note
* If you are writing a gtkmm application, and the program you
* are spawning is a graphical application, too, then you may
* want to use spawn_on_screen_with_pipes() instead to ensure that
* the spawned program opens its windows on the right screen.
*
* @param working_directory Child's current working directory, or an empty string to inherit the parent's, in the GLib file name encoding.
* @param argv Child's argument vector.
* @param envp Child's environment.
* @param flags Flags from SpawnFlags
* @param child_setup Slot to run in the child just before exec().
* @param child_pid Return location for child process ID, or NULL.
* @param standard_input Return location for file descriptor to write to child's stdin, or NULL.
* @param standard_output Return location for file descriptor to read child's stdout, or NULL.
* @param standard_error Return location for file descriptor to read child's stderr, or NULL.
*
* @throws SpawnError Errors are reported even if they occur in the child (for example if the
* executable in argv[0] is not found). Typically
* the message field of returned errors should be displayed
* to users. If an error occurs, @a child_pid, @a standard_input, @a standard_output,
* and @a standard_error will not be filled with valid values.
*/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
@ -54,7 +202,36 @@ void spawn_async_with_pipes(const std::string& working_directory,
int* standard_input = 0,
int* standard_output = 0,
int* standard_error = 0);
#else
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid,
int* standard_input,
int* standard_output,
int* standard_error, std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
/** Like the main spawn_async_with_pipes() method, but inheriting the parent's environment.
*
* @param working_directory Child's current working directory, or an empty string to inherit the parent's, in the GLib file name encoding.
* @param argv Child's argument vector.
* @param flags Flags from SpawnFlags
* @param child_setup Slot to run in the child just before exec().
* @param child_pid Return location for child process ID, or NULL.
* @param standard_input Return location for file descriptor to write to child's stdin, or NULL.
* @param standard_output Return location for file descriptor to read child's stdout, or NULL.
* @param standard_error Return location for file descriptor to read child's stderr, or NULL.
*
* @throws SpawnError Errors are reported even if they occur in the child (for example if the
* executable in argv[0] is not found). Typically
* the message field of returned errors should be displayed
* to users. If an error occurs, @a child_pid, @a standard_input, @a standard_output,
* and @a standard_error will not be filled with valid values.
*/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags = SpawnFlags(0),
@ -63,20 +240,115 @@ void spawn_async_with_pipes(const std::string& working_directory,
int* standard_input = 0,
int* standard_output = 0,
int* standard_error = 0);
#else
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid,
int* standard_input,
int* standard_output,
int* standard_error, std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
/** See pawn_async_with_pipes() for a full description. This function
* simply calls the spawn_async_with_pipes() without any pipes.
*
* @note
* If you are writing a GTK+ application, and the program you
* are spawning is a graphical application, too, then you may
* want to use gdk_spawn_on_screen() instead to ensure that
* the spawned program opens its windows on the right screen.
*
* @param working_directory Child's current working directory, or an empty string to inherit parent's.
* @param argv Child's argument vector.
* @param env Child's environment.
* @param flags Flags from SpawnFlags.
* @param child_setup Slot to run in the child just before exec().
* @param child_pid Return location for child process ID, or NULL
*
* @throws SpawnError Errors are reported even if they occur in the child (for example if the
* executable in argv[0] is not found). Typically
* the message field of returned errors should be displayed
* to users.
*/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
SpawnFlags flags = SpawnFlags(0),
const sigc::slot<void>& child_setup = sigc::slot<void>(),
Pid* child_pid = 0);
#else
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid, std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
/** Like the main spawn_async() method, but inheriting the parent's environment.
*
* @param working_directory Child's current working directory, or an empty string to inherit parent's.
* @param argv Child's argument vector.
* @param env Child's environment.
* @param flags Flags from SpawnFlags.
* @param child_setup Slot to run in the child just before exec().
* @param child_pid Return location for child process ID, or NULL
*
* @throws SpawnError Errors are reported even if they occur in the child (for example if the
* executable in argv[0] is not found). Typically
* the message field of returned errors should be displayed
* to users.
*/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags = SpawnFlags(0),
const sigc::slot<void>& child_setup = sigc::slot<void>(),
Pid* child_pid = 0);
#else
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid, std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
/** Executes a child synchronously (waits for the child to exit before returning).
* All output from the child is stored in @a standard_output and @a standard_error,
* if those parameters are non-NULL. Note that you must set the
* SPAWN_STDOUT_TO_DEV_NULL and SPAWN_STDERR_TO_DEV_NULL flags when
* passing NULL for @a standard_output and @a standard_error.
* If @a exit_status is non-NULL, the exit status of the child is stored
* there as it would be returned by waitpid(); standard UNIX macros such
* as WIFEXITED() and WEXITSTATUS() must be used to evaluate the exit status.
* Note that this function calls waitpid() even if @a exit_status is NULL, and
* does not accept the SPAWN_DO_NOT_REAP_CHILD flag.
* If an error occurs, no data is returned in @a standard_output,
* @a standard_error, or @a exit_status.
*
* This function calls spawn_async_with_pipes() internally; see that
* function for full details on the other parameters and details on
* how these functions work on Windows.
*
* @param working_directory Child's current working directory, or an empty string to inherit the parent's, in the GLib file name encoding.
* @param argv Child's argument vector.
* @param envp Child's environment.
* @param flags Flags from SpawnFlags
* @param child_setup Slot to run in the child just before exec().
* @param standard_output Return location for file descriptor to read child's stdout, or NULL.
* @param standard_error Return location for file descriptor to read child's stderr, or NULL.
* @param exit_status Return location for child exit status, as returned by waitpid(), or NULL
*
* @throws SpawnError Errors are reported even if they occur in the child (for example if the
* executable in argv[0] is not found). Typically
* the message field of returned errors should be displayed
* to users. If an error occurs, @a child_pid, @a standard_input, @a standard_output,
* and @a standard_error will not be filled with valid values.
*/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
@ -85,7 +357,34 @@ void spawn_sync(const std::string& working_directory,
std::string* standard_output = 0,
std::string* standard_error = 0,
int* exit_status = 0);
#else
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
std::string* standard_output,
std::string* standard_error,
int* exit_status, std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
/** Like the main spawn_sync() method, but inheriting the parent's environment.
*
* @param working_directory Child's current working directory, or an empty string to inherit the parent's, in the GLib file name encoding.
* @param argv Child's argument vector.
* @param flags Flags from SpawnFlags
* @param child_setup Slot to run in the child just before exec().
* @param standard_output Return location for file descriptor to read child's stdout, or NULL.
* @param standard_error Return location for file descriptor to read child's stderr, or NULL.
* @param exit_status Return location for child exit status, as returned by waitpid(), or NULL
*
* @throws SpawnError Errors are reported even if they occur in the child (for example if the
* executable in argv[0] is not found). Typically
* the message field of returned errors should be displayed
* to users. If an error occurs, @a child_pid, @a standard_input, @a standard_output,
* and @a standard_error will not be filled with valid values.
*/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags = SpawnFlags(0),
@ -93,14 +392,91 @@ void spawn_sync(const std::string& working_directory,
std::string* standard_output = 0,
std::string* standard_error = 0,
int* exit_status = 0);
#else
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
std::string* standard_output,
std::string* standard_error ,
int* exit_status, std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
/** A simple version of spawn_async() that parses a command line with
* shell_parse_argv() and passes it to spawn_async(). It runs a
* command line in the background. Unlike spawn_async(), the
* SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note
* that SPAWN_SEARCH_PATH can have security implications, so
* consider using spawn_async() directly if appropriate.
*
* The same concerns on Windows apply as for spawn_command_line_sync().
*
* @param command_line A command line.
*
* @throws SpawnError Errors are reported even if they occur in the child (for example if the
* executable in argv[0] is not found). Typically
* the message field of returned errors should be displayed
* to users.
* @throws ShellError If the command line could not be parsed.
*/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_command_line_async(const std::string& command_line);
#else
void spawn_command_line_async(const std::string& command_line, std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
/** A simple version of spawn_sync() with little-used parameters
* removed, taking a command line instead of an argument vector. See
* spawn_sync() for full details. @a command_line will be parsed by
* shell_parse_argv(). Unlike spawn_sync(), the SPAWN_SEARCH_PATH flag
* is enabled. Note that SPAWN_SEARCH_PATH can have security
* implications, so consider using spawn_sync() directly if
* appropriate.
*
* If @a exit_status is non-NULL, the exit status of the child is stored there as
* it would be returned by waitpid(); standard UNIX macros such as WIFEXITED()
* and WEXITSTATUS() must be used to evaluate the exit status.
*
* On Windows, please note the implications of shell_parse_argv()
* parsing @a command_line. Parsing is done according to Unix shell rules, not
* Windows command interpreter rules.
* Space is a separator, and backslashes are
* special. Thus you cannot simply pass a @a command_line containing
* canonical Windows paths, like "c:\\program files\\app\\app.exe", as
* the backslashes will be eaten, and the space will act as a
* separator. You need to enclose such paths with single quotes, like
* "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".
*
* @param command_line A command line.
* @param standard_output Return location for child output.
* @param standard_error Return location for child errors.
* @param exit_status Return location for child exit status, as returned by waitpid().
*
* @throws SpawnError Errors are reported even if they occur in the child (for example if the
* executable in argv[0] is not found). Typically
* the message field of returned errors should be displayed
* to users.
* @throws ShellError If the command line could not be parsed.
*/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_command_line_sync(const std::string& command_line,
std::string* standard_output = 0,
std::string* standard_error = 0,
int* exit_status = 0);
#else
void spawn_command_line_sync(const std::string& command_line,
std::string* standard_output,
std::string* standard_error,
int* exit_status, std::auto_ptr<Glib::Error>& error;
#endif //GLIBMM_EXCEPTIONS_ENABLED
/** On some platforms, notably WIN32, the Pid type represents a resource
* which must be closed to prevent resource leaking. close_pid()
* is provided for this purpose. It should be used on all platforms, even
* though it doesn't do anything under UNIX.
*
* @param pid The process identifier to close.
*/
void spawn_close_pid(Pid pid);
/** @} group Spawn */

View file

@ -7,16 +7,16 @@ dnl
dnl Currently maintained by Tero Pulkkinen. <terop@modeemi.cs.tut.fi>
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Library General Public
dnl modify it under the terms of the GNU Lesser General Public
dnl License as published by the Free Software Foundation; either
dnl version 2 of the License, or (at your option) any later version.
dnl version 2.1 of the License, or (at your option) any later version.
dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Library General Public License for more details.
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Library General Public
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free
dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
dnl

View file

@ -4,16 +4,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/

View file

@ -3,23 +3,23 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
_DEFS(glibmm,glib)
#include <glib/gthread.h>
#include <glib.h>
#include <cstddef>
#include <sigc++/sigc++.h>
@ -174,6 +174,7 @@ class Thread
public:
class Exit;
//See http://bugzilla.gnome.org/show_bug.cgi?id=512348 about the sigc::trackable issue.
/** Creates a new thread with the priority <tt>THREAD_PRIORITY_NORMAL</tt>.
* If @a joinable is @c true, you can wait for this thread's termination by
* calling join(). Otherwise the thread will just disappear, when ready.
@ -182,6 +183,10 @@ public:
* pass additional arguments using sigc::bind(). If the thread was created
* successfully, it is returned, otherwise a ThreadError exception is thrown.
*
* Because sigc::trackable is not thread safe, if the slot represents a
* non-static class method (that is, it is created by sigc::mem_fun()), the
* class concerned should not derive from sigc::trackable.
*
* @param slot A slot to execute in the new thread.
* @param joinable Should this thread be joinable?
* @return The new Thread* on success.
@ -189,6 +194,7 @@ public:
*/
static Thread* create(const sigc::slot<void>& slot, bool joinable);
//See http://bugzilla.gnome.org/show_bug.cgi?id=512348 about the sigc::trackable issue.
/** Creates a new thread with the priority @a priority. The stack gets the
* size @a stack_size or the default value for the current platform, if
* @a stack_size is <tt>0</tt>.
@ -204,6 +210,10 @@ public:
* pass additional arguments using sigc::bind(). If the thread was created
* successfully, it is returned.
*
* Because sigc::trackable is not thread safe, if the slot represents a
* non-static class method (that is, it is created by sigc::mem_fun()), the
* class concerned should not derive from sigc::trackable.
*
* @note It is not guaranteed, that threads with different priorities really
* behave accordingly. On some systems (e.g. Linux) only root can increase
* priorities. On other systems (e.g. Solaris) there doesn't seem to be

View file

@ -4,16 +4,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/

View file

@ -3,16 +3,16 @@
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* 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
* Library General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* 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.
*/
@ -43,9 +43,7 @@ inline $1 $2(char c)
_POP()
#m4end
#include <glib/gmacros.h>
#include <glib/gstrfuncs.h>
#include <glib/gunicode.h>
#include <glib.h>
// Not used, but we want to get rid of possible <ctype.h> macros.
#include <cctype>

View file

@ -0,0 +1,45 @@
// -*- c++ -*-
/* $Id: fileutils.ccg,v 1.1 2003/01/07 16:58:25 murrayc Exp $ */
/* Copyright (C) 2002 The gtkmm 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 <glib.h>
#include <glibmm/utility.h>
namespace Glib
{
std::string uri_unescape_string(const std::string& escaped_string, const std::string& illegal_characters)
{
gchar* cresult = g_uri_unescape_string(escaped_string.c_str(), illegal_characters.c_str());
return Glib::convert_return_gchar_ptr_to_stdstring(cresult);
}
std::string uri_parse_scheme(const std::string& uri)
{
return Glib::convert_return_gchar_ptr_to_stdstring( g_uri_parse_scheme(uri.c_str()) );
}
std::string uri_escape_string(const std::string& unescaped, const std::string& reserved_chars_allowed, bool allow_utf8)
{
gchar* cresult = g_uri_escape_string(unescaped.c_str(), reserved_chars_allowed.c_str(), allow_utf8);
return Glib::convert_return_gchar_ptr_to_stdstring(cresult);
}
} // namespace Glib

View file

@ -0,0 +1,93 @@
/* $Id: fileutils.hg,v 1.3 2004/01/22 18:38:12 murrayc Exp $ */
/* Copyright (C) 2002 The gtkmm 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.
*/
_DEFS(glibmm,glib)
#include <string>
#include <glibmmconfig.h>
GLIBMM_USING_STD(string)
namespace Glib
{
/** @defgroup UriUtils URI Utilities
* Various uri-related functions.
*/
//Note that the illegal_characters and reserved_chars_allowed parameters are bytes and may not be UTF-8
//so they are not Glib::ustring. See http://bugzilla.gnome.org/show_bug.cgi?id=508773
/** Unescapes a whole escaped string.
* If any of the characters in @a illegal_characters or the character zero appears
* as an escaped character in @a escaped_string then that is an error and an empty string
* will be returned. This is useful it you want to avoid, for instance, having a
* slash being expanded in an escaped path element, which might confuse pathname
* handling.
*
* @param escaped_string An escaped string to be unescaped.
* @param illegal_characters An optional string of illegal characters not to be allowed.
* @result An unescaped version of @a escaped_string.
*
* @ingroup UriUtils
* @newin2p16
*/
std::string uri_unescape_string(const std::string& escaped_string, const std::string& illegal_characters = std::string());
//TODO: Use iterator?
//char * g_uri_unescape_segment (const char *escaped_string,
// const char *escaped_string_end,
// const char *illegal_characters);
/** Gets the scheme portion of a URI. RFC 3986 decodes the scheme as:
* @code
* URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
* @endcode
* Common schemes include "file", "http", "svn+ssh", etc.
*
* @param uri
* @result The "Scheme" component of the URI, or an empty string on error.
*
* @ingroup UriUtils
* @newin2p16
*/
std::string uri_parse_scheme(const std::string& uri);
/** Escapes a string for use in a URI.
*
* Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
* characters plus dash, dot, underscore and tilde) are escaped.
* But if you specify characters in @a reserved_chars_allowed they are not
* escaped. This is useful for the "reserved" characters in the URI
* specification, since those are allowed unescaped in some portions of
* a URI.
*
* @param unescaped The unescaped input string.
* @param reserved_chars_allowed A string of reserved characters that are allowed to be used.
* @param allow_utf8 true if the result can include UTF-8 characters.
* @result An escaped version of @a unescaped.
*
* @ingroup UriUtils
* @newin2p16
*/
std::string uri_escape_string(const std::string& unescaped, const std::string& reserved_chars_allowed = std::string(), bool allow_utf8 = true);
} // namespace Glib

View file

@ -1,22 +1,22 @@
divert(-1)
dnl $Id: value_basictypes.cc.m4 348 2006-11-22 11:14:43Z murrayc $
dnl $Id: value_basictypes.cc.m4 779 2009-01-19 17:58:50Z murrayc $
dnl Glib::Value specializations for fundamental types
dnl
dnl Copyright 2002 The gtkmm Development Team
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Library General Public
dnl modify it under the terms of the GNU Lesser General Public
dnl License as published by the Free Software Foundation; either
dnl version 2 of the License, or (at your option) any later version.
dnl version 2.1 of the License, or (at your option) any later version.
dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Library General Public License for more details.
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Library General Public
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free
dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

View file

@ -1,22 +1,22 @@
divert(-1)
dnl $Id: value_basictypes.h.m4 2 2003-01-07 16:59:16Z murrayc $
dnl $Id: value_basictypes.h.m4 779 2009-01-19 17:58:50Z murrayc $
dnl Glib::Value specializations for fundamental types
dnl
dnl Copyright 2002 The gtkmm Development Team
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Library General Public
dnl modify it under the terms of the GNU Lesser General Public
dnl License as published by the Free Software Foundation; either
dnl version 2 of the License, or (at your option) any later version.
dnl version 2.1 of the License, or (at your option) any later version.
dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Library General Public License for more details.
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Library General Public
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free
dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.