From 363d3700165819bfc4251c1c925622a6c4a73c08 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Sat, 18 Jan 2014 22:06:42 +0100 Subject: [PATCH] Issue warning if output observation definition file has no .xml suffix. --- src/ctbin/ctbin.cpp | 12 ++++++++++++ src/ctmodel/ctmodel.cpp | 12 ++++++++++++ src/ctobssim/ctobssim.cpp | 14 +++++++++++++- src/ctselect/ctselect.cpp | 12 ++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/ctbin/ctbin.cpp b/src/ctbin/ctbin.cpp index 9a61cc5..d2aca6c 100644 --- a/src/ctbin/ctbin.cpp +++ b/src/ctbin/ctbin.cpp @@ -819,6 +819,18 @@ void ctbin::save_xml(void) m_outfile = (*this)["outfile"].filename(); m_prefix = (*this)["prefix"].string(); + // Issue warning if output filename has no .xml suffix + std::string suffix = gammalib::tolower(m_outfile.substr(m_outfile.length()-4,4)); + if (suffix != ".xml") { + log << "*** WARNING: Name of observation definition output file \""+ + m_outfile+"\"" << std::endl; + log << "*** WARNING: does not terminate with \".xml\"." << std::endl; + log << "*** WARNING: This is not an error, but might be misleading." + " It is recommended" << std::endl; + log << "*** WARNING: to use the suffix \".xml\" for observation" + " definition files." << std::endl; + } + // Loop over all observation in the container for (int i = 0; i < m_obs.size(); ++i) { diff --git a/src/ctmodel/ctmodel.cpp b/src/ctmodel/ctmodel.cpp index 708ba05..89f19f2 100644 --- a/src/ctmodel/ctmodel.cpp +++ b/src/ctmodel/ctmodel.cpp @@ -821,6 +821,18 @@ void ctmodel::save_xml(void) m_outfile = (*this)["outfile"].filename(); m_prefix = (*this)["prefix"].string(); + // Issue warning if output filename has no .xml suffix + std::string suffix = gammalib::tolower(m_outfile.substr(m_outfile.length()-4,4)); + if (suffix != ".xml") { + log << "*** WARNING: Name of observation definition output file \""+ + m_outfile+"\"" << std::endl; + log << "*** WARNING: does not terminate with \".xml\"." << std::endl; + log << "*** WARNING: This is not an error, but might be misleading." + " It is recommended" << std::endl; + log << "*** WARNING: to use the suffix \".xml\" for observation" + " definition files." << std::endl; + } + // Loop over all observation in the container for (int i = 0; i < m_obs.size(); ++i) { diff --git a/src/ctobssim/ctobssim.cpp b/src/ctobssim/ctobssim.cpp index a7bc036..9c1a0f7 100644 --- a/src/ctobssim/ctobssim.cpp +++ b/src/ctobssim/ctobssim.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctobssim - CTA observation simulator tool * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2013 by Juergen Knoedlseder * + * copyright (C) 2011-2014 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -1100,6 +1100,18 @@ void ctobssim::save_xml(void) m_outfile = (*this)["outfile"].filename(); m_prefix = (*this)["prefix"].string(); + // Issue warning if output filename has no .xml suffix + std::string suffix = gammalib::tolower(m_outfile.substr(m_outfile.length()-4,4)); + if (suffix != ".xml") { + log << "*** WARNING: Name of observation definition output file \""+ + m_outfile+"\"" << std::endl; + log << "*** WARNING: does not terminate with \".xml\"." << std::endl; + log << "*** WARNING: This is not an error, but might be misleading." + " It is recommended" << std::endl; + log << "*** WARNING: to use the suffix \".xml\" for observation" + " definition files." << std::endl; + } + // Initialise file number int file_num = 0; diff --git a/src/ctselect/ctselect.cpp b/src/ctselect/ctselect.cpp index 75fc5a8..36f44d3 100644 --- a/src/ctselect/ctselect.cpp +++ b/src/ctselect/ctselect.cpp @@ -905,6 +905,18 @@ void ctselect::save_xml(void) m_outfile = (*this)["outfile"].filename(); m_prefix = (*this)["prefix"].string(); + // Issue warning if output filename has no .xml suffix + std::string suffix = gammalib::tolower(m_outfile.substr(m_outfile.length()-4,4)); + if (suffix != ".xml") { + log << "*** WARNING: Name of observation definition output file \""+ + m_outfile+"\"" << std::endl; + log << "*** WARNING: does not terminate with \".xml\"." << std::endl; + log << "*** WARNING: This is not an error, but might be misleading." + " It is recommended" << std::endl; + log << "*** WARNING: to use the suffix \".xml\" for observation" + " definition files." << std::endl; + } + // Loop over all observation in the container for (int i = 0; i < m_obs.size(); ++i) { -- libgit2 0.21.4