vsl_vector_io_vector_bool.cxx
Go to the documentation of this file.
1 //:
2 // \file
3 // \brief Old deprecated version Specialised version of binary IO for vector<vector<bool> > for backwards compatibility only.
4 // \author Kevin de Souza (based on vsl_vector_io_bool.cxx by Ian Scott)
5 //
6 
7 #include <iostream>
8 #include "vsl_vector_io.h"
9 #include <vsl/vsl_binary_io.h>
10 #ifdef _MSC_VER
11 # include <vcl_msvc_warnings.h>
12 #endif
13 #include <vcl_deprecated.h>
14 
15 //====================================================================================
16 //: Read vector from binary stream in an old deprecated format.
17 // \deprecated in favour of correctly work normal vsl behaviour. Only kept for backwards compatibility.
18 // If no-one complains about the name change to this code, or otherwise asks for it
19 // to be kept, then it should be removed after the release of VXL 1.18. The name change will
20 // however remain, to avoid overriding normal performance of vsl(vec<vec<bool>>) IMS July 2012.
21 void vsl_b_read_vec_vec_bool_old(vsl_b_istream& is, std::vector<std::vector<bool> >& v)
22 {
23  if (!is) return;
24 
25  unsigned int n, m;
26  short ver;
27  vsl_b_read(is, ver);
28  switch (ver)
29  {
30  case 1:
31  vsl_b_read(is, n);
32  v.resize(n);
33  for (unsigned int i=0; i<n; ++i)
34  {
35  vsl_b_read(is, m);
36  v[i].resize(m);
37  for (unsigned int j=0; j<m; ++j)
38  {
39  bool b;
40  vsl_b_read(is, b);
41  v[i][j] = b;
42  }
43  }
44  break;
45 
46  default:
47  std::cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, std::vector<std::vector<T> >&)\n"
48  << " Unknown version number "<< ver << '\n';
49  is.is().clear(std::ios::badbit); // Set an unrecoverable IO error on stream
50  return;
51  }
52 }
std::istream & is() const
A reference to the adaptor's stream.
void vsl_b_read(vsl_b_istream &is, char &n)
Read char from vsl_b_istream.
An adaptor for any std::istream to make it suitable for binary input.
Set of functions, and objects to perform binary IO.
void vsl_b_read_vec_vec_bool_old(vsl_b_istream &is, std::vector< std::vector< bool > > &v)
Read vector from binary stream in an old deprecated format.
binary IO functions for std::vector<T>