1 //:
2 // \file
3 // \brief Old deprecated version Specialised version of binary IO for vector<vector<bool> > for backwards compatibility
4 // only. \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 vsl_b_read_vec_vec_bool_old(vsl_b_istream & is, std::vector<std::vector<bool>> & v)
23 {
24   if (!is)
25     return;
26 
27   unsigned int n, m;
28   short ver;
29   vsl_b_read(is, ver);
30   switch (ver)
31   {
32     case 1:
33       vsl_b_read(is, n);
34       v.resize(n);
35       for (unsigned int i = 0; i < n; ++i)
36       {
37         vsl_b_read(is, m);
38         v[i].resize(m);
39         for (unsigned int j = 0; j < m; ++j)
40         {
41           bool b;
42           vsl_b_read(is, b);
43           v[i][j] = b;
44         }
45       }
46       break;
47 
48     default:
49       std::cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, std::vector<std::vector<T> >&)\n"
50                 << "           Unknown version number " << ver << '\n';
51       is.is().clear(std::ios::badbit); // Set an unrecoverable IO error on stream
52       return;
53   }
54 }
55