core/vsl/vsl_vector_io_vector_bool.cxx
Go to the documentation of this file.
00001 //:
00002 // \file
00003 // \brief Old deprecated version Specialised version of binary IO for vector<vector<bool> > for backwards compatibility only.
00004 // \author Kevin de Souza (based on vsl_vector_io_bool.cxx by Ian Scott)
00005 //
00006 
00007 #include "vsl_vector_io.h"
00008 #include <vsl/vsl_binary_io.h>
00009 #include <vcl_iostream.h>
00010 #include <vcl_deprecated.h>
00011 
00012 //====================================================================================
00013 //: Read vector from binary stream in an old deprecated format.
00014 // \deprecated in favour of correctly work normal vsl behaviour. Only kept for backwards compatibility.
00015 // If no-one complains about the name change to this code, or otherwise asks for it
00016 // to be kept, then it should be removed after the release of VXL 1.18. The name change will
00017 // however remain, to avoid overriding normal performance of vsl(vec<vec<bool>>) IMS July 2012.
00018 void vsl_b_read_vec_vec_bool_old(vsl_b_istream& is, vcl_vector<vcl_vector<bool> >& v)
00019 {
00020   if (!is) return;
00021 
00022   unsigned int n, m;
00023   short ver;
00024   vsl_b_read(is, ver);
00025   switch (ver)
00026   {
00027   case 1:
00028     vsl_b_read(is, n);
00029     v.resize(n);
00030     for (unsigned int i=0; i<n; ++i)
00031     {
00032       vsl_b_read(is, m);
00033       v[i].resize(m);
00034       for (unsigned int j=0; j<m; ++j)
00035       {
00036         bool b;
00037         vsl_b_read(is, b);
00038         v[i][j] = b;
00039       }
00040     }
00041     break;
00042 
00043   default:
00044     vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vcl_vector<vcl_vector<T> >&)\n"
00045              << "           Unknown version number "<< ver << '\n';
00046     is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on stream
00047     return;
00048   }
00049 }
00050 
00051 
00052