Commit 07b4111f authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libdatrwxx [WP][API]: provide report functions in separate compilation unit

Since report functions must be addressed in error.h and in exception.cc their
prototypes must be presented in a different header file, if exception.h should
not expose error.h to library users.

error.cc has become empty and obsolete.
parent 664a39c5
......@@ -36,6 +36,8 @@
* - 05/07/2016 V1.5 thof: operate with string containers rather than
* with pointer to character arrays
* - 07/07/2016 V1.6 thof: move class exception to separate header
* - 08/07/2016 V1.7 thof: move report functions to separate compilation
* unit
*
* ============================================================================
*/
......@@ -44,41 +46,15 @@
#ifndef DATRW_ERROR_H_VERSION
#define DATRW_ERROR_H_VERSION \
"DATRW_ERROR_H V1.6"
"DATRW_ERROR_H V1.7"
#include <iostream>
#include <datrwxx/report.h>
#include <datrwxx/exception.h>
namespace datrw {
/*! \defgroup group_error Internal utility: Error handling module
*/
/*! \brief report violation of condition
*
* \ingroup group_error
* \param message message of type char*
* \param file name of source code file
* \param line source code line number
* \param condition assert condition
*/
void report_violation(const std::string& message,
const std::string& file,
const int& line,
const std::string& condition);
/*! \brief report deprecation of a function
*
* \ingroup group_error
* \param function name of deprecated function
* \param reason the reason for deprecating the function
* should finish a sentence which started with "because"
*/
void report_deprecated(const std::string& function,
const std::string& reason);
} // namespace datrw
/*======================================================================*/
//
// preprocessor macros
......@@ -152,7 +128,7 @@ namespace datrw {
*/
#define DATRW_report_assert(C,M,V) \
if (!(C)) { \
datrw::report_violation(M, __FILE__, __LINE__, #C); \
datrw::util::report_violation(M, __FILE__, __LINE__, #C); \
std::cerr << "* comment: " << V << std::endl; \
std::cerr << std::endl; \
std::cerr.flush(); \
......
......@@ -71,6 +71,7 @@
#include <datrwxx/thiesdl1.h>
#include <datrwxx/ascii.h>
#include <datrwxx/binary.h>
#include <datrwxx/report.h>
namespace datrw {
......@@ -141,7 +142,7 @@ namespace datrw {
ianystream::ianystream(std::istream& is, const Eformat& format,
const bool& debug)
{
report_deprecated("ianystream::ianystream(std::istream& is, "
datrw::util::report_deprecated("ianystream::ianystream(std::istream& is, "
"const Eformat& format)",
"this constructor does not support format modifiers");
this->open(is, anyID(format), debug);
......
/*! \file error.cc
* \brief exception class for libdatrwxx (implementation)
/*! \file report.cc
* \brief report errors and warnings (implementation)
*
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 30/03/2004
* \date 08/07/2016
*
* report errors and warnings (implementation)
*
* Copyright (c) 2016 by Thomas Forbriger (BFO Schiltach)
*
* exception class for libdatrwxx (implementation)
*
* ----
* This program is free software; you can redistribute it and/or modify
......@@ -20,29 +23,19 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----
*
* Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach)
*
*
* REVISIONS and CHANGES
* - 30/03/2004 V1.0 Thomas Forbriger (thof)
* - 07/07/2006 V1.1 added report function
* - 06/09/2011 V1.2 introduced report_deprecated
* - 10/06/2015 V1.3 update repository URL in report_deprecated
* - 05/07/2016 V1.4 thof:
* - operate with string containers rather than with
* pointer to character arrays
* - revise error output
* - 07/07/2016 V1.5 thof: move class exception to separate compilation
* unit
* - 08/07/2016 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define DATRW_ERROR_CC_VERSION \
"DATRW_ERROR_CC V1.5"
#define DATRW_REPORT_CC_VERSION \
"DATRW_REPORT_CC V1.0"
#include <datrwxx/report.h>
#include <iostream>
#include <datrwxx/error.h>
#include <datrwxx/aalibdatrwxx.h>
......@@ -53,37 +46,41 @@ using std::endl;
namespace datrw {
//! report violation of assertion
void report_violation(const std::string& message,
const std::string& file,
const int& line,
const std::string& condition)
{
cerr << endl;
cerr << "ERROR: " << datrw::libversion << " ";
cerr << "reports violation of condition:" << endl;
cerr << " \"" << condition << "\"" << endl;
cerr << " while reading or writing time series data" << endl;
cerr << " in " << file << " at line " << line << endl;
cerr << " " << message << endl;
}
namespace util {
//! report violation of assertion
void report_violation(const std::string& message,
const std::string& file,
const int& line,
const std::string& condition)
{
cerr << endl;
cerr << "ERROR: " << datrw::libversion << " ";
cerr << "reports violation of condition:" << endl;
cerr << " \"" << condition << "\"" << endl;
cerr << " while reading or writing time series data" << endl;
cerr << " in " << file << " at line " << line << endl;
cerr << " " << message << endl;
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
//! report deprecated function
void report_deprecated(const std::string& function,
const std::string& reason)
{
cerr << "WARNING: program uses deprecated function" << endl;
cerr << " \"" << function << "\"" << endl;
cerr << " from " << datrw::libversion << endl;
cerr << " This function should no longer be used because\n"
<< " " << reason << endl;
cerr << " Please report this issue at "
"http://git.scc.kit.edu/Seitosh/Seitosh"
<< endl;
}
//! report deprecated function
void report_deprecated(const std::string& function,
const std::string& reason)
{
cerr << "WARNING: program uses deprecated function" << endl;
cerr << " \"" << function << "\"" << endl;
cerr << " from " << datrw::libversion << endl;
cerr << " This function should no longer be used because\n"
<< " " << reason << endl;
cerr << " Please report this issue at "
"http://git.scc.kit.edu/Seitosh/Seitosh"
<< endl;
}
} // namespce util
} // namespace datrw
/* ----- END OF error.cc ----- */
/* ----- END OF report.cc ----- */
/*! \file report.h
* \brief report errors and warnings (prototypes)
*
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 08/07/2016
*
* report errors and warnings (prototypes)
*
* \ingroup group_error
*
* Copyright (c) 2016 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----
*
* REVISIONS and CHANGES
* - 08/07/2016 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef DATRW_REPORT_H_VERSION
#define DATRW_REPORT_H_VERSION \
"DATRW_REPORT_H V1.0"
#include <string>
namespace datrw {
namespace util {
/*! \brief report categories
* \ingroup group_error
*/
enum Ereports {
//! just a warning; processing can proceeed
Fwarning,
//! an error, but non-fatal; processing will proceed
Fnonfatal,
//! a fatal error; processing wil abort as a consequence
Ferror
}; // enum Ereports
/* ---------------------------------------------------------------------- */
/*! \brief report violation of condition
*
* \ingroup group_error
* \param message message of type char*
* \param file name of source code file
* \param line source code line number
* \param condition assert condition
*/
void report_violation(const std::string& message,
const std::string& file,
const int& line,
const std::string& condition);
/* ---------------------------------------------------------------------- */
/*! \brief report deprecation of a function
*
* \ingroup group_error
* \param function name of deprecated function
* \param reason the reason for deprecating the function
* should finish a sentence which started with
* "because"
*/
void report_deprecated(const std::string& function,
const std::string& reason);
} // namespace util
} // namespace datrw
#endif // DATRW_REPORT_H_VERSION (includeguard)
/* ----- END OF report.h ----- */
......@@ -53,13 +53,14 @@
#include <datrwxx/binary.h>
#include <datrwxx/formatmodifier.h>
#include <datrwxx/util.h>
#include <datrwxx/report.h>
namespace datrw {
oanystream::oanystream(std::ostream& os, const Eformat& format,
const bool& debug)
{
report_deprecated("oanystream::oanystream(std::ostream& os, "
datrw::util::report_deprecated("oanystream::oanystream(std::ostream& os, "
"const Eformat& format)",
"this constructor does not support format modifiers");
std::string fm(anyID(format));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment