summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBob Jamison <ishmalius@gmail.com>2008-06-14 21:17:27 +0000
committerishmal <ishmal@users.sourceforge.net>2008-06-14 21:17:27 +0000
commitecfc0c494a65c52032261a864b5f53578742e08c (patch)
treee526d6ff2bfea8f44746a37a57274def675cd6f4 /src
parentexperimental version without multiple inheritance (diff)
downloadinkscape-ecfc0c494a65c52032261a864b5f53578742e08c.tar.gz
inkscape-ecfc0c494a65c52032261a864b5f53578742e08c.zip
Add SVGValue class
(bzr r5941)
Diffstat (limited to 'src')
-rw-r--r--src/dom/svg2.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/dom/svg2.h b/src/dom/svg2.h
index 0e980cf89..0da3d861d 100644
--- a/src/dom/svg2.h
+++ b/src/dom/svg2.h
@@ -246,6 +246,92 @@ const char *svgElementEnumToStr(int type);
/*#########################################################################
+## SVGValue
+#########################################################################*/
+
+
+/**
+ * A helper class to provide a common API across several data types
+ */
+class SVGValue
+{
+public:
+
+ /**
+ * Constructors
+ */
+ SVGValue()
+ { init(); }
+
+ SVGValue(const SVGValue &other)
+ { assign(other); }
+
+ SVGValue(double val)
+ { init(); type = SVG_DOUBLE; dval = val; }
+
+ SVGValue(long val)
+ { init(); type = SVG_INT; ival = val; }
+
+ SVGValue(const DOMString &val)
+ { init(); type = SVG_STRING; sval = val; }
+
+ int getType()
+ { return type; }
+
+ /**
+ * Assignment
+ */
+ SVGValue &operator=(const SVGValue &val)
+ { assign(val); return *this; }
+
+ SVGValue &operator=(double val)
+ { init(); type = SVG_DOUBLE; dval = val; return *this; }
+
+ SVGValue &operator=(long val)
+ { init(); type = SVG_INT; ival = val; return *this; }
+
+ SVGValue &operator=(const DOMString &val)
+ { init(); type = SVG_STRING; sval = val; return *this; }
+
+ /**
+ * Getters
+ */
+ double doubleValue()
+ { return dval; }
+
+ long intValue()
+ { return ival; }
+
+ DOMString &stringValue()
+ { return sval; }
+
+private:
+
+ void init()
+ {
+ type = SVG_DOUBLE;
+ dval = 0.0;
+ ival = 0;
+ sval.clear();
+ }
+
+ void assign(const SVGValue &other)
+ {
+ type = other.type;
+ dval = other.dval;
+ ival = other.ival;
+ sval = other.sval;
+ }
+
+ int type;
+ double dval;
+ long ival;
+ DOMString sval;
+
+};
+
+
+/*#########################################################################
## SVGElement
#########################################################################*/