[aravis/dom: 4/5] dom: add dom files to Makefile.



commit 834785dbaf642a5f93b83a2bbdf01399e21ebaf9
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Sun Feb 19 19:43:55 2012 +0100

    dom: add dom files to Makefile.

 src/Makefile.am            |   24 ++++++
 src/arvdebug.h             |    5 +
 src/arvdom.h               |    3 +-
 src/arvdomcharacterdata.c  |    4 +-
 src/arvdomdocument.c       |   14 ++--
 src/arvdomdocument.h       |    3 +-
 src/arvdomimplementation.c |   12 +--
 src/arvdomnode.c           |   14 ++--
 src/arvdomparser.c         |   17 ++--
 src/arvevaluator.c         |    1 +
 src/arvgcfloatnode.c       |    1 +
 src/arvmisc.c              |   90 --------------------
 src/arvmisc.h              |   37 ---------
 src/arvstr.c               |  193 ++++++++++++++++++++++++++++++++++++++++++++
 src/arvstr.h               |   74 +++++++++++++++++
 15 files changed, 330 insertions(+), 162 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 254c0a1..4d90065 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,6 +33,16 @@ ARAVIS_SRCS =					\
 	arvdebug.c				\
 	arvsystem.c				\
 	arvevaluator.c				\
+	arvdomnode.c				\
+	arvdomnodelist.c			\
+	arvdomnamednodemap.c			\
+	arvdomdocument.c			\
+	arvdomdocumentfragment.c		\
+	arvdomelement.c				\
+	arvdomcharacterdata.c			\
+	arvdomtext.c				\
+	arvdomparser.c				\
+	arvdomimplementation.c			\
 	arvcamera.c				\
 	arvgc.c					\
 	arvgcnode.c				\
@@ -65,6 +75,7 @@ ARAVIS_SRCS =					\
 ARAVIS_SRCS_NO_INTRO =				\
 	arvmisc.c				\
 	arvzip.c				\
+	arvstr.c				\
 	arvgvcp.c				\
 	arvgvsp.c
 
@@ -75,6 +86,18 @@ ARAVIS_HDRS = 					\
 	arvdebug.h				\
 	arvsystem.h				\
 	arvevaluator.h				\
+	arvdom.h				\
+	arvdomtypes.h				\
+	arvdomnode.h				\
+	arvdomnodelist.h			\
+	arvdomnamednodemap.h			\
+	arvdomdocument.h			\
+	arvdomdocumentfragment.h		\
+	arvdomelement.h				\
+	arvdomcharacterdata.h			\
+	arvdomtext.h				\
+	arvdomparser.h				\
+	arvdomimplementation.h			\
 	arvcamera.h				\
 	arvgc.h					\
 	arvgcnode.h				\
@@ -107,6 +130,7 @@ ARAVIS_HDRS = 					\
 ARAVIS_HDRS_NO_INTRO =				\
 	arvmisc.h				\
 	arvzip.h				\
+	arvstr.h				\
 	arvgvcp.h				\
 	arvgvsp.h
 
diff --git a/src/arvdebug.h b/src/arvdebug.h
index cb729d0..b6a0e8b 100644
--- a/src/arvdebug.h
+++ b/src/arvdebug.h
@@ -40,6 +40,7 @@ typedef struct {
 	ArvDebugLevel level;
 } ArvDebugCategory;
 
+extern ArvDebugCategory arv_debug_category_dom;
 extern ArvDebugCategory arv_debug_category_interface;
 extern ArvDebugCategory arv_debug_category_device;
 extern ArvDebugCategory arv_debug_category_stream;
@@ -50,6 +51,10 @@ extern ArvDebugCategory arv_debug_category_genicam;
 extern ArvDebugCategory arv_debug_category_evaluator;
 extern ArvDebugCategory arv_debug_category_misc;
 
