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