[template-glib] template: add tmpl_template_parse_string()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [template-glib] template: add tmpl_template_parse_string()
- Date: Mon, 18 Jan 2016 06:06:21 +0000 (UTC)
commit 3130a8e2cb6e47cd4155ab0817695d507717e498
Author: Christian Hergert <chergert redhat com>
Date: Sun Jan 17 22:06:09 2016 -0800
template: add tmpl_template_parse_string()
src/tmpl-template.c | 21 +++++++++++++++++++++
src/tmpl-template.h | 3 +++
2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/tmpl-template.c b/src/tmpl-template.c
index 693d2a6..f1fda11 100644
--- a/src/tmpl-template.c
+++ b/src/tmpl-template.c
@@ -16,7 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define G_LOG_DOMAIN "tmpl-template"
+
#include <glib/gi18n.h>
+#include <string.h>
#include "tmpl-branch-node.h"
#include "tmpl-condition-node.h"
@@ -212,6 +215,24 @@ tmpl_template_parse_resource (TmplTemplate *self,
}
gboolean
+tmpl_template_parse_string (TmplTemplate *self,
+ const gchar *str,
+ GError **error)
+{
+ GInputStream *stream;
+ gboolean ret;
+
+ g_return_val_if_fail (TMPL_IS_TEMPLATE (self), FALSE);
+ g_return_val_if_fail (str, FALSE);
+
+ stream = g_memory_input_stream_new_from_data (g_strdup (str), strlen (str), g_free);
+ ret = tmpl_template_parse (self, stream, NULL, error);
+ g_object_unref (stream);
+
+ return ret;
+}
+
+gboolean
tmpl_template_parse (TmplTemplate *self,
GInputStream *stream,
GCancellable *cancellable,
diff --git a/src/tmpl-template.h b/src/tmpl-template.h
index 4e64397..5ab549a 100644
--- a/src/tmpl-template.h
+++ b/src/tmpl-template.h
@@ -55,6 +55,9 @@ gboolean tmpl_template_parse_path (TmplTemplate *self,
const gchar *path,
GCancellable *cancellable,
GError **error);
+gboolean tmpl_template_parse_string (TmplTemplate *self,
+ const gchar *input,
+ GError **error);
gboolean tmpl_template_parse (TmplTemplate *self,
GInputStream *stream,
GCancellable *cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]