core/vnl/xio/vnl_xio_quaternion.txx
Go to the documentation of this file.
00001 // This is core/vnl/xio/vnl_xio_quaternion.txx
00002 #ifndef vnl_xio_quaternion_txx_
00003 #define vnl_xio_quaternion_txx_
00004 
00005 #include "vnl_xio_quaternion.h"
00006 #include <vnl/vnl_quaternion.h>
00007 #include <vsl/vsl_basic_xml_element.h>
00008 
00009 //=================================================================================
00010 template<class T>
00011 void x_write(vcl_ostream & os, vnl_quaternion<T> const& q, vcl_string name)
00012 {
00013   vsl_basic_xml_element element(name);
00014   element.add_attribute("x", q.x());
00015   element.add_attribute("y", q.y());
00016   element.add_attribute("z", q.z());
00017   element.add_attribute("r", q.r());
00018   element.x_write(os);
00019 }
00020 
00021 //=================================================================================
00022 template<class T>
00023 void x_write_tree(vcl_ostream & os, vnl_quaternion<T> const& q, vcl_string name)
00024 {
00025   vsl_basic_xml_element element(name);
00026   element.append_cdata("<x>"); element.append_cdata(q.x()); element.append_cdata("</x>");
00027   element.append_cdata("<y>"); element.append_cdata(q.y()); element.append_cdata("</y>");
00028   element.append_cdata("<z>"); element.append_cdata(q.z()); element.append_cdata("</z>");
00029   element.append_cdata("<r>"); element.append_cdata(q.r()); element.append_cdata("</r>");
00030   element.x_write(os);
00031 }
00032 
00033 #undef VNL_XIO_QUATERNION_INSTANTIATE
00034 #define VNL_XIO_QUATERNION_INSTANTIATE(T) \
00035 template void x_write(vcl_ostream &, vnl_quaternion<T > const&, vcl_string); \
00036 template void x_write_tree(vcl_ostream &, vnl_quaternion<T > const&, vcl_string)
00037 
00038 #endif // vnl_xio_quaternion_txx_