core/vnl/xio/vnl_xio_matrix_fixed.txx
Go to the documentation of this file.
00001 // This is core/vnl/xio/vnl_xio_matrix_fixed.txx
00002 #ifndef vnl_xio_matrix_fixed_txx_
00003 #define vnl_xio_matrix_fixed_txx_
00004 
00005 #include "vnl_xio_matrix_fixed.h"
00006 #include <vnl/vnl_matrix_fixed.h>
00007 #include <vsl/vsl_basic_xml_element.h>
00008 
00009 //=================================================================================
00010 template<class T, unsigned m, unsigned n>
00011 void x_write(vcl_ostream & os, vnl_matrix_fixed<T,m,n> const& M, vcl_string name)
00012 {
00013   vsl_basic_xml_element element(name);
00014   element.add_attribute("rows", (int) m);
00015   element.add_attribute("cols", (int) n);
00016   for (unsigned int r=0; r<m; ++r) {
00017     for (unsigned int c=0; c<n; ++c)
00018       element.append_cdata(M.get(r,c));
00019   }
00020   element.x_write(os);
00021 }
00022 
00023 //=================================================================================
00024 template<class T, unsigned m, unsigned n>
00025 void x_write_tree(vcl_ostream & os, vnl_matrix_fixed<T,m,n> const& M, vcl_string name)
00026 {
00027   vsl_basic_xml_element element(name);
00028   element.add_attribute("rows", (int) m);
00029   element.add_attribute("cols", (int) n);
00030   for (unsigned int r=0; r<m; ++r) {
00031     element.append_cdata("<row>");
00032     for (unsigned int c=0; c<n; ++c) {
00033       element.append_cdata("<cell>");
00034       element.append_cdata(M.get(r,c));
00035       element.append_cdata("</cell>");
00036     }
00037     element.append_cdata("</row>");
00038   }
00039   element.x_write(os);
00040 }
00041 
00042 #undef VNL_XIO_MATRIX_FIXED_INSTANTIATE
00043 #define VNL_XIO_MATRIX_FIXED_INSTANTIATE(T,m,n) \
00044 template void x_write(vcl_ostream &, vnl_matrix_fixed<T,m,n > const&, vcl_string); \
00045 template void x_write_tree(vcl_ostream &, vnl_matrix_fixed<T,m,n > const&, vcl_string)
00046 
00047 #endif // vnl_xio_matrix_fixed_txx_