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

randombit / botan / 5079590438

25 May 2023 12:28PM UTC coverage: 92.228% (+0.5%) from 91.723%
5079590438

Pull #3502

github

Pull Request #3502: Apply clang-format to the codebase

75589 of 81959 relevant lines covered (92.23%)

12139530.51 hits per line

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

90.91
/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
#include <istream>
10
#include <ostream>
11

12
namespace Botan {
13

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

22
   const size_t base = (stream_flags & std::ios::hex) ? 16 : 10;
58✔
23

24
   std::string enc;
58✔
25

26
   if(base == 10)
58✔
27
      enc = n.to_dec_string();
28✔
28
   else
29
      enc = n.to_hex_string();
30✔
30

31
   stream.write(enc.data(), enc.size());
58✔
32

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

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

50
}
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