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