FACT++  1.0
int FitsDumper::Exec ( Configuration conf)

Configures the fitsLoader from the config file and/or command arguments.

Retrieves the configuration parameters

Parameters
confthe configuration object

Definition at line 958 of file fitsdump.cc.

References Dump(), DumpMinMax(), DumpRoot(), DumpStats(), Configuration::Get(), Configuration::Has(), InitColumns(), List(), ListFileContent(), ListHeader(), and Configuration::Vec().

Referenced by main().

959 {
960  if (conf.Get<bool>("list"))
961  List();
962 
963  if (conf.Get<bool>("filecontent"))
964  ListFileContent();
965 
966  if (conf.Get<bool>("header"))
967  ListHeader(conf.Get<string>("outfile"));
968 
969 
970  if (conf.Get<bool>("header") || conf.Get<bool>("list") || conf.Get<bool>("filecontent"))
971  return 1;
972 
973  // ------------------------------------------------------------
974 
975  if (conf.Get<bool>("minmax") && conf.Get<bool>("stat"))
976  {
977  cerr << "Invalid combination of options: cannot do stats and minmax." << endl;
978  return -1;
979  }
980  if (conf.Get<bool>("stat") && conf.Get<bool>("nozero"))
981  {
982  cerr << "Invalid combination of options: nozero only works with minmax." << endl;
983  return -1;
984  }
985 
986  if (conf.Get<bool>("scientific") && conf.Get<bool>("fixed"))
987  {
988  cerr << "Switched --scientific and --fixed are mutually exclusive." << endl;
989  return -1;
990  }
991 
992  if (conf.Has("%") && conf.Has("%%"))
993  {
994  cerr << "Switched --% and --%% are mutually exclusive." << endl;
995  return -1;
996  }
997 
998  // ------------------------------------------------------------
999 
1000  const string filename = conf.Get<string>("outfile");
1001 
1002  ostream fout(cout.rdbuf());
1003 
1004  ofstream sout;
1005  if (filename!="-")
1006  {
1007  sout.open(filename);
1008  if (!sout)
1009  {
1010  cerr << "Cannot open output stream " << filename << ": " << strerror(errno) << endl;
1011  return false;
1012  }
1013  fout.rdbuf(sout.rdbuf());
1014  }
1015 
1016  fout.precision(conf.Get<int>("precision"));
1017  if (conf.Get<bool>("fixed"))
1018  fout << fixed;
1019  if (conf.Get<bool>("scientific"))
1020  fout << scientific;
1021 
1022  const string filter = conf.Has("filter") ? conf.Get<string>("filter") : "";
1023  const size_t first = conf.Get<size_t>("first");
1024  const size_t limit = conf.Get<size_t>("limit");
1025 
1026 #ifdef HAVE_ROOT
1027  if (conf.Get<bool>("root"))
1028  {
1029  DumpRoot(fout, conf.Vec<string>("col"), filter, first, limit, filename);
1030  return 0;
1031  }
1032 #endif
1033 
1034  const vector<string> format = conf.Vec<string>("%");
1035  for (auto it=format.begin(); it<format.end(); it++)
1036  {
1037  static const boost::regex expr("-?[0-9]*[.]?[0-9]*[diouxXeEfFgGaAh]");
1038 
1039  boost::smatch what;
1040  if (!boost::regex_match(*it, what, expr, boost::match_extra))
1041  {
1042  cerr << "Format '" << *it << "' not supported." << endl;
1043  return -1;
1044  }
1045  }
1046 
1047  const vector<MyColumn> cols = InitColumns(conf.Vec<string>("col"));
1048  if (cols.empty())
1049  return false;
1050 
1051  if (conf.Get<bool>("minmax"))
1052  {
1053  DumpMinMax(fout, cols, first, limit, conf.Get<bool>("nozero"));
1054  return 0;
1055  }
1056 
1057  if (conf.Get<bool>("stat"))
1058  {
1059  DumpStats(fout, cols, filter, first, limit);
1060  return 0;
1061  }
1062 
1063  Dump(fout, format, cols, filter, first, limit, filename);
1064 
1065  return 0;
1066 }
void DumpStats(ostream &, const vector< MyColumn > &, const string &, size_t, size_t)
Definition: fitsdump.cc:849
void List()
Lists all columns of an open file.
Definition: fitsdump.cc:126
T Get(const std::string &var)
std::vector< T > Vec(const std::string &var)
int64_t first
Size of this column in the tile.
Definition: zofits.h:26
void ListFileContent() const
Definition: fitsdump.cc:168
void DumpRoot(ostream &, const vector< string > &, const string &, size_t, size_t, const string &)
Definition: fitsdump.cc:641
void ListHeader(const string &filename)
Definition: fitsdump.cc:177
vector< MyColumn > InitColumns(vector< string > list)
Definition: fitsdump.cc:203
bool Has(const std::string &var)
void DumpMinMax(ostream &, const vector< MyColumn > &, size_t, size_t, bool)
Definition: fitsdump.cc:732
void Dump(ostream &, const vector< string > &, const vector< MyColumn > &, const string &, size_t, size_t, const string &)
Display the selected columns values VS time.
Definition: fitsdump.cc:413

+ Here is the call graph for this function:

+ Here is the caller graph for this function: