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
19#pragma once
20
21#include <utility>
22#include <list>
23#include <memory>
24
25#include <QtCore/QString>
26#include <QtCore/QVariantList>
27#include <QtCore/QFile>
28
29#include "cc_tools_qt/ToolsApi.h"
30#include "cc_tools_qt/ToolsMessage.h"
31#include "cc_tools_qt/ToolsProtocol.h"
32
33namespace cc_tools_qt
34{
35
36class CC_TOOLS_API ToolsMsgFileMgr
37{
38public:
39 enum class Type
40 {
41 Recv,
42 Send
43 };
44
45 ToolsMsgFileMgr();
46 ~ToolsMsgFileMgr() noexcept;
47 ToolsMsgFileMgr(const ToolsMsgFileMgr&);
48 ToolsMsgFileMgr(ToolsMsgFileMgr&&);
49
50 ToolsMsgFileMgr& operator=(const ToolsMsgFileMgr&);
51 ToolsMsgFileMgr& operator=(ToolsMsgFileMgr&&);
52
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
71
Main namespace for all classes / functions of the shared library.