+#define arv_debug_dom(...)	 	arv_debug (&arv_debug_category_interface, __VA_ARGS__)
+#define arv_log_dom(...)		arv_log (&arv_debug_category_interface, __VA_ARGS__)
+#define arv_warning_dom(...)		arv_warning (&arv_debug_category_interface, __VA_ARGS__)
+
 #define arv_debug_interface(...) 	arv_debug (&arv_debug_category_interface, __VA_ARGS__)
 #define arv_log_interface(...)		arv_log (&arv_debug_category_interface, __VA_ARGS__)
 #define arv_warning_interface(...)	arv_warning (&arv_debug_category_interface, __VA_ARGS__)
diff --git a/src/arvdom.h b/src/arvdom.h
index f26aa96..c7681ad 100644
--- a/src/arvdom.h
+++ b/src/arvdom.h
@@ -24,7 +24,7 @@
 #ifndef ARV_DOM_H
 #define ARV_DOM_H
 
-#include <lsm.h>
+#include <arv.h>
 
 #include <arvdomtypes.h>
 
@@ -37,6 +37,5 @@
 #include <arvdomimplementation.h>
 
 #include <arvdomparser.h>
-#include <arvdomview.h>
 
 #endif
diff --git a/src/arvdomcharacterdata.c b/src/arvdomcharacterdata.c
index 0508680..7880da7 100644
--- a/src/arvdomcharacterdata.c
+++ b/src/arvdomcharacterdata.c
@@ -27,7 +27,7 @@
  */
 
 #include <arvdomcharacterdata.h>
-#include <lsmdebug.h>
+#include <arvdebug.h>
 #include <string.h>
 
 static GObjectClass *parent_class = NULL;
@@ -74,7 +74,7 @@ arv_dom_character_data_set_data (ArvDomCharacterData* self, const char * value)
 	g_free (self->data);
 	self->data = g_strdup (value);
 
-	lsm_debug_dom ("[ArvDomCharacterData::set_data] Value = '%s'", value);
+	arv_debug_dom ("[ArvDomCharacterData::set_data] Value = '%s'", value);
 
 	arv_dom_node_changed (ARV_DOM_NODE (self));
 }
diff --git a/src/arvdomdocument.c b/src/arvdomdocument.c
index 1c4a908..4204f77 100644
--- a/src/arvdomdocument.c
+++ b/src/arvdomdocument.c
@@ -28,8 +28,8 @@
 
 #include <arvdomdocument.h>
 #include <arvdomelement.h>
-#include <lsmstr.h>
-#include <lsmdebug.h>
+#include <arvstr.h>
+#include <arvdebug.h>
 #include <arvdomtext.h>
 #include <gio/gio.h>
 #include <string.h>
@@ -102,7 +102,7 @@ arv_dom_document_get_element_by_id (ArvDomDocument *self, const char *id)
 	g_return_val_if_fail (LSM_IS_DOM_DOCUMENT (self), NULL);
 	g_return_val_if_fail (id != NULL, NULL);
 
-	lsm_debug_dom ("[ArvDomDocument::get_element_by_id] Lookup '%s'", id);
+	arv_debug_dom ("[ArvDomDocument::get_element_by_id] Lookup '%s'", id);
 
 	return g_hash_table_lookup (self->ids, id);
 }
