Loading data-access/engine/src/vlkb/src/ast.cpp +59 −42 Original line number Diff line number Diff line Loading @@ -97,15 +97,32 @@ void write_previous(string header, string filename) out << header; } void read_lines(string pathname, vector<string>& lines) { LOG_trace(__func__); static const string empty_card{" "}; lines.clear(); ifstream file(pathname); string s; while (getline(file, s)) { if(s.size()<80) s += empty_card.substr(0, 80-s.size()); lines.push_back(s); } } int header_backup(const string& pathname, bool backup) int header_backup(const string& pathname, const string& extra_cards_pathname, bool backup) { LOG_trace(__func__); int maxHdu = 1;//FIXME INT_MAX; // read all HDU's vector<string> extra_cards; read_lines(extra_cards_pathname, extra_cards); int maxHdu = 1;//FIXME INT_MAX; // read all HDU's std::vector<fitsfiles::Hdu> allHdus = fitsfiles::fname2hdrstr(pathname, maxHdu); fitsfiles::fname2hdrstr(pathname, extra_cards, maxHdu); for(unsigned int i=0; i<allHdus.size(); i++) { Loading @@ -121,7 +138,7 @@ int header_backup(const string& pathname, bool backup) unsigned long hdr_len = hd.m_header.length(); while((i*80+80) <= hdr_len) { cout << hd.m_header.substr(80*i++, 80) << endl; cout << hd.m_header.substr(80*i++, 80) << "<" << endl; } } // FIXME remove all explicit cout cerr to main.cpp and here use ostream& Loading data-access/engine/src/vlkb/src/ast.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ int vlkb_skyvertices(const std::string& pathname, const std::string& skysys_str); int vlkb_listbounds(const std::string& skysys_str, const std::string& specsys_str, const std::string& pathname); int header_backup(const std::string& pathname, bool backup = false); int header_backup(const std::string& pathname, const std::string& extra_cards_pathname, bool backup = false); int vlkb_overlap(const std::string& pathname, const std::string& region, std::vector<uint_bounds>& bnds); #endif data-access/engine/src/vlkb/src/main.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <algorithm> // replace needed #include <iostream> #include <sstream> #include <fstream> #include <assert.h> #include <libgen.h> // basename() Loading Loading @@ -397,7 +398,7 @@ int cmd_header(int argc, char * argv[]) if (argc < 2) { std::cerr << "Usage: header [--backup] <pathname.fits>...\n" << "Usage: header [--backup] [--extra-cards-pathname=<pathname>] <pathname.fits>...\n" << "\n" << "Prints current header (one card per line) or writes the header into a file with the same pathname but 'fitshdr' extension.\n" << "Arguments:\n" Loading @@ -407,6 +408,7 @@ int cmd_header(int argc, char * argv[]) else { bool backup = false; string extra_cards_pathname; for(int i=1; i<argc; i++) { Loading @@ -414,12 +416,17 @@ int cmd_header(int argc, char * argv[]) { backup = true; } else if(0 == (string(argv[i]).substr(0,2+21)).compare("--extra-cards-pathname=")) { extra_cards_pathname = (string{argv[i]}).substr(2+21); cout << "DBG " << extra_cards_pathname << endl; } else { string pathname(argv[i]); cout << to_string(i) << " : " << pathname << endl; rc = header_backup(pathname, backup); rc = header_backup(pathname, extra_cards_pathname, backup); std::cout << "header_backup rc: " << rc << std::endl; } } Loading Loading
data-access/engine/src/vlkb/src/ast.cpp +59 −42 Original line number Diff line number Diff line Loading @@ -97,15 +97,32 @@ void write_previous(string header, string filename) out << header; } void read_lines(string pathname, vector<string>& lines) { LOG_trace(__func__); static const string empty_card{" "}; lines.clear(); ifstream file(pathname); string s; while (getline(file, s)) { if(s.size()<80) s += empty_card.substr(0, 80-s.size()); lines.push_back(s); } } int header_backup(const string& pathname, bool backup) int header_backup(const string& pathname, const string& extra_cards_pathname, bool backup) { LOG_trace(__func__); int maxHdu = 1;//FIXME INT_MAX; // read all HDU's vector<string> extra_cards; read_lines(extra_cards_pathname, extra_cards); int maxHdu = 1;//FIXME INT_MAX; // read all HDU's std::vector<fitsfiles::Hdu> allHdus = fitsfiles::fname2hdrstr(pathname, maxHdu); fitsfiles::fname2hdrstr(pathname, extra_cards, maxHdu); for(unsigned int i=0; i<allHdus.size(); i++) { Loading @@ -121,7 +138,7 @@ int header_backup(const string& pathname, bool backup) unsigned long hdr_len = hd.m_header.length(); while((i*80+80) <= hdr_len) { cout << hd.m_header.substr(80*i++, 80) << endl; cout << hd.m_header.substr(80*i++, 80) << "<" << endl; } } // FIXME remove all explicit cout cerr to main.cpp and here use ostream& Loading
data-access/engine/src/vlkb/src/ast.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ int vlkb_skyvertices(const std::string& pathname, const std::string& skysys_str); int vlkb_listbounds(const std::string& skysys_str, const std::string& specsys_str, const std::string& pathname); int header_backup(const std::string& pathname, bool backup = false); int header_backup(const std::string& pathname, const std::string& extra_cards_pathname, bool backup = false); int vlkb_overlap(const std::string& pathname, const std::string& region, std::vector<uint_bounds>& bnds); #endif
data-access/engine/src/vlkb/src/main.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <algorithm> // replace needed #include <iostream> #include <sstream> #include <fstream> #include <assert.h> #include <libgen.h> // basename() Loading Loading @@ -397,7 +398,7 @@ int cmd_header(int argc, char * argv[]) if (argc < 2) { std::cerr << "Usage: header [--backup] <pathname.fits>...\n" << "Usage: header [--backup] [--extra-cards-pathname=<pathname>] <pathname.fits>...\n" << "\n" << "Prints current header (one card per line) or writes the header into a file with the same pathname but 'fitshdr' extension.\n" << "Arguments:\n" Loading @@ -407,6 +408,7 @@ int cmd_header(int argc, char * argv[]) else { bool backup = false; string extra_cards_pathname; for(int i=1; i<argc; i++) { Loading @@ -414,12 +416,17 @@ int cmd_header(int argc, char * argv[]) { backup = true; } else if(0 == (string(argv[i]).substr(0,2+21)).compare("--extra-cards-pathname=")) { extra_cards_pathname = (string{argv[i]}).substr(2+21); cout << "DBG " << extra_cards_pathname << endl; } else { string pathname(argv[i]); cout << to_string(i) << " : " << pathname << endl; rc = header_backup(pathname, backup); rc = header_backup(pathname, extra_cards_pathname, backup); std::cout << "header_backup rc: " << rc << std::endl; } } Loading