Apply clang-tidy-8 readability-uppercase-literal-suffix
[gromacs.git] / src / gromacs / fileio / warninp.h
blob57949b440aa31d59f43a72fe433c7e2037d03f2b
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2010,2014,2015,2016,2017,2018, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
37 #ifndef GMX_FILEIO_WARNINP_H
38 #define GMX_FILEIO_WARNINP_H
40 #include <string>
42 #include "gromacs/utility/basedefinitions.h"
44 /* Abstract type for warning bookkeeping */
45 typedef struct warninp *warninp_t;
48 warninp_t
49 init_warning(gmx_bool bAllowWarnings, int maxwarning);
50 /* Initialize the warning data structure.
51 * If bAllowWarnings=FALSE, all warnings (calls to warning()) will be
52 * transformed into errors, calls to warning_note still produce notes.
53 * maxwarning determines the maximum number of warnings that are allowed
54 * for proceeding. When this number is exceeded check_warning_error
55 * and done_warning will generate a fatal error.
56 * bAllowWarnings=TRUE should only be used by programs that have
57 * a -maxwarn command line option.
60 void
61 set_warning_line(warninp_t wi, const char *fn, int line);
62 /* Set filename and linenumber for the warning */
64 int
65 get_warning_line(warninp_t wi);
66 /* Get linenumber for the warning */
69 const char *
70 get_warning_file(warninp_t wi);
71 /* Get filename for the warning */
73 void
74 warning(warninp_t wi, const char *s);
75 /* Issue a warning, with the string s. If s == NULL, then warn_buf
76 * will be printed instead. The file and line set by set_warning_line
77 * are printed, nwarn_warn (local) is incremented.
78 * A fatal error will be generated after processing the input
79 * when nwarn_warn is larger than maxwarning passed to init_warning.
80 * So warning should only be called for issues that should be resolved,
81 * otherwise warning_note should be called.
83 //! Convenience wrapper.
84 void
85 warning(warninp_t wi, const std::string &s);
87 void
88 warning_note(warninp_t wi, const char *s);
89 /* Issue a note, with the string s. If s == NULL, then warn_buf
90 * will be printed instead. The file and line set by set_warning_line
91 * are printed, nwarn_note (local) is incremented.
92 * This is for issues which could be a problem for some systems,
93 * but 100% ok for other systems.
96 //! Convenience wrapper.
97 void
98 warning_note(warninp_t wi, const std::string &s);
100 void
101 warning_error(warninp_t wi, const char *s);
102 /* Issue an error, with the string s. If s == NULL, then warn_buf
103 * will be printed instead. The file and line set by set_warning_line
104 * are printed, nwarn_error (local) is incremented.
107 //! Convenience wrapper.
108 void
109 warning_error(warninp_t wi, const std::string &s);
111 /*! \brief Issue an error with warning_error() and prevent further
112 * processing by calling check_warning_error().
114 * This is intended for use where there is no way to produce a data
115 * structure that would prevent execution from segfaulting. */
116 [[noreturn]] void warning_error_and_exit(warninp_t wi, const char *s, int f_errno, const char *file, int line);
117 //! \copydoc warning_error_and_exit(warninp_t, const char *, int, const char *, int);
118 [[noreturn]] void warning_error_and_exit(warninp_t wi, const std::string &s, int f_errno, const char *file, int line);
120 gmx_bool warning_errors_exist(warninp_t wi);
121 /* Return whether any error-level warnings were issued to wi. */
123 //! Resets the count for all kinds of warnings to zero.
124 void warning_reset(warninp_t wi);
126 void
127 check_warning_error(warninp_t wi, int f_errno, const char *file, int line);
128 /* When warning_error has been called at least once gmx_fatal is called,
129 * otherwise does nothing.
132 void
133 done_warning(warninp_t wi, int f_errno, const char *file, int line);
134 /* Should be called when finished processing the input file.
135 * Prints the number of notes and warnings
136 * and generates a fatal error when errors were found or too many
137 * warnings were generatesd.
138 * Frees the data structure pointed to by wi.
141 void
142 free_warning(warninp_t wi);
143 /* Frees the data structure pointed to by wi. */
145 void
146 _too_few(warninp_t wi, const char *fn, int line);
147 #define too_few(wi) _too_few(wi, __FILE__, __LINE__)
148 /* Issue a warning stating 'Too few parameters' */
150 void
151 _incorrect_n_param(warninp_t wi, const char *fn, int line);
152 #define incorrect_n_param(wi) _incorrect_n_param(wi, __FILE__, __LINE__)
153 /* Issue a warning stating 'Incorrect number of parameters' */
155 #endif