MySQL 9.0.0
Source Code Documentation
warning.h
Go to the documentation of this file.
1#ifndef WARNING_INCLUDED
2#define WARNING_INCLUDED
3
4// Copyright (c) 2018, 2024, Oracle and/or its affiliates.
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License, version 2.0,
8// as published by the Free Software Foundation.
9//
10// This program is designed to work with certain software (including
11// but not limited to OpenSSL) that is licensed under separate terms,
12// as designated in a particular file or component or in included license
13// documentation. The authors of MySQL hereby grant you an additional
14// permission to link the program and your derivative works with the
15// separately licensed software that they have either included with
16// the program or referenced in the documentation.
17//
18// This program is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU General Public License, version 2.0, for more details.
22//
23// You should have received a copy of the GNU General Public License
24// along with this program; if not, write to the Free Software
25// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26
27/// @file
28///
29/// This file declares the Warning class.
30
31#include <cstdint>
32#include <string>
33
34/// Class representing a warning.
35///
36/// Contains following information
37/// * A flag representing whether to ignore a warning or not
38/// * A flag representing the scope of a warning
39/// * Warning name
40/// * Warning number
41class Warning {
42 public:
43 Warning(std::uint32_t warning_code, const char *warning_name, bool once) {
44 this->m_ignore_warning = false;
45 this->m_once_property = once;
47 this->m_warning_name.assign(warning_name);
48 }
49
50 /// Check if a warning is disabled/enabled for next statement only.
51 ///
52 /// @retval True if the warning is disabled or enabled for next
53 /// statement only, false otherwise.
54 bool expired() { return m_once_property; }
55
56 /// Return ignore_warning flag value
57 ///
58 /// @retval True if ignore_warning flag is set, false otherwise.
60
61 /// Return a symbolic name representing a warning
62 ///
63 /// @retval Symbolic name for a warning.
64 const char *warning_name() { return m_warning_name.c_str(); }
65
66 /// Return a warning code
67 ///
68 /// @retval Warning code
69 std::uint32_t warning_code() { return m_warning_code; }
70
71 /// Set ignore_warning flag
72 ///
73 /// @param value Boolean value for ignore_warning flag
74 void set_ignore_warning(bool value) { m_ignore_warning = value; }
75
76 private:
79 std::string m_warning_name;
80 std::uint32_t m_warning_code;
81};
82
83#endif // WARNING_INCLUDED
Class representing a warning.
Definition: warning.h:41
std::uint32_t m_warning_code
Definition: warning.h:80
Warning(std::uint32_t warning_code, const char *warning_name, bool once)
Definition: warning.h:43
std::string m_warning_name
Definition: warning.h:79
const char * warning_name()
Return a symbolic name representing a warning.
Definition: warning.h:64
bool m_ignore_warning
Definition: warning.h:77
void set_ignore_warning(bool value)
Set ignore_warning flag.
Definition: warning.h:74
bool expired()
Check if a warning is disabled/enabled for next statement only.
Definition: warning.h:54
std::uint32_t warning_code()
Return a warning code.
Definition: warning.h:69
bool m_once_property
Definition: warning.h:78
bool ignore_warning()
Return ignore_warning flag value.
Definition: warning.h:59