--- a/gplate/Makefile.am Sun Feb 17 18:49:40 2008 -0600
+++ b/gplate/Makefile.am Tue Feb 19 02:41:10 2008 -0600
@@ -13,6 +13,7 @@
gplate-dictionary-variable.h \
+ gplate-include-function.h \ gplate-object-variable.h \
@@ -31,6 +32,7 @@
gplate-dictionary-variable.c \
+ gplate-include-function.c \ gplate-print-function.c \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/gplate-include-function.c Tue Feb 19 02:41:10 2008 -0600
@@ -0,0 +1,106 @@
+ * Copyright (C) 2007-2008 Gary Kramlich <grim@reaperworld.com> + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * This program 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 General Public License for + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#endif /* HAVE_CONFIG_H */ +#include <gplate/gplate-include-function.h> +#include <gplate/gplate-collection.h> +#include <gplate/gplate-variable.h> +/****************************************************************************** + * IncludeFunction Stuff + *****************************************************************************/ +gplate_include_function_evaluate(GPlateFunction *function, + GPlateTemplate *tplate, + GMatchInfo *info = NULL; + regex = g_regex_new("\"(.+)\"", 0, 0, NULL); + if(g_regex_match(regex, contents, 0, &info)) { + gchar *file = g_match_info_fetch(info, 1); + ret = gplate_template_render_file(tplate, file, NULL); + g_match_info_free(info); + GPlateVariable *variable = NULL; + variable = gplate_collection_find_variable(GPLATE_COLLECTION(tplate), + if(GPLATE_IS_VARIABLE(variable)) { + const gchar *value = gplate_variable_get_value(variable); + ret = gplate_template_render(tplate, value, NULL); + g_object_unref(G_OBJECT(variable)); +/****************************************************************************** + *****************************************************************************/ +gplate_include_function_class_init(GPlateIncludeFunctionClass *klass) { + GPlateFunctionClass *func_class = GPLATE_FUNCTION_CLASS(klass); + func_class->evaluate = gplate_include_function_evaluate; +/****************************************************************************** + * GPlateIncludeFunction API + *****************************************************************************/ +gplate_include_function_get_gtype(void) { + static const GTypeInfo info = { + sizeof(GPlateIncludeFunctionClass), + (GClassInitFunc)gplate_include_function_class_init, + sizeof(GPlateIncludeFunction), + type = g_type_register_static(GPLATE_TYPE_FUNCTION, + "GPlateIncludeFunction", --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/gplate-include-function.h Tue Feb 19 02:41:10 2008 -0600
@@ -0,0 +1,58 @@
+ * Copyright (C) 2007-2008 Gary Kramlich <grim@reaperworld.com> + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * This program 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 General Public License for + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#ifndef GPLATE_INCLUDE_FUNCTION_H +#define GPLATE_INCLUDE_FUNCTION_H +#include <gplate/gplate-function.h> +#define GPLATE_TYPE_INCLUDE_FUNCTION (gplate_include_function_get_gtype()) +#define GPLATE_INCLUDE_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GPLATE_TYPE_INCLUDE_FUNCTION, GPlateIncludeFunction)) +#define GPLATE_INCLUDE_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GPLATE_TYPE_INCLUDE_FUNCTION, GPlateIncludeFunctionClass)) +#define GPLATE_IS_INCLUDE_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GPLATE_TYPE_INCLUDE_FUNCTION)) +#define GPLATE_IS_INCLUDE_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GPLATE_TYPE_INCLUDE_FUNCTION)) +#define GPLATE_INCLUDE_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GPLATE_TYPE_INCLUDE_FUNCTION, GPlateIncludeFunctionClass)) +typedef struct _GPlateIncludeFunction GPlateIncludeFunction; +typedef struct _GPlateIncludeFunctionClass GPlateIncludeFunctionClass; +struct _GPlateIncludeFunction { + GPlateFunction gparent; + void (*_gplate_reserved1)(void); + void (*_gplate_reserved2)(void); + void (*_gplate_reserved3)(void); + void (*_gplate_reserved4)(void); +struct _GPlateIncludeFunctionClass { + GPlateFunctionClass parent; + void (*_gplate_reserved1)(void); + void (*_gplate_reserved2)(void); + void (*_gplate_reserved3)(void); + void (*_gplate_reserved4)(void); +GType gplate_include_function_get_gtype(void); +#endif /* GPLATE_INCLUDE_FUNCTION_H */