vnl_io_bignum.cxx
Go to the documentation of this file.
1 // This is core/vnl/io/vnl_io_bignum.cxx
2 //:
3 // \file
4 
5 #include "vnl_io_bignum.h"
6 #include <vsl/vsl_binary_io.h>
7 
8 //=================================================================================
9 //: Binary save self to stream.
10 void vsl_b_write(vsl_b_ostream & os, const vnl_bignum & p)
11 {
12  constexpr short io_version_no = 1;
13  vsl_b_write(os, io_version_no);
14  std::string s;
16  vsl_b_write(os, s);
17 }
18 
19 //=================================================================================
20 //: Binary load self from stream.
21 void vsl_b_read(vsl_b_istream &is, vnl_bignum & p)
22 {
23  if (!is) return;
24  short ver;
25  std::string s;
26  vsl_b_read(is, ver);
27  switch (ver)
28  {
29  case 1:
30  vsl_b_read(is, s);
32  break;
33 
34  default:
35  std::cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vnl_bignum&)\n"
36  << " Unknown version number "<< ver << '\n';
37  is.is().clear(std::ios::badbit); // Set an unrecoverable IO error on stream
38  return;
39  }
40 }
41 
42 //====================================================================================
43 //: Output a human readable summary to the stream
44 void vsl_print_summary(std::ostream & os,const vnl_bignum & p)
45 {
46  os<<p;
47 }
void vsl_print_summary(std::ostream &os, vnl_bignum const &b)
Print human readable summary of object to a stream.
Infinite precision integers.
Definition: vnl_bignum.h:143
void vsl_b_read(vsl_b_istream &is, vnl_bignum &v)
Binary load vnl_bignum from stream.
void vsl_b_write(vsl_b_ostream &os, vnl_bignum const &v)
Binary save vnl_bignum to stream.
std::string & vnl_bignum_to_string(std::string &s, const vnl_bignum &b)
Convert the number to a decimal representation in a string.
Definition: vnl_bignum.cxx:643
vnl_bignum & vnl_bignum_from_string(vnl_bignum &b, const std::string &s)
Convert the number from a decimal representation in a string.
Definition: vnl_bignum.cxx:667