gplate/gplate-template.h
author Gary Kramlich <grim@reaperworld.com>
Sat Jul 03 23:24:33 2010 -0500 (22 months ago)
changeset 394 ad26d98e20e6
parent 332 50427237b04b
permissions -rw-r--r--
Changed the license from gplv2 to gplv3
Updated copyrights to be 2007-2010 rather than 2007-2008 (since just about everything has been touched recently
Ignored the top level tests/ directory for now since that is slowly being replaced
     1 /*
     2  * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
     3  *
     4  * This program is free software: you can redistribute it and/or modify
     5  * it under the terms of the GNU General Public License as published by
     6  * the Free Software Foundation, either version 3 of the License, or
     7  * (at your option) any later version.
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16  */
    17 #ifndef GPLATE_TEMPLATE_H
    18 #define GPLATE_TEMPLATE_H
    19 
    20 #include <glib.h>
    21 #include <glib-object.h>
    22 
    23 #define GPLATE_TYPE_TEMPLATE			(gplate_template_get_gtype())
    24 #define GPLATE_TEMPLATE(obj)			(G_TYPE_CHECK_INSTANCE_CAST((obj), GPLATE_TYPE_TEMPLATE, GPlateTemplate))
    25 #define GPLATE_TEMPLATE_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST((klass), GPLATE_TYPE_TEMPLATE, GPlateTemplateClass))
    26 #define GPLATE_IS_TEMPLATE(obj)			(G_TYPE_CHECK_INSTANCE_TYPE((obj), GPLATE_TYPE_TEMPLATE))
    27 #define GPLATE_IS_TEMPLATE_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((klass), GPLATE_TYPE_TEMPLATE))
    28 #define GPLATE_TEMPLATE_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS((obj), GPLATE_TYPE_TEMPLATE, GPlateTemplateClass))
    29 
    30 typedef struct _GPlateTemplate			GPlateTemplate;
    31 typedef struct _GPlateTemplateClass		GPlateTemplateClass;
    32 
    33 #include <gplate/gplate-tag.h>
    34 
    35 struct _GPlateTemplate {
    36 	GObject gparent;
    37 
    38 	void (*_gplate_reserved1)(void);
    39 	void (*_gplate_reserved2)(void);
    40 	void (*_gplate_reserved3)(void);
    41 	void (*_gplate_reserved4)(void);
    42 };
    43 
    44 struct _GPlateTemplateClass {
    45 	GObjectClass parent;
    46 
    47 	GList *(*tokenize)(GPlateTemplate *tplate, const gchar *tplate_string, GError **error);
    48 	gchar *(*render)(GPlateTemplate *tplate, const gchar *tplate_string, GError **error);
    49 
    50 	GPlateTag *(*first_tag)(GPlateTemplate *tplate);
    51 	GPlateTag *(*last_tag)(GPlateTemplate *tplate);
    52 	GPlateTag *(*current_tag)(GPlateTemplate *tplate);
    53 	GPlateTag *(*next_tag)(GPlateTemplate *tplate);
    54 	GPlateTag *(*previous_tag)(GPlateTemplate *tplate);
    55 	GPlateTag *(*nth_tag)(GPlateTemplate *tplate, guint nth);
    56 	GPlateTag *(*nth_previous_tag)(GPlateTemplate *tplate, guint nth);
    57 	
    58 	void (*insert_tags)(GPlateTemplate *tplate, GList *tags);
    59 
    60 	void (*_gplate_reserved1)(void);
    61 	void (*_gplate_reserved2)(void);
    62 	void (*_gplate_reserved3)(void);
    63 	void (*_gplate_reserved4)(void);
    64 };
    65 
    66 G_BEGIN_DECLS
    67 
    68 GType gplate_template_get_gtype(void);
    69 
    70 GPlateTemplate *gplate_template_new(void);
    71 
    72 GList *gplate_template_tokenize(GPlateTemplate *tplate, const gchar *tplate_string, GError **error);
    73 
    74 gchar *gplate_template_render(GPlateTemplate *tplate, const gchar *tplate_string, GError **error);
    75 gchar *gplate_template_render_file(GPlateTemplate *tplate, const gchar *filename, GError **error);
    76 
    77 gchar *gplate_template_render_until(GPlateTemplate *tplate, guint *ntags, ...);
    78 
    79 void gplate_template_jump_to(GPlateTemplate *tplate, guint *ntags, ...);
    80 
    81 GPlateTag *gplate_template_first_tag(GPlateTemplate *tplate);
    82 GPlateTag *gplate_template_last_tag(GPlateTemplate *tplate);
    83 GPlateTag *gplate_template_current_tag(GPlateTemplate *tplate);
    84 GPlateTag *gplate_template_next_tag(GPlateTemplate *tplate);
    85 GPlateTag *gplate_template_previous_tag(GPlateTemplate *tplate);
    86 GPlateTag *gplate_template_nth_tag(GPlateTemplate *tplate, guint nth);
    87 GPlateTag *gplate_template_nth_previous_tag(GPlateTemplate *tplate, guint nth);
    88 
    89 void gplate_template_insert_tags(GPlateTemplate *tplate, GList *tags);
    90 
    91 gchar *gplate_template_render_tag(GPlateTemplate *tplate, const GPlateTag *tag);
    92 
    93 void gplate_template_set_working_directory(GPlateTemplate *tplate, const gchar *wd);
    94 const gchar *gplate_template_get_working_directory(const GPlateTemplate *tplate);
    95 
    96 G_END_DECLS
    97 
    98 #endif /* GPLATE_TEMPLATE_H */