dump.H

00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00020 #ifndef ARCHON_X3D_DUMP_H
00021 #define ARCHON_X3D_DUMP_H
00022 
00023 #include <string>
00024 
00025 #include <archon/math/rotation.H>
00026 #include <archon/util/image.H>
00027 #include <archon/util/time.H>
00028 #include <archon/util/text.H>
00029 
00030 namespace Archon
00031 {
00032   namespace X3D
00033   {
00034     using namespace std;
00035     using namespace Math;
00036     using namespace Utilities;
00037 
00038     template<typename T>
00039     inline string dumpValue(const vector<T> &v)
00040     {
00041       string s = "[";
00042       for(unsigned i=0; i<v.size(); ++i)
00043       {
00044         if(i) s+= ", ";
00045         s += dumpValue(v[i]);
00046       }
00047       return s + "]";
00048     }
00049 
00050     inline string dumpValue(string v)
00051     {
00052       return "\"" + v + "\"";
00053     }
00054 
00055     inline string dumpValue(bool v)
00056     {
00057       return v ? "TRUE" : "FALSE";
00058     }
00059 
00060     inline string dumpValue(int v)
00061     {
00062       return Utilities::Text::toString(v);
00063     }
00064 
00065     inline string dumpValue(double v)
00066     {
00067       return Utilities::Text::toString(v);
00068     }
00069 
00070     inline string dumpValue(Vector2 v)
00071     {
00072       return
00073         Utilities::Text::toString(v[0]) + " " +
00074         Utilities::Text::toString(v[1]);
00075     }
00076 
00077     inline string dumpValue(Vector3 v)
00078     {
00079       return
00080         Utilities::Text::toString(v[0]) + " " +
00081         Utilities::Text::toString(v[1]) + " " +
00082         Utilities::Text::toString(v[2]);
00083     }
00084 
00085     inline string dumpValue(Vector4 v)
00086     {
00087       return
00088         Utilities::Text::toString(v[0]) + " " +
00089         Utilities::Text::toString(v[1]) + " " +
00090         Utilities::Text::toString(v[2]) + " " +
00091         Utilities::Text::toString(v[3]);
00092     }
00093 
00094     inline string dumpValue(Rotation3 v)
00095     {
00096       return
00097         Utilities::Text::toString(v.axis[0]) + " " +
00098         Utilities::Text::toString(v.axis[1]) + " " +
00099         Utilities::Text::toString(v.axis[2]) + " " +
00100         Utilities::Text::toString(v.angle);
00101     }
00102 
00103     inline string dumpValue(const Image &v)
00104     {
00105       return "<inlined image>";
00106     }
00107 
00108     inline string dumpValue(const Time &v)
00109     {
00110       return Utilities::Text::toString(v);
00111     }
00112   }
00113 }
00114 
00115 #endif // ARCHON_X3D_DUMP_H

Generated on Sun Jul 30 22:55:49 2006 for Archon by  doxygen 1.4.4