MySQL 8.0.39
Source Code Documentation
expected_warnings.h
Go to the documentation of this file.
1#ifndef EXPECTED_WARNINGS_INCLUDED
2#define EXPECTED_WARNINGS_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
28
29#include <memory>
30#include <vector>
31
32/// Class representing any one of the following list.
33/// * List of disabled warnings
34/// * List of enabled warnings
36 public:
37 typedef std::vector<std::unique_ptr<Warning>>::iterator iterator;
38
39 Expected_warnings() = default;
40 ~Expected_warnings() = default;
41
42 iterator begin() { return m_warnings.begin(); }
43 iterator end() { return m_warnings.end(); }
44
45 /// Return length of the list containing warnings.
46 ///
47 /// @retval Length value
48 std::size_t count() { return m_warnings.size(); }
49
50 /// Delete all warnings from the vector.
51 void clear_list() { m_warnings.clear(); }
52
53 /// Add a new warning to the existing list of warnings only if it
54 /// doesn't exist.
55 ///
56 /// @param warning_code Warning number
57 /// @param warning_name Warning name
58 /// @param once_property Flag value representing the scope of a warning.
59 void add_warning(std::uint32_t warning_code, const char *warning_name,
60 bool once_property);
61
62 /// Remove a warning from the existing list of warnings if it exists.
63 /// If "ONCE" argument is specified, don't remove the warning, set a
64 /// flag to ignore disabling or enabling of it for the next statement
65 /// only.
66 ///
67 /// @param warning_code Warning number
68 /// @param once_property Flag value representing the scope of a
69 /// disabled warning
70 void remove_warning(std::uint32_t warning_code, bool once_property);
71
72 /// Update the list of disabled or enabled warnings.
73 ///
74 /// * Remove all the warnings which are disabled or enabled only for
75 /// one statement. These warnings are expired after the execution of
76 /// next statement.
77 ///
78 /// * Reset ignore_warning flag value to 0 if it set to 1.
79 void update_list();
80
81 /// Return a list of symbolic names of disabled or enabled warnings.
82 ///
83 /// @retval String containing symbolic names of disabled warnings
84 std::string warnings_list();
85
86 private:
87 // List containing disabled or enabled warnings.
88 std::vector<std::unique_ptr<Warning>> m_warnings;
89};
90
91#endif // EXPECTED_WARNINGS_INCLUDED
Class representing any one of the following list.
Definition: expected_warnings.h:35
std::vector< std::unique_ptr< Warning > > m_warnings
Definition: expected_warnings.h:88
void update_list()
Update the list of disabled or enabled warnings.
Definition: expected_warnings.cc:52
void add_warning(std::uint32_t warning_code, const char *warning_name, bool once_property)
Add a new warning to the existing list of warnings only if it doesn't exist.
Definition: expected_warnings.cc:26
~Expected_warnings()=default
iterator end()
Definition: expected_warnings.h:43
void clear_list()
Delete all warnings from the vector.
Definition: expected_warnings.h:51
Expected_warnings()=default
void remove_warning(std::uint32_t warning_code, bool once_property)
Remove a warning from the existing list of warnings if it exists.
Definition: expected_warnings.cc:40
std::vector< std::unique_ptr< Warning > >::iterator iterator
Definition: expected_warnings.h:37
iterator begin()
Definition: expected_warnings.h:42
std::string warnings_list()
Return a list of symbolic names of disabled or enabled warnings.
Definition: expected_warnings.cc:63
std::size_t count()
Return length of the list containing warnings.
Definition: expected_warnings.h:48
static bool once_property
Definition: mysqltest.cc:290
This file declares the Warning class.