vnl_xio_vector_fixed.hxx
Go to the documentation of this file.
1 // This is core/vnl/xio/vnl_xio_vector_fixed.hxx
2 #ifndef vnl_xio_vector_fixed_hxx_
3 #define vnl_xio_vector_fixed_hxx_
4 
5 #include "vnl_xio_vector_fixed.h"
6 #include <vsl/vsl_basic_xml_element.h>
7 
8 //=================================================================================
9 template<class T, unsigned int n>
10 void x_write(std::ostream & os, vnl_vector_fixed<T,n> const& v, std::string name)
11 {
12  vsl_basic_xml_element element(name);
13  element.add_attribute("size", (int) n);
14  for (unsigned i=0; i<n; i++)
15  element.append_cdata(v.get(i));
16  element.x_write(os);
17 }
18 
19 //=================================================================================
20 template<class T, unsigned int n>
21 void x_write_tree(std::ostream & os, vnl_vector_fixed<T,n> const& v, std::string name)
22 {
23  vsl_basic_xml_element element(name);
24  element.add_attribute("size", (int) n);
25  for (unsigned i=0; i<n; i++) {
26  element.append_cdata("<element>");
27  element.append_cdata(v.get(i));
28  element.append_cdata("</element>");
29  }
30  element.x_write(os);
31 }
32 
33 #undef VNL_XIO_VECTOR_FIXED_INSTANTIATE
34 #define VNL_XIO_VECTOR_FIXED_INSTANTIATE(T,n) \
35 template void x_write(std::ostream &, vnl_vector_fixed<T,n > const&, std::string); \
36 template void x_write_tree(std::ostream &, vnl_vector_fixed<T,n > const&, std::string)
37 
38 #endif // vnl_xio_vector_fixed_hxx_
void VNL_EXPORT x_write_tree(std::ostream &os, vnl_matrix< T > const &v, std::string name="vnl_matrix")
XML save vnl_matrix as a 3-level tree to stream.
#define v
Definition: vnl_vector.h:42
XML write a vnl_vector_fixed Two functions which write a valid XML fragment to an ostream.
Fixed length stack-stored, space-efficient vector.
Definition: vnl_fwd.h:22
void VNL_EXPORT x_write(std::ostream &os, vnl_matrix< T > const &v, std::string name="vnl_matrix")
XML save vnl_matrix to stream.