summaryrefslogtreecommitdiff
path: root/src/properties-table.h
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2014-09-13 20:37:57 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2014-09-13 20:37:57 +0200
commitdc32c58499caa8b1ec4e975afad75ca0d862e990 (patch)
tree91322afabcb457406ab512d20163f0dd73ce2c5a /src/properties-table.h
parent302127b03d44277c829642468561ac9e518b7a21 (diff)
downloadcataract-dc32c58499caa8b1ec4e975afad75ca0d862e990.tar.xz
Introduce properties table
This is a new internal properties storage for attributes that can be defined both in the item and album scope, with the item scope taking priority. The big advantage is a better distinguishment from an undefined, default value. It also makes easier to retrieve attributes with properly defined scope priorities.
Diffstat (limited to 'src/properties-table.h')
-rw-r--r--src/properties-table.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/properties-table.h b/src/properties-table.h
new file mode 100644
index 0000000..4a1a9ed
--- /dev/null
+++ b/src/properties-table.h
@@ -0,0 +1,62 @@
+/* Cataract - Static web photo gallery generator
+ * Copyright (C) 2014 Tomas Bzatek <tbzatek@users.sourceforge.net>
+ *
+ * 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 any later version.
+ *
+ * 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 more details.
+ *
+ * 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 __CGG__PROPERTIES_TABLE_H__
+#define __CGG__PROPERTIES_TABLE_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+
+typedef GHashTable PropertiesTable;
+
+/*
+ * properties_table_new: creates new property table
+ */
+PropertiesTable * properties_table_new ();
+
+/*
+ * properties_table_dup: creates deep copy of the table
+ */
+PropertiesTable * properties_table_dup (PropertiesTable *table);
+
+/*
+ * properties_table_add_*: adds new item in the table, duplicating data
+ */
+void properties_table_add_string (PropertiesTable *table, int property_id, const gchar *value);
+void properties_table_add_int (PropertiesTable *table, int property_id, long int value);
+void properties_table_add_bool (PropertiesTable *table, int property_id, gboolean value);
+void properties_table_add_double (PropertiesTable *table, int property_id, double value);
+
+/*
+ * properties_table_get_*: gets data for the specified id, setting *value, returning TRUE if found
+ */
+const gchar * properties_table_get_string (PropertiesTable *table, int property_id);
+gboolean properties_table_get_int (PropertiesTable *table, int property_id, long int *value);
+gboolean properties_table_get_bool (PropertiesTable *table, int property_id, gboolean *value);
+gboolean properties_table_get_double (PropertiesTable *table, int property_id, double *value);
+
+/*
+ * properties_table_free: destroys properties table and frees all data
+ */
+void properties_table_free (PropertiesTable *table);
+
+
+G_END_DECLS
+
+#endif /* __CGG__PROPERTIES_TABLE_H__ */