cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ToolsMsgFileMgr.h
1//
2// Copyright 2015 - 2026 (C). Alex Robenko. All rights reserved.
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6
7// This file is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20#pragma once
21
22#include <utility>
23#include <list>
24#include <memory>
25
26#include <QtCore/QString>
27#include <QtCore/QVariantList>
28#include <QtCore/QFile>
29
30#include "cc_tools_qt/ToolsApi.h"
31#include "cc_tools_qt/ToolsMessage.h"
32#include "cc_tools_qt/ToolsProtocol.h"
33
34namespace cc_tools_qt
35{
36
37class CC_TOOLS_API ToolsMsgFileMgr
38{
39public:
40 enum class Type
41 {
42 Recv,
43 Send
44 };
45
46 ToolsMsgFileMgr();
47 ~ToolsMsgFileMgr() noexcept;
48 ToolsMsgFileMgr(const ToolsMsgFileMgr&);
49 ToolsMsgFileMgr(ToolsMsgFileMgr&&);
50
51 ToolsMsgFileMgr& operator=(const ToolsMsgFileMgr&);
52 ToolsMsgFileMgr& operator=(ToolsMsgFileMgr&&);
53
54 const QString& getLastFile() const;
55 static const QString& getFilesFilter();
56
57 ToolsMessagesList load(Type type, const QString& filename, ToolsProtocol& protocol);
58 bool save(Type type, const QString& filename, const ToolsMessagesList& msgs);
59
60 using FileSaveHandler = std::shared_ptr<QFile>;
61 static FileSaveHandler startRecvSave(const QString& filename);
62 static void addToRecvSave(FileSaveHandler handler, const ToolsMessage& msg, bool flush = false);
63 static void flushRecvFile(FileSaveHandler handler);
64
65private:
66 QString m_lastFile;
67};
68
69} // namespace cc_tools_qt
70
Main namespace for all classes / functions of the shared library.