MySQL 8.0.40
Source Code Documentation
file_writer.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2015, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program 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
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef FILE_WRITER_INCLUDED
27#define FILE_WRITER_INCLUDED
28
29#include <functional>
30#include <string>
31
34#include "my_inttypes.h"
35
36namespace Mysql {
37namespace Tools {
38namespace Dump {
39
40/**
41 Writes formatted data to specified file.
42 */
44 public:
45 File_writer(std::function<bool(const Mysql::Tools::Base::Message_data &)>
46 *message_handler,
47 Simple_id_generator *object_id_generator,
48 const std::string &file_name);
49 bool init() override;
50 ~File_writer() override;
51
52 void append(const std::string &data_to_append) override;
53
54 // Fix "inherits ... via dominance" warnings
56 I_progress_watcher *new_progress_watcher) override {
58 }
59
60 // Fix "inherits ... via dominance" warnings
61 uint64 get_id() const override { return Abstract_chain_element::get_id(); }
62
63 protected:
64 // Fix "inherits ... via dominance" warnings
66 Item_processing_data *item_processed) override {
68 }
69
70 private:
72 const std::string m_file_name;
73};
74
75} // namespace Dump
76} // namespace Tools
77} // namespace Mysql
78
79#endif
Structure to represent message from server sent after executing query.
Definition: message_data.h:49
Definition: abstract_chain_element.h:45
void register_progress_watcher(I_progress_watcher *new_progress_watcher) override
Add new Progress Watcher to report to.
Definition: abstract_chain_element.h:58
uint64 get_id() const override
Returns an application unique ID of this chain element object.
Definition: abstract_chain_element.cc:36
void item_completion_in_child_callback(Item_processing_data *item_processed) override
This callback can be requested to be called by child for any object processing.
Definition: abstract_chain_element.cc:150
Writes formatted data to specified file.
Definition: file_writer.h:43
File_writer(std::function< bool(const Mysql::Tools::Base::Message_data &)> *message_handler, Simple_id_generator *object_id_generator, const std::string &file_name)
Definition: file_writer.cc:51
void item_completion_in_child_callback(Item_processing_data *item_processed) override
This callback can be requested to be called by child for any object processing.
Definition: file_writer.h:65
const std::string m_file_name
Definition: file_writer.h:72
void register_progress_watcher(I_progress_watcher *new_progress_watcher) override
Add new Progress Watcher to report to.
Definition: file_writer.h:55
FILE * m_file
Definition: file_writer.h:71
uint64 get_id() const override
Returns an application unique ID of this chain element object.
Definition: file_writer.h:61
void append(const std::string &data_to_append) override
Adds new block of data atomically to output.
Definition: file_writer.cc:32
~File_writer() override
Definition: file_writer.cc:42
bool init() override
Initialize writer.
Definition: file_writer.cc:59
Definition: i_output_writer.h:37
Definition: i_progress_watcher.h:37
Data structure for objects that are processed in any chain.
Definition: item_processing_data.h:43
Definition: simple_id_generator.h:37
Some integer typedefs for easier portability.
uint64_t uint64
Definition: my_inttypes.h:69
Definition: abstract_connection_program.h:38
const std::string FILE("FILE")
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:94