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