core/vnl/io/vnl_io_bignum.cxx
Go to the documentation of this file.
00001 // This is core/vnl/io/vnl_io_bignum.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 
00008 #include "vnl_io_bignum.h"
00009 #include <vsl/vsl_binary_io.h>
00010 
00011 //=================================================================================
00012 //: Binary save self to stream.
00013 void vsl_b_write(vsl_b_ostream & os, const vnl_bignum & p)
00014 {
00015   const short io_version_no = 1;
00016   vsl_b_write(os, io_version_no);
00017   vcl_string s;
00018   vnl_bignum_to_string(s, p);
00019   vsl_b_write(os, s);
00020 }
00021 
00022 //=================================================================================
00023 //: Binary load self from stream.
00024 void vsl_b_read(vsl_b_istream &is, vnl_bignum & p)
00025 {
00026   if (!is) return;
00027   short ver;
00028   vcl_string s;
00029   vsl_b_read(is, ver);
00030   switch (ver)
00031   {
00032    case 1:
00033     vsl_b_read(is, s);
00034     vnl_bignum_from_string(p, s);
00035     break;
00036 
00037    default:
00038     vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vnl_bignum&)\n"
00039              << "           Unknown version number "<< ver << '\n';
00040     is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on stream
00041     return;
00042   }
00043 }
00044 
00045 //====================================================================================
00046 //: Output a human readable summary to the stream
00047 void vsl_print_summary(vcl_ostream & os,const vnl_bignum & p)
00048 {
00049   os<<p;
00050 }