@@ -116,7 +116,7 @@ arv_dom_document_register_element (ArvDomDocument *self, ArvDomElement *element,
 
 	old_id = g_hash_table_lookup (self->elements, element);
 	if (old_id != NULL) {
-		lsm_debug_dom ("[ArvDomDocument::register_element] Unregister '%s'", old_id);
+		arv_debug_dom ("[ArvDomDocument::register_element] Unregister '%s'", old_id);
 
 		g_hash_table_remove (self->elements, element);
 		g_hash_table_remove (self->ids, old_id);
@@ -125,7 +125,7 @@ arv_dom_document_register_element (ArvDomDocument *self, ArvDomElement *element,
 	if (id != NULL) {
 		char *new_id = g_strdup (id);
 
-		lsm_debug_dom ("[ArvDomDocument::register_element] Register '%s'", id);
+		arv_debug_dom ("[ArvDomDocument::register_element] Register '%s'", id);
 
 		g_hash_table_replace (self->ids, new_id, element);
 		g_hash_table_replace (self->elements, element, new_id);
@@ -152,14 +152,14 @@ arv_dom_document_set_path (ArvDomDocument *self, const char *path)
 		return;
 	}
 
-	self->url = lsm_str_to_uri (path);
+	self->url = arv_str_to_uri (path);
 }
 
 void
 arv_dom_document_set_url (ArvDomDocument *self, const char *url)
 {
 	g_return_if_fail (LSM_IS_DOM_DOCUMENT (self));
-	g_return_if_fail (url == NULL || lsm_str_is_uri (url));
+	g_return_if_fail (url == NULL || arv_str_is_uri (url));
 
 	g_free (self->url);
 	self->url = g_strdup (url);
diff --git a/src/arvdomdocument.h b/src/arvdomdocument.h
index 8b68105..1fd4cd2 100644
--- a/src/arvdomdocument.h
+++ b/src/arvdomdocument.h
@@ -24,10 +24,9 @@
 #ifndef ARV_DOM_DOCUMENT_H
 #define ARV_DOM_DOCUMENT_H
 
-#include <lsmtypes.h>
+#include <arvtypes.h>
 #include <arvdomtypes.h>
 #include <arvdomnode.h>
-#include <arvdomview.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/arvdomimplementation.c b/src/arvdomimplementation.c
index 76fff72..e05ef65 100644
--- a/src/arvdomimplementation.c
+++ b/src/arvdomimplementation.c
@@ -22,9 +22,7 @@
  */
 
 #include <arvdomimplementation.h>
-#include <lsmmathmldocument.h>
-#include <lsmsvgdocument.h>
-#include <lsmdebug.h>
+#include <arvdebug.h>
 #include <string.h>
 
 static GHashTable *document_types = NULL;
@@ -48,14 +46,14 @@ arv_dom_implementation_create_document (const char *namespace_uri,
 	g_return_val_if_fail (qualified_name != NULL, NULL);
 
 	if (document_types == NULL) {
-		arv_dom_implementation_add_create_function ("math", lsm_mathml_document_new);
-		arv_dom_implementation_add_create_function ("svg", lsm_svg_document_new);
+/*                arv_dom_implementation_add_create_function ("math", lsm_mathml_document_new);*/
+/*                arv_dom_implementation_add_create_function ("svg", lsm_svg_document_new);*/
 	}
 
 	create_function = g_hash_table_lookup (document_types, qualified_name);
 	if (create_function == NULL) {
-		lsm_debug_dom ("[ArvDomImplementation::create_document] Unknow document type (%s)",
-			   qualified_name);
+		arv_debug_dom ("[ArvDomImplementation::create_document] Unknow document type (%s)",
+			       qualified_name);
 		return NULL;
 	}
 
diff --git a/src/arvdomnode.c b/src/arvdomnode.c
index 5a347a3..039d0fb 100644
--- a/src/arvdomnode.c
+++ b/src/arvdomnode.c
@@ -29,7 +29,7 @@
 #include <arvdomnode.h>
 #include <arvdomnodelist.h>
 #include <arvdomdocument.h>
-#include <lsmdebug.h>
+#include <arvdebug.h>
 #include <glib/gprintf.h>
 #include <stdio.h>
 
@@ -345,7 +345,7 @@ arv_dom_node_insert_before (ArvDomNode* self, ArvDomNode* new_child, ArvDomNode*
 	}
 
 	if (ref_child->parent_node != self) {
-		lsm_debug_dom ("[ArvDomNode::insert_before] Ref child '%s' doesn't belong to '%s'",
+		arv_debug_dom ("[ArvDomNode::insert_before] Ref child '%s' doesn't belong to '%s'",
 			   arv_dom_node_get_node_name (ref_child),
 			   arv_dom_node_get_node_name (self));
 		g_object_unref (new_child);
@@ -353,7 +353,7 @@ arv_dom_node_insert_before (ArvDomNode* self, ArvDomNode* new_child, ArvDomNode*
 	}
 
 	if (!ARV_DOM_NODE_GET_CLASS (self)->can_append_child (self, new_child)) {
-		lsm_debug_dom ("[ArvDomNode::insert_before] Can't append '%s' to '%s'",
+		arv_debug_dom ("[ArvDomNode::insert_before] Can't append '%s' to '%s'",
 			   arv_dom_node_get_node_name (new_child),
 			   arv_dom_node_get_node_name (self));
 		g_object_unref (new_child);
@@ -418,7 +418,7 @@ arv_dom_node_replace_child (ArvDomNode* self, ArvDomNode* new_child, ArvDomNode*
 		arv_dom_node_remove_child (self, new_child);
 
 	if (old_child == NULL) {
-		lsm_debug_dom ("[ArvDomNode::replace_child] old_child == NULL)");
+		arv_debug_dom ("[ArvDomNode::replace_child] old_child == NULL)");
 		g_object_unref (new_child);
 		return NULL;
 	}
@@ -544,9 +544,9 @@ arv_dom_node_append_child (ArvDomNode* self, ArvDomNode* new_child)
 		arv_dom_node_remove_child (self, new_child);
 
 	if (!ARV_DOM_NODE_GET_CLASS (self)->can_append_child (self, new_child)) {
-		lsm_debug_dom ("[ArvDomNode::append_child] Can't append '%s' to '%s'",
-			   arv_dom_node_get_node_name (new_child),
-			   arv_dom_node_get_node_name (self));
+		arv_debug_dom ("[ArvDomNode::append_child] Can't append '%s' to '%s'",
+			       arv_dom_node_get_node_name (new_child),
+			       arv_dom_node_get_node_name (self));
 		g_object_unref (new_child);
 		return NULL;
 	}
diff --git a/src/arvdomparser.c b/src/arvdomparser.c
index 98eb0a0..892665d 100644
--- a/src/arvdomparser.c
+++ b/src/arvdomparser.c
@@ -21,17 +21,14 @@
  * 	Emmanuel Pacaud <emmanuel gnome org>
  */
 
-#include <lsmdebug.h>
+#include <arvdebug.h>
 #include <arvdomimplementation.h>
 #include <arvdomnode.h>
-#include <lsmmathmlpresentationtoken.h>
-#include <lsmmathmlentitydictionary.h>
-#include <lsmsvgtextelement.h>
-#include <lsmstr.h>
+#include <arvdomelement.h>
+#include <arvstr.h>
 #include <libxml/parser.h>
 #include <gio/gio.h>
 #include <string.h>
-#include <../itex2mml/itex2MML.h>
 
 typedef enum {
 	STATE
@@ -159,6 +156,7 @@ arv_dom_parser_characters (void *user_data, const xmlChar *ch, int len)
 	}
 }
 
+#if 0
 static xmlEntityPtr
 arv_dom_parser_get_entity (void *user_data, const xmlChar *name)
 {
@@ -197,6 +195,7 @@ arv_dom_parser_declare_entity (void * user_data, const xmlChar * name, int type,
 		g_hash_table_insert (state->entities, (char *) name, entity);
 	}
 }
+#endif
 
 #if 1
 static void
@@ -240,9 +239,11 @@ static xmlSAXHandler sax_handler = {
 	.endDocument = arv_dom_parser_end_document,
 	.startElement = arv_dom_parser_start_element,
 	.endElement = arv_dom_parser_end_element,
-	.characters = arv_dom_parser_characters,
+	.characters = arv_dom_parser_characters
+#if 0
 	.getEntity = arv_dom_parser_get_entity,
 	.entityDecl = arv_dom_parser_declare_entity
+#endif
 };
 
 static GQuark
@@ -280,7 +281,7 @@ arv_dom_document_new_from_memory (const void *buffer, int size, GError **error)
 			g_object_unref (state.document);
 		state.document = NULL;
 
-		lsm_debug_dom ("[ArvDomParser::from_memory] Invalid document");
+		arv_debug_dom ("[ArvDomParser::from_memory] Invalid document");
 
 		g_set_error (error,
 			     ARV_DOM_DOCUMENT_ERROR,
diff --git a/src/arvevaluator.c b/src/arvevaluator.c
index ba1536c..982a6b6 100644
--- a/src/arvevaluator.c
+++ b/src/arvevaluator.c
@@ -28,6 +28,7 @@
 #include <arvevaluator.h>
 #include <arvdebug.h>
 #include <arvmisc.h>
+#include <arvstr.h>
 #include <math.h>
 #include <stdlib.h>
 
diff --git a/src/arvgcfloatnode.c b/src/arvgcfloatnode.c
index 365e482..1f472fb 100644
--- a/src/arvgcfloatnode.c
+++ b/src/arvgcfloatnode.c
@@ -29,6 +29,7 @@
 #include <arvgcfloat.h>
 #include <arvgc.h>
 #include <arvmisc.h>
+#include <arvstr.h>
 #include <string.h>
 
 static GObjectClass *parent_class = NULL;
diff --git a/src/arvmisc.c b/src/arvmisc.c
index 41a0424..278ead9 100644
--- a/src/arvmisc.c
+++ b/src/arvmisc.c
@@ -316,96 +316,6 @@ arv_statistic_to_string (const ArvStatistic *statistic)
 	return str;
 }
 
-/* ArvStr implementation */
-
-gboolean
-arv_str_parse_double (char **str, double *x)
-{
-	char *end, *c;
-	gboolean integer_part = FALSE;
-	gboolean fractional_part = FALSE;
-	gboolean exponent_part = FALSE;
-	double mantissa = 0.0;
-	double exponent =0.0;
-	double divisor;
-	gboolean mantissa_sign = 1.0;
-	gboolean exponent_sign = 1.0;
-
-	c = *str;
-
-	if (*c == '-') {
-		mantissa_sign = -1.0;
-		c++;
-	} else if (*c == '+')
-		c++;
-
-	if (*c >= '0' && *c <= '9') {
-		integer_part = TRUE;
-		mantissa = *c - '0';
-		c++;
-
-		while (*c >= '0' && *c <= '9') {
-			mantissa = mantissa * 10.0 + *c - '0';
-			c++;
-		}
-	}
-
-
-	if (*c == '.')
-		c++;
-	else if (!integer_part)
-		return FALSE;
-
-	if (*c >= '0' && *c <= '9') {
-		fractional_part = TRUE;
-		mantissa += (*c - '0') * 0.1;
-		divisor = 0.01;
-		c++;
-
-		while (*c >= '0' && *c <= '9') {
-			mantissa += (*c - '0') * divisor;
-			divisor *= 0.1;
-			c++;
-		}
-	}
-
-	if (!fractional_part && !integer_part)
-		return FALSE;
-
-	end = c;
-
-	if (*c == 'E' || *c == 'e') {
-		c++;
-
-		if (*c == '-') {
-			exponent_sign = -1.0;
-			c++;
-		} else if (*c == '+')
-			c++;
-
-		if (*c >= '0' && *c <= '9') {
-			exponent_part = TRUE;
-			exponent = *c - '0';
-			c++;
-
-			while (*c >= '0' && *c <= '9') {
-				exponent = exponent * 10.0 + *c - '0';
-				c++;
-			}
-		}
-	}
-
-	if (exponent_part) {
-		end = c;
-		*x = mantissa_sign * mantissa * pow (10.0, exponent_sign * exponent);
-	} else
-		*x = mantissa_sign * mantissa;
-
-	*str = end;
-
-	return TRUE;
-}
-
 /**
  * SECTION: arvvalue
  * @short_description: An int64/double value storage
diff --git a/src/arvmisc.h b/src/arvmisc.h
index e028bf2..e7de2e2 100644
--- a/src/arvmisc.h
+++ b/src/arvmisc.h
@@ -38,43 +38,6 @@ void 			arv_statistic_set_name 		(ArvStatistic *statistic, guint histogram_id, c
 
 char *			arv_statistic_to_string 	(const ArvStatistic *statistic);
 
-gboolean 		arv_str_parse_double 		(char **str, double *x);
-
-static inline void
-arv_str_skip_spaces (char **str)
-{
-	while (g_ascii_isspace (**str))
-		(*str)++;
-}
-
-static inline void
-arv_str_skip_char (char **str, char c)
-{
-	while (**str == c)
-		(*str)++;
-}
-
-static inline void
-arv_str_skip_comma_and_spaces (char **str)
-{
-	while (g_ascii_isspace (**str) || **str == ',')
-		(*str)++;
-}
-
-static inline void
-arv_str_skip_semicolon_and_spaces (char **str)
-{
-	while (g_ascii_isspace (**str) || **str == ';')
-		(*str)++;
-}
-
-static inline void
-arv_str_skip_colon_and_spaces (char **str)
-{
-	while (g_ascii_isspace (**str) || **str == ':')
-		(*str)++;
-}
-
 #define ARV_TYPE_VALUE (arv_value_get_type())
 
 GType arv_value_get_type (void);
diff --git a/src/arvstr.c b/src/arvstr.c
new file mode 100644
index 0000000..a1e5627
--- /dev/null
+++ b/src/arvstr.c
@@ -0,0 +1,193 @@
+/* Lasem
+ *
+ * Copyright  2009 Emmanuel Pacaud
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ * 	Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#include <arvstr.h>
+#include <glib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+/* http://www.ietf.org/rfc/rfc2396.txt - Implementation comes from librsvg (rsvg-base.c). */
+
+gboolean
+arv_str_is_uri  (const char *str)
+{
+	char const *p;
+
+	if (str == NULL)
+		return FALSE;
+
+	if (strlen (str) < 4)
+		return FALSE;
+
+	if (   (str[0] < 'a' || str[0] > 'z')
+	       && (str[0] < 'A' || str[0] > 'Z'))
+		return FALSE;
+
+	for (p = &str[1];
+	     (*p >= 'a' && *p <= 'z')
+	     || (*p >= 'A' && *p <= 'Z')
+	     || (*p >= '0' && *p <= '9')
+	     || *p == '+'
+	     || *p == '-'
+	     || *p == '.';
+	     p++);
+
+	if (strlen (p) < 3)
+		return FALSE;
+
+	return (p[0] == ':' && p[1] == '/' && p[2] == '/');
+}
+
+char *
+arv_str_to_uri (const char *str)
+{
+	gchar *current_dir;
+	gchar *absolute_filename;
+	gchar *uri;
+
+	if (str == NULL)
+		return NULL;
+
+	if (arv_str_is_uri (str))
+		return g_strdup (str);
+
+	if (g_path_is_absolute (str))
+		return g_filename_to_uri (str, NULL, NULL);
+
+	current_dir = g_get_current_dir ();
+	absolute_filename = g_build_filename (current_dir, str, NULL);
+	uri = g_filename_to_uri (absolute_filename, NULL, NULL);
+	g_free (absolute_filename);
+	g_free (current_dir);
+
+	return uri;
+}
+
+gboolean
+arv_str_parse_double (char **str, double *x)
+{
+	char *end, *c;
+	gboolean integer_part = FALSE;
+	gboolean fractional_part = FALSE;
+	gboolean exponent_part = FALSE;
+	double mantissa = 0.0;
+	double exponent =0.0;
+	double divisor;
+	gboolean mantissa_sign = 1.0;
+	gboolean exponent_sign = 1.0;
+
+	c = *str;
+
+	if (*c == '-') {
+		mantissa_sign = -1.0;
+		c++;
+	} else if (*c == '+')
+		c++;
+
+	if (*c >= '0' && *c <= '9') {
+		integer_part = TRUE;
+		mantissa = *c - '0';
+		c++;
+
+		while (*c >= '0' && *c <= '9') {
+			mantissa = mantissa * 10.0 + *c - '0';
+			c++;
+		}
+	}
+
+
+	if (*c == '.')
+		c++;
+	else if (!integer_part)
+		return FALSE;
+
+	if (*c >= '0' && *c <= '9') {
+		fractional_part = TRUE;
+		mantissa += (*c - '0') * 0.1;
+		divisor = 0.01;
+		c++;
+
+		while (*c >= '0' && *c <= '9') {
+			mantissa += (*c - '0') * divisor;
+			divisor *= 0.1;
+			c++;
+		}
+	}
+
+	if (!fractional_part && !integer_part)
+		return FALSE;
+
+	end = c;
+
+	if (*c == 'E' || *c == 'e') {
+		c++;
+
+		if (*c == '-') {
+			exponent_sign = -1.0;
+			c++;
+		} else if (*c == '+')
+			c++;
+
+		if (*c >= '0' && *c <= '9') {
+			exponent_part = TRUE;
+			exponent = *c - '0';
+			c++;
+
+			while (*c >= '0' && *c <= '9') {
+				exponent = exponent * 10.0 + *c - '0';
+				c++;
+			}
+		}
+	}
+
+	if (exponent_part) {
+		end = c;
+		*x = mantissa_sign * mantissa * pow (10.0, exponent_sign * exponent);
+	} else
+		*x = mantissa_sign * mantissa;
+
+	*str = end;
+
+	return TRUE;
+}
+
+unsigned int
+arv_str_parse_double_list (char **str, unsigned int n_values, double *values)
+{
+	char *ptr = *str;
+	unsigned int i;
+
+	arv_str_skip_comma_and_spaces (str);
+
+	for (i = 0; i < n_values; i++) {
+		if (!arv_str_parse_double (str, &values[i])) {
+			*str = ptr;
+			return i;
+		}
+		arv_str_skip_comma_and_spaces (str);
+	}
+
+	return i;
+}
+
diff --git a/src/arvstr.h b/src/arvstr.h
new file mode 100644
index 0000000..e886975
--- /dev/null
+++ b/src/arvstr.h
@@ -0,0 +1,74 @@
+/* Lasem
+ *
+ * Copyright  2009 Emmanuel Pacaud
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ * 	Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#ifndef ARV_STR_H
+#define ARV_STR_H
+
+#include <arvtypes.h>
+
+G_BEGIN_DECLS
+
+gboolean 	arv_str_is_uri 		(const char *str);
+char *   	arv_str_to_uri 		(const char *str);
+
+gboolean 	arv_str_parse_double 		(char **str, double *x);
+unsigned int 	arv_str_parse_double_list 	(char **str, unsigned int n_values, double *values);
+
+static inline void
+arv_str_skip_spaces (char **str)
+{
+	while (g_ascii_isspace (**str))
+		(*str)++;
+}
+
+static inline void
+arv_str_skip_char (char **str, char c)
+{
+	while (**str == c)
+		(*str)++;
+}
+
+static inline void
+arv_str_skip_comma_and_spaces (char **str)
+{
+	while (g_ascii_isspace (**str) || **str == ',')
+		(*str)++;
+}
+
+static inline void
+arv_str_skip_semicolon_and_spaces (char **str)
+{
+	while (g_ascii_isspace (**str) || **str == ';')
+		(*str)++;
+}
+
+static inline void
+arv_str_skip_colon_and_spaces (char **str)
+{
+	while (g_ascii_isspace (**str) || **str == ':')
+		(*str)++;
+}
+
+G_END_DECLS
+
+#endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]