Skip to content

Commit

Permalink
Handle newlines in external partition file (lnis-uofu#87)
Browse files Browse the repository at this point in the history
* external_partion fixed

* Update external_partition.hpp

* Update utility.cpp

Co-authored-by: ALEXANDRE NORMAND <[email protected]>
  • Loading branch information
NormandAlexandre and ALEXANDRE NORMAND authored Jul 7, 2022
1 parent 7368723 commit febd152
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,14 @@ template function_counts node_functions<xmg_names>(const xmg_names&);
template function_counts node_functions<aig_names>(const aig_names&);
template function_counts node_functions<xag_names>(const xag_names&);
}
bool is_digits(const std::string &str)
{
return std::all_of(str.begin(), str.end(), ::isdigit); // C++11
}

std::vector<int> read_integer_file(string filename)
{

std::vector<int> output;
std::ifstream ifs;

Expand All @@ -715,7 +720,8 @@ std::vector<int> read_integer_file(string filename)
while (ifs.good()) {
std::string part;
getline(ifs, part);
if (part != "")
std::cout<<"part:"<<part<<std::endl;
if (!part.empty() && is_digits(part))
output.push_back(std::stoi(part));
}
ifs.close();
Expand Down
1 change: 1 addition & 0 deletions core/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,5 @@ void update_counts(function_counts &counts,
const typename network::node &node);

}
bool is_digits(const std::string &str);
std::vector<int> read_integer_file(string filename);

0 comments on commit febd152

Please sign in to comment.