MySQL 8.2.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, 2023, 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 also distributed 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 included with MySQL.
16//
17// This program is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU General Public License, version 2.0, for more details.
21//
22// You should have received a copy of the GNU General Public License
23// along with this program; if not, write to the Free Software
24// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25
26/// @file
27///
28/// This file declares the Warning class.
29
30#include <cstdint>
31#include <string>
32
33/// Class representing a warning.
34///
35/// Contains following information
36/// * A flag representing whether to ignore a warning or not
37/// * A flag representing the scope of a warning
38/// * Warning name
39/// * Warning number
40class Warning {
41 public:
42 Warning(std::uint32_t warning_code, const char *warning_name, bool once) {
43 this->m_ignore_warning = false;
44 this->m_once_property = once;
46 this->m_warning_name.assign(warning_name);
47 }
48
49 /// Check if a warning is disabled/enabled for next statement only.
50 ///
51 /// @retval True if the warning is disabled or enabled for next
52 /// statement only, false otherwise.
53 bool expired() { return m_once_property; }
54
55 /// Return ignore_warning flag value
56 ///
57 /// @retval True if ignore_warning flag is set, false otherwise.
59
60 /// Return a symbolic name representing a warning
61 ///
62 /// @retval Symbolic name for a warning.
63 const char *warning_name() { return m_warning_name.c_str(); }
64
65 /// Return a warning code
66 ///
67 /// @retval Warning code
68 std::uint32_t warning_code() { return m_warning_code; }
69
70 /// Set ignore_warning flag
71 ///
72 /// @param value Boolean value for ignore_warning flag
73 void set_ignore_warning(bool value) { m_ignore_warning = value; }
74
75 private:
78 std::string m_warning_name;
79 std::uint32_t m_warning_code;
80};
81
82#endif // WARNING_INCLUDED
Class representing a warning.
Definition: warning.h:40
std::uint32_t m_warning_code
Definition: warning.h:79
Warning(std::uint32_t warning_code, const char *warning_name, bool once)
Definition: warning.h:42
std::string m_warning_name
Definition: warning.h:78
const char * warning_name()
Return a symbolic name representing a warning.
Definition: warning.h:63
bool m_ignore_warning
Definition: warning.h:76
void set_ignore_warning(bool value)
Set ignore_warning flag.
Definition: warning.h:73
bool expired()
Check if a warning is disabled/enabled for next statement only.
Definition: warning.h:53
std::uint32_t warning_code()
Return a warning code.
Definition: warning.h:68
bool m_once_property
Definition: warning.h:77
bool ignore_warning()
Return ignore_warning flag value.
Definition: warning.h:58