MCPcopy Create free account
hub / github.com/aff3ct/aff3ct / read_info_bits_pos

Function read_info_bits_pos

src/Module/Encoder/User/Encoder_user.cpp:15–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13using namespace aff3ct::module;
14
15std::vector<uint32_t>
16read_info_bits_pos(std::istream& stream)
17{
18 std::string line;
19
20 // look for the position in the file where the info bits begin
21 while (std::getline(stream, line))
22 if (line == "# Positions of the information bits in the codewords:" || stream.eof() || stream.fail() ||
23 stream.bad())
24 break;
25
26 getline(stream, line);
27 auto values = tools::split(line);
28 if (values.size() != 1)
29 {
30 std::stringstream message;
31 message << "'values.size()' has to be equal to 1 ('values.size()' = " << values.size() << ").";
32 throw spu::tools::runtime_error(__FILE__, __LINE__, __func__, message.str());
33 }
34
35 const uint32_t size = std::stoi(values[0]);
36
37 getline(stream, line);
38 values = tools::split(line);
39 if (values.size() != size)
40 {
41 std::stringstream message;
42 message << "'values.size()' has to be equal to 'size' ('values.size()' = " << values.size()
43 << ", 'size' = " << size << ").";
44 throw spu::tools::runtime_error(__FILE__, __LINE__, __func__, message.str());
45 }
46
47 std::vector<uint32_t> info_bits_pos;
48 for (auto v : values)
49 {
50 const uint32_t pos = std::stoi(v);
51
52 if (std::find(info_bits_pos.begin(), info_bits_pos.end(), pos) != info_bits_pos.end())
53 {
54 std::stringstream message;
55 message << "'pos' already exists in the 'info_bits_pos' vector ('pos' = " << pos << ").";
56 throw spu::tools::runtime_error(__FILE__, __LINE__, __func__, message.str());
57 }
58
59 info_bits_pos.push_back(pos);
60 }
61
62 return info_bits_pos;
63}
64
65template<typename B>
66Encoder_user<B>::Encoder_user(const int K, const int N, const std::string& filename, const int start_idx)

Callers 3

Encoder_userMethod · 0.85
read_info_bits_posMethod · 0.85
readMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected