cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
MsgFileMgr.h
1//
2// Copyright 2015 - 2024 (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 "Api.h"
30#include "Message.h"
31#include "Protocol.h"
32
33namespace cc_tools_qt
34{
35
36class CC_API MsgFileMgr
37{
38public:
39
40 typedef Protocol::MessagesList MessagesList;
41
42 enum class Type
43 {
44 Recv,
45 Send
46 };
47
48 MsgFileMgr();
49 ~MsgFileMgr() noexcept;
50 MsgFileMgr(const MsgFileMgr&);
51 MsgFileMgr(MsgFileMgr&&);
52
53 MsgFileMgr& operator=(const MsgFileMgr&);
54 MsgFileMgr& operator=(MsgFileMgr&&);
55
56
57 const QString& getLastFile() const;
58 static const QString& getFilesFilter();
59
60 MessagesList load(Type type, const QString& filename, Protocol& protocol);
61 bool save(Type type, const QString& filename, const MessagesList& msgs);
62
63 typedef std::shared_ptr<QFile> FileSaveHandler;
64 static FileSaveHandler startRecvSave(const QString& filename);
65 static void addToRecvSave(FileSaveHandler handler, const Message& msg, bool flush = false);
66 static void flushRecvFile(FileSaveHandler handler);
67
68private:
69 QString m_lastFile;
70};
71
72} // namespace cc_tools_qt
73
74
Main namespace for all classes / functions of the shared library.