QSDK 1.1 Documentation
Main Page | Modules | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

mathsxmlout.h

Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1999-2003 Qube Software, Ltd.
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are
00007  * met:
00008  * 
00009  * 1. Redistributions of the source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 
00012  * 2. Any redistribution solely in binary form must conspicuously
00013  *    reproduce the following disclaimer in documentation provided with the
00014  *    binary redistribution.
00015  * 
00016  * THIS SOFTWARE IS PROVIDED ``AS IS'', WITHOUT ANY WARRANTIES, EXPRESS
00017  * OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF
00018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  LICENSOR SHALL
00019  * NOT BE LIABLE FOR ANY LOSS OR DAMAGES RESULTING FROM THE USE OF THIS
00020  * SOFTWARE, EITHER ALONE OR IN COMBINATION WITH ANY OTHER SOFTWARE.
00021  * 
00022  *      $Qube: Q/maths/sdk/mathsxmlout.h,v 1.8 2002/08/20 07:19:29 nps Exp $
00023  */
00024 
00025 #ifndef __mxmlout_h__
00026 #define __mxmlout_h__
00027 
00028 #include <Q/xmlwrap.h>
00029 
00030 #ifndef MATHS_BEGIN
00031 #define MATHS_BEGIN     namespace Maths {
00032 #endif
00033 
00034 #ifndef MATHS_END
00035 #define MATHS_END       };
00036 #endif
00037 
00038 MATHS_BEGIN
00039 
00047 
00048 
00049 
00055 template<class T> XmlWrap::XmlNode 
00056 addXmlElement(XmlWrap::XmlNode parent,
00057               const char *name,
00058               const Vec2<T>& v)
00059 {
00060     XmlWrap::XmlNode vecNode = parent.addElement(name);
00061     vecNode.addElement("x", v.x);
00062     vecNode.addElement("y", v.y);
00063     return vecNode;
00064 }
00065 
00072 template<class T> XmlWrap::XmlNode
00073 addXmlElement(XmlWrap::XmlNode parent,
00074               const char *name,
00075               const Vec3<T>&v)
00076 {
00077     XmlWrap::XmlNode vecNode = parent.addElement(name);
00078     vecNode.addElement("x", v.x);
00079     vecNode.addElement("y", v.y);
00080     vecNode.addElement("z", v.z);
00081     return vecNode;
00082 }
00083 
00090 template<class T> XmlWrap::XmlNode
00091 addXmlElement(XmlWrap::XmlNode parent,
00092               const char *name,
00093               const Vec4<T>&v)
00094 {
00095     XmlWrap::XmlNode vecNode = parent.addElement(name);
00096     vecNode.addElement("x", v.x);
00097     vecNode.addElement("y", v.y);
00098     vecNode.addElement("z", v.z);
00099     vecNode.addElement("w", v.w);
00100     return vecNode;
00101 }
00102 
00109 inline XmlWrap::XmlNode
00110 addXmlElement(XmlWrap::XmlNode parent,
00111               const char *name,
00112               Color4b col)
00113 {
00114     XmlWrap::XmlNode colNode = parent.addElement(name);
00115     colNode.addElement("red", col.red());
00116     colNode.addElement("green", col.green());
00117     colNode.addElement("blue", col.blue());
00118     colNode.addElement("alpha", col.alpha());
00119     return colNode;
00120 }
00121 
00128 inline XmlWrap::XmlNode
00129 addXmlElement(XmlWrap::XmlNode parent,
00130               const char* name,
00131               const Quat4f& q)
00132 {
00133     XmlWrap::XmlNode quatNode = parent.addElement(name);
00134     quatNode.addElement("x", q.x);
00135     quatNode.addElement("y", q.y);
00136     quatNode.addElement("z", q.z);
00137     quatNode.addElement("w", q.w);
00138     return quatNode;
00139 }
00140 
00147 template<class T> XmlWrap::XmlNode 
00148 addXmlElement(XmlWrap::XmlNode parent,
00149               const char *name,
00150               const Box2<T>& b)
00151 {
00152     XmlWrap::XmlNode boxNode = parent.addElement(name);
00153     addXmlElement(boxNode, "min", b.bmin);
00154     addXmlElement(boxNode, "max", b.bmax);
00155     return boxNode;
00156 }
00157 
00164 inline XmlWrap::XmlNode 
00165 addXmlElement(XmlWrap::XmlNode parent,
00166               const char *name,
00167               const Box3f& b)
00168 {
00169     XmlWrap::XmlNode boxNode = parent.addElement(name);
00170     addXmlElement(boxNode, "min", b.bmin);
00171     addXmlElement(boxNode, "max", b.bmax);
00172     return boxNode;
00173 }
00174 
00176 
00177 MATHS_END
00178 
00179 #endif /* __mxmlout_h__ */

Return to QSDK documentation Contents page. Contact details for support, information and fault-reporting.
Qube Software Limited © 2000-2004