Use fmtlib for string formatting in opmhash

This commit is contained in:
Joakim Hove 2020-09-18 11:23:43 +02:00
parent 4e5aed45d7
commit b09db0325d

View File

@ -18,10 +18,10 @@
*/
#include <getopt.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <fmt/format.h>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
@ -85,12 +85,11 @@ std::size_t deck_hash(const std::vector<keyword>& keywords) {
void print_keywords(const std::vector<keyword>& keywords, bool location_info) {
for (const auto& kw : keywords) {
if (location_info)
std::cout << std::setw(8) << std::left << kw.name << " : " << kw.filename << ":" << kw.line_number << " " << kw.content_hash << std::endl;
fmt::print("{:8s} : {}:{} {} \n", kw.name, kw.filename, kw.line_number, kw.content_hash);
else
std::cout << std::setw(8) << std::left << kw.name << " : " << kw.content_hash << std::endl;
fmt::print("{:8s} : {} \n", kw.name, kw.content_hash);
}
std::cout << std::endl;
std::cout << std::setw(8) << std::left << "Total" << " : " << deck_hash(keywords) << std::endl;
fmt::print("\n{:8s} : {}\n", "Total", deck_hash(keywords));
}