• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 21753596263

06 Feb 2026 02:13PM UTC coverage: 90.063% (-0.01%) from 90.073%
21753596263

Pull #5289

github

web-flow
Merge 587099284 into 8ea0ca252
Pull Request #5289: Further misc header reductions, forward declarations, etc

102237 of 113517 relevant lines covered (90.06%)

11402137.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.47
/src/lib/math/bigint/big_io.cpp
1
/*
2
* BigInt Input/Output
3
* (C) 1999-2007 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/bigint.h>
9

10
#include <botan/exceptn.h>
11
#include <istream>
12
#include <ostream>
13

14
namespace Botan {
15

16
/*
17
* Write the BigInt into a stream
18
*/
19
std::ostream& operator<<(std::ostream& stream, const BigInt& n) {
59✔
20
   const auto stream_flags = stream.flags();
59✔
21
   if((stream_flags & std::ios::oct) != 0) {
59✔
22
      throw Invalid_Argument("Octal output of BigInt not supported");
1✔
23
   }
24

25
   const size_t base = (stream_flags & std::ios::hex) != 0 ? 16 : 10;
58✔
26

27
   if(base == 10) {
58✔
28
      stream << n.to_dec_string();
54✔
29
   } else {
30
      stream << n.to_hex_string();
62✔
31
   }
32

33
   if(!stream.good()) {
58✔
34
      throw Stream_IO_Error("BigInt output operator has failed");
×
35
   }
36
   return stream;
58✔
37
}
38

39
/*
40
* Read the BigInt from a stream
41
*/
42
std::istream& operator>>(std::istream& stream, BigInt& n) {
5✔
43
   std::string str;
5✔
44
   std::getline(stream, str);
5✔
45
   if(stream.bad() || (stream.fail() && !stream.eof())) {
5✔
46
      throw Stream_IO_Error("BigInt input operator has failed");
×
47
   }
48
   n = BigInt(str);
5✔
49
   return stream;
5✔
50
}
5✔
51

52
}  // namespace Botan
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc