diff options
author | José Alburquerque <jaalburqu@svn.gnome.org> | 2011-06-14 18:03:59 -0400 |
---|---|---|
committer | José Alburquerque <jaalburqu@svn.gnome.org> | 2011-06-14 18:03:59 -0400 |
commit | 4e45a5aae66f037184cff646591c40c66bad39b2 (patch) | |
tree | a324f71f4fda50d4658def7b18c657b48bd559c8 | |
parent | 026ef4d9484202e1f9c1e713e4600f398c86c3ce (diff) | |
download | glibmm-4e45a5aae66f037184cff646591c40c66bad39b2.tar.gz |
glibmm: Add TimeZone and partial DateTime classes.
* glib/src/datetime.{ccg,hg}:
* glib/src/timezone.{ccg,hg}:
* glib/src/filelist.am: Add the new sources and mention them in the
build structure so they are processed.
* glib/src/glib_extra_objects.defs: Include object definitions of the
new classes so there are no gmmproc warnings when parsing the docs.
* tools/m4/convert_glib.m4: Add necessary conversions.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | glib/src/datetime.ccg | 26 | ||||
-rw-r--r-- | glib/src/datetime.hg | 79 | ||||
-rw-r--r-- | glib/src/filelist.am | 6 | ||||
-rw-r--r-- | glib/src/glib_extra_objects.defs | 22 | ||||
-rw-r--r-- | glib/src/timezone.ccg | 23 | ||||
-rw-r--r-- | glib/src/timezone.hg | 74 | ||||
-rw-r--r-- | tools/m4/convert_glib.m4 | 38 |
8 files changed, 264 insertions, 17 deletions
@@ -1,6 +1,19 @@ 2011-06-14 José Alburquerque <jaalburqu@svn.gnome.org> + glibmm: Add TimeZone and partial DateTime classes. + + * glib/src/datetime.{ccg,hg}: + * glib/src/timezone.{ccg,hg}: + * glib/src/filelist.am: Add the new sources and mention them in the + build structure so they are processed. + * glib/src/glib_extra_objects.defs: Include object definitions of the + new classes so there are no gmmproc warnings when parsing the docs. + * tools/m4/convert_glib.m4: Add necessary conversions. + +2011-06-14 José Alburquerque <jaalburqu@svn.gnome.org> + + glibmm: Regenerate the defs and xml doc files. * glib/src/glib_docs.xml: diff --git a/glib/src/datetime.ccg b/glib/src/datetime.ccg new file mode 100644 index 00000000..f27df969 --- /dev/null +++ b/glib/src/datetime.ccg @@ -0,0 +1,26 @@ +/* Copyright (C) 2011 The 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. + */ + +#include <glibmm/utility.h> +#include <glibmm/timeval.h> +#include <glibmm/timezone.h> +#include <glibmm/wrap.h> + +namespace Glib +{ + +}// namespace Glib diff --git a/glib/src/datetime.hg b/glib/src/datetime.hg new file mode 100644 index 00000000..88d9db26 --- /dev/null +++ b/glib/src/datetime.hg @@ -0,0 +1,79 @@ +/* Copyright (C) 2011 The 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 <glibmmconfig.h> +#include <glibmm/refptr.h> +#include <glibmm/ustring.h> +#include <glib.h> + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +typedef struct _GDateTime GDateTime; +#endif + +namespace Glib +{ + +class TimeVal; +class TimeZone; + +/** DateTime - A structure representing Date and Time. + * DateTime is a structure that combines a Gregorian date and time into a + * single structure. It provides many conversion and methods to manipulate + * dates and times. Time precision is provided down to microseconds and the + * time can range (proleptically) from 0001-01-01 00:00:00 to 9999-12-31 + * 23:59:59.999999. DateTime follows POSIX time in the sense that it is + * oblivious to leap seconds. + * + * DateTime is an immutable object; once it has been created it cannot be + * modified further. All modifiers will create a new DateTime. Nearly all such + * functions can fail due to the date or time going out of range, in which case + * <tt>0</tt> will be returned. + * + * DateTime is reference counted. When the reference count drops to 0, the + * resources allocated by the DateTime structure are released. + * + * Many parts of the API may produce non-obvious results. As an example, adding + * two months to January 31st will yield March 31st whereas adding one month + * and then one month again will yield either March 28th or March 29th. Also + * note that adding 24 hours is not always the same as adding one day (since + * days containing daylight savings time transitions are either 23 or 25 hours + * in length). + * @newin{2,30} + */ +class DateTime +{ + _CLASS_OPAQUE_REFCOUNTED(DateTime, GDateTime, NONE, g_date_time_ref, g_date_time_unref) + _IGNORE(g_date_time_ref, g_date_time_unref) + +public: + _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now(const Glib::RefPtr<const TimeZone>& timezone), g_date_time_new_now) + _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now_local(), g_date_time_new_now_local) + _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now_utc(), g_date_time_new_now_utc) + + _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now_local(gint64 t), g_date_time_new_from_unix_local) + _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now_utc(gint64 t), g_date_time_new_from_unix_utc) + + _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now_local(const TimeVal& tv), g_date_time_new_from_timeval_local) + _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now_utc(const TimeVal& tv), g_date_time_new_from_timeval_utc) + + //TODO: Wrap the create() methods not creating now instances. + //TODO: Wrap the the rest of the methods. +}; + +} // namespace Glib diff --git a/glib/src/filelist.am b/glib/src/filelist.am index 64ffa229..01ab6085 100644 --- a/glib/src/filelist.am +++ b/glib/src/filelist.am @@ -18,6 +18,7 @@ glibmm_files_hg = \ checksum.hg \ convert.hg \ date.hg \ + datetime.hg \ fileutils.hg \ iochannel.hg \ keyfile.hg \ @@ -31,11 +32,12 @@ glibmm_files_hg = \ shell.hg \ spawn.hg \ thread.hg \ + timezone.hg \ unicode.hg \ uriutils.hg \ valuearray.hg \ - variant.hg \ - variantiter.hg \ + variant.hg \ + variantiter.hg \ varianttype.hg glibmm_files_ccg = $(glibmm_files_hg:.hg=.ccg) diff --git a/glib/src/glib_extra_objects.defs b/glib/src/glib_extra_objects.defs index cc291005..9dd327a7 100644 --- a/glib/src/glib_extra_objects.defs +++ b/glib/src/glib_extra_objects.defs @@ -6,18 +6,17 @@ ; that are mentioned in documentation text. ; (DocsParser.pm:substitute_function(), which uses GtkDefs.pm:lookup_object().) -(define-object OptionContext - (in-module "GLib") - (c-name "GOptionContext") - (gtype-id "G_TYPE_OPTION_CONTEXT") -) - (define-object Checksum (in-module "GLib") (c-name "GChecksum") (gtype-id "G_TYPE_CHECKSUM") ) +(define-object DateTime + (in-module "GLib") + (c-name "GDateTime") +) + (define-object KeyFile (in-module "GLib") (c-name "GKeyFile") @@ -30,6 +29,12 @@ (gtype-id "G_TYPE_MATCH_INFO") ) +(define-object OptionContext + (in-module "GLib") + (c-name "GOptionContext") + (gtype-id "G_TYPE_OPTION_CONTEXT") +) + (define-object Regex (in-module "GLib") (c-name "GRegex") @@ -42,6 +47,11 @@ (gtype-id "G_TYPE_SET") ) +(define-object TimeZone + (in-module "GLib") + (c-name "GTimeZone") +) + (define-object Variant (in-module "GLib") (c-name "GVariant") diff --git a/glib/src/timezone.ccg b/glib/src/timezone.ccg new file mode 100644 index 00000000..79957c1e --- /dev/null +++ b/glib/src/timezone.ccg @@ -0,0 +1,23 @@ +/* Copyright (C) 2011 The 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. + */ + +#include <glibmm/utility.h> + +namespace Glib +{ + +}// namespace Glib diff --git a/glib/src/timezone.hg b/glib/src/timezone.hg new file mode 100644 index 00000000..103190d7 --- /dev/null +++ b/glib/src/timezone.hg @@ -0,0 +1,74 @@ +/* Copyright (C) 2011 The 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 <glibmmconfig.h> +#include <glibmm/refptr.h> +#include <glibmm/ustring.h> +#include <glib.h> + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +typedef struct _GTimeZone GTimeZone; +#endif + +namespace Glib +{ + +_WRAP_ENUM(TimeType, GTimeType, NO_GTYPE) + +/** TimeZone - A structure representing a time zone. + * TimeZone is a structure that represents a time zone, at no particular point + * in time. It is refcounted and immutable. + * + * A time zone contains a number of intervals. Each interval has an + * abbreviation to describe it, an offet to UTC and a flag indicating if the + * daylight savings time is in effect during that interval. A time zone always + * has at least one interval -- interval 0. + * + * Every UTC time is contained within exactly one interval, but a given local + * time may be contained within zero, one or two intervals (due to + * incontinuities associated with daylight savings time). + * + * An interval may refer to a specific period of time (eg: the duration of + * daylight savings time during 2010) or it may refer to many periods of time + * that share the same properties (eg: all periods of daylight savings time). + * It is also possible (usually for political reasons) that some properties + * (like the abbreviation) change between intervals without other properties + * changing. + * @newin{2,30} + */ +class TimeZone +{ + _CLASS_OPAQUE_REFCOUNTED(TimeZone, GTimeZone, NONE, g_time_zone_ref, g_time_zone_unref) + _IGNORE(g_time_zone_ref, g_time_zone_unref) + +public: + _WRAP_METHOD(static Glib::RefPtr<TimeZone> create(const Glib::ustring& identifier), g_time_zone_new) + _WRAP_METHOD(static Glib::RefPtr<TimeZone> create_local(), g_time_zone_new_local) + _WRAP_METHOD(static Glib::RefPtr<TimeZone> create_utc(), g_time_zone_new_utc) + + _WRAP_METHOD(static void refresh_local(), g_time_zone_refresh_local) + + _WRAP_METHOD(int find_interval(TimeType type, gint64 time), g_time_zone_find_interval) + _WRAP_METHOD(int adjust_time(TimeType type, gint64& time), g_time_zone_adjust_time) + _WRAP_METHOD(Glib::ustring get_abbreviation(int interval), g_time_zone_get_abbreviation) + _WRAP_METHOD(gint32 get_offset(int interval), g_time_zone_get_offset) + _WRAP_METHOD(bool is_dst(int interval), g_time_zone_is_dst) +}; + +} // namespace Glib diff --git a/tools/m4/convert_glib.m4 b/tools/m4/convert_glib.m4 index fce48640..ddf8025d 100644 --- a/tools/m4/convert_glib.m4 +++ b/tools/m4/convert_glib.m4 @@ -57,14 +57,15 @@ dnl dnl # These are for fixmegtkconst _CONVERSION(`const guchar*',`guchar*',`const_cast<guchar*>($3)',`$3') -_CONV_GLIB_ENUM(IOStatus) -_CONV_GLIB_ENUM(IOFlags) _CONV_GLIB_ENUM(IOCondition) -_CONV_GLIB_ENUM(SeekType) -_CONV_GLIB_ENUM(OptionArg) +_CONV_GLIB_ENUM(IOFlags) +_CONV_GLIB_ENUM(IOStatus) _CONV_GLIB_ENUM(KeyFileFlags) +_CONV_GLIB_ENUM(OptionArg) _CONV_GLIB_ENUM(RegexCompileFlags) _CONV_GLIB_ENUM(RegexMatchFlags) +_CONV_GLIB_ENUM(SeekType) +_CONV_GLIB_ENUM(TimeType) _CONVERSION(`gunichar&',`gunichar*',`&($3)') @@ -99,6 +100,13 @@ _CONVERSION(`return-gchar*',`Glib::ustring',`Glib::convert_return_gchar_ptr_to_u _CONVERSION(`return-gchar*',`std::string',`Glib::convert_return_gchar_ptr_to_stdstring($3)') _CONVERSION(`return-char*',`Glib::ustring',`Glib::convert_return_gchar_ptr_to_ustring($3)') +dnl DateTime +_CONVERSION(`GDateTime*',`Glib::RefPtr<DateTime>',`Glib::wrap($3)') + +dnl KeyFile +_CONVERSION(`Glib::KeyFile&',`GKeyFile*',`($3).gobj()') + +dnl Object _CONVERSION(`const Glib::RefPtr<Glib::Object>&',`GObject*',__CONVERT_REFPTR_TO_P) _CONVERSION(`const Glib::RefPtr<const Glib::Object>&',`GObject*',__CONVERT_CONST_REFPTR_TO_P_SUN(Glib::Object)) _CONVERSION(`GObject*',`Glib::RefPtr<Glib::Object>',`Glib::wrap($3)') @@ -107,20 +115,32 @@ _CONVERSION(`GObject*',`Glib::RefPtr<const Glib::Object>',`Glib::wrap($3)') _CONVERSION(`GObject*',`Glib::RefPtr<Glib::ObjectBase>',`Glib::wrap($3)') _CONVERSION(`GObject*',`Glib::RefPtr<const Glib::ObjectBase>',`Glib::wrap($3)') +dnl OptionGroup +_CONVERSION(`OptionGroup&',`GOptionGroup*',`($3).gobj()') +#_CONVERSION(`GOptionGroup*',`OptionGroup',`Glib::wrap(($3), true /* take_copy */)') + +dnl Regex _CONVERSION(`GRegex*',`Glib::RefPtr<Regex>',`Glib::wrap($3)') _CONVERSION(`GRegex*',`Glib::RefPtr<const Regex>',`Glib::wrap($3)') +dnl TimeVal +_CONVERSION(`const TimeVal&',`const GTimeVal*',`&($3)') + +dnl TimeZone +_CONVERSION(`GTimeZone*',`Glib::RefPtr<TimeZone>',`Glib::wrap($3)') +_CONVERSION(`const Glib::RefPtr<const TimeZone>&',`GTimeZone*',`const_cast<$2>(Glib::unwrap($3))') + +dnl ValueBase _CONVERSION(`Glib::ValueBase&',`GValue*',`($3).gobj()') _CONVERSION(`const Glib::ValueBase&',`const GValue*',`($3).gobj()') _CONVERSION(`const Glib::ValueBase&',`GValue*',`const_cast<GValue*>(($3).gobj())') _CONVERSION(`GValue*', `Glib::ValueBase&', `*reinterpret_cast<Glib::ValueBase*>($3)') _CONVERSION(`const GValue*', `const Glib::ValueBase&', `*reinterpret_cast<const Glib::ValueBase*>($3)') -_CONVERSION(`OptionGroup&',`GOptionGroup*',`($3).gobj()') -#_CONVERSION(`GOptionGroup*',`OptionGroup',`Glib::wrap(($3), true /* take_copy */)') - -_CONVERSION(`Glib::KeyFile&',`GKeyFile*',`($3).gobj()') - +dnl VariantType _CONVERSION(`const VariantType&',`const GVariantType*',`($3).gobj()') _CONVERSION(`const GVariantType*',`VariantType',`Glib::wrap(const_cast<GVariantType*>($3), true)') _CONVERSION(`GVariantType*',`VariantType',`Glib::wrap(($3), true)') + +dnl Misillaneous +_CONVERSION(`gint64&',`gint64*',`&($3)') |