[gupnp-av] Add XML helper functions getting number from child contents.
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp-av] Add XML helper functions getting number from child contents.
- Date: Fri, 21 Sep 2012 10:49:55 +0000 (UTC)
commit 0836346d50b63893dfbe6b958eb742f339700c59
Author: Krzesimir Nowak <krnowak openismus com>
Date: Fri Sep 7 13:45:22 2012 +0200
Add XML helper functions getting number from child contents.
Will be needed by update ID getters in object and container.
libgupnp-av/xml-util.c | 30 ++++++++++++++++++++++++++++++
libgupnp-av/xml-util.h | 12 ++++++++++++
2 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/libgupnp-av/xml-util.c b/libgupnp-av/xml-util.c
index 92e71bb..4d345b8 100644
--- a/libgupnp-av/xml-util.c
+++ b/libgupnp-av/xml-util.c
@@ -1,9 +1,11 @@
/*
* Copyright (C) 2006, 2007 OpenedHand Ltd.
* Copyright (C) 2007 Zeeshan Ali.
+ * Copyright (C) 2012 Intel Corporation
*
* Author: Jorn Baayen <jorn openedhand com>
* Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ * Author: Krzesimir Nowak <krnowak openismus com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -93,6 +95,34 @@ xml_util_get_child_element_content (xmlNode *node,
return content;
}
+guint
+xml_util_get_uint_child_element (xmlNode *node,
+ const char *child_name,
+ guint default_value)
+{
+ const char *content;
+
+ content = xml_util_get_child_element_content (node, child_name);
+ if (!content)
+ return default_value;
+
+ return strtoul (content, NULL, 0);
+}
+
+guint64
+xml_util_get_uint64_child_element (xmlNode *node,
+ const char *child_name,
+ guint64 default_value)
+{
+ const char *content;
+
+ content = xml_util_get_child_element_content (node, child_name);
+ if (!content)
+ return default_value;
+
+ return g_ascii_strtoull (content, NULL, 0);
+}
+
const char *
xml_util_get_attribute_content (xmlNode *node,
const char *attribute_name)
diff --git a/libgupnp-av/xml-util.h b/libgupnp-av/xml-util.h
index e50066c..80d9b82 100644
--- a/libgupnp-av/xml-util.h
+++ b/libgupnp-av/xml-util.h
@@ -1,9 +1,11 @@
/*
* Copyright (C) 2006, 2007 OpenedHand Ltd.
* Copyright (C) 2007 Zeeshan Ali.
+ * Copyright (C) 2012 Intel Corporation
*
* Author: Jorn Baayen <jorn openedhand com>
* Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ * Author: Krzesimir Nowak <krnowak openismus com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -41,6 +43,16 @@ G_GNUC_INTERNAL const char *
xml_util_get_child_element_content (xmlNode *node,
const char *child_name);
+G_GNUC_INTERNAL guint
+xml_util_get_uint_child_element (xmlNode *node,
+ const char *child_name,
+ guint default_value);
+
+G_GNUC_INTERNAL guint64
+xml_util_get_uint64_child_element (xmlNode *node,
+ const char *child_name,
+ guint64 default_value);
+
G_GNUC_INTERNAL const char *
xml_util_get_attribute_content (xmlNode *node,
const char *attribute_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]