astrotypes  0.0
sigproc_header.cpp
Go to the documentation of this file.
1 /*
2  * MIT License
3  *
4  * Copyright (c) 2018 PulsarSearchSoft
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
25 #include <fstream>
26 
27 void usage(const char* program_name)
28 {
29  std::cout << "Usage:\n"
30  << "\t" << program_name << " [options] input_file\n"
31  << "Synopsis:\n"
32  << "\tDisplays the header information of the provided input_files to stdout,\n"
33  << "Options:\n"
34  << "\t--help : this message\n";
35 }
36 
37 int main(int argc, char** argv) {
38 
39  std::string file;
40 
41  // process command line
42  for(int a=1; a < argc; ++a) {
43  if((char)argv[a][0] == '-') {
44  if(std::string("--help") == argv[a])
45  {
46  usage(argv[0]);
47  return 0;
48  }
49  else {
50  std::cerr << "unknown parameter " << argv[a] << std::endl;
51  usage(argv[0]);
52  return 1;
53  }
54  }
55  else {
56  file = argv[a];
57  }
58  }
59  if(file.size() == 0) {
60  std::cerr << argv[0] << " error: no input file supplied" << std::endl;
61  usage(argv[0]);
62  return 1;
63  }
64 
65  // read in a sigproc file
66  std::ifstream input_file_stream(file);
67 
69  input_file_stream >> header;
70 
71  // dump header information to the screen in a human readable format
72  std::cout << pss::astrotypes::sigproc::Header::Info() << header;
73 
74 }
Store SigProc header information.
Definition: Header.h:73
int main(int argc, char **argv)
void usage(const char *program_name)