forked from Sneeds-Feed-and-Seed/sneedacity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectSerializer.h
82 lines (57 loc) · 2.33 KB
/
ProjectSerializer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**********************************************************************
Sneedacity: A Digital Audio Editor
Sneedacity(R) is copyright (c) 1999-2010 Sneedacity Team.
License: GPL v2. See License.txt.
ProjectSerializer.h
*******************************************************************/
#ifndef __SNEEDACITY_PROJECTSERIALIZER__
#define __SNEEDACITY_PROJECTSERIALIZER__
#include "xml/XMLTagHandler.h"
#include <wx/mstream.h> // member variables
#include <unordered_set>
#include <unordered_map>
#include "Identifier.h"
// From SampleBlock.h
using SampleBlockID = long long;
///
/// ProjectSerializer
///
using NameMap = std::unordered_map<wxString, unsigned short>;
using IdMap = std::unordered_map<unsigned short, wxString>;
// This class's overrides do NOT throw SneedacityException.
class SNEEDACITY_DLL_API ProjectSerializer final : public XMLWriter
{
public:
static TranslatableString FailureMessage( const FilePath &filePath );
ProjectSerializer(size_t allocSize = 1024 * 1024);
virtual ~ProjectSerializer();
void StartTag(const wxString & name) override;
void EndTag(const wxString & name) override;
void WriteAttr(const wxString & name, const wxString &value) override;
void WriteAttr(const wxString & name, const wxChar *value) override;
void WriteAttr(const wxString & name, int value) override;
void WriteAttr(const wxString & name, bool value) override;
void WriteAttr(const wxString & name, long value) override;
void WriteAttr(const wxString & name, long long value) override;
void WriteAttr(const wxString & name, size_t value) override;
void WriteAttr(const wxString & name, float value, int digits = -1) override;
void WriteAttr(const wxString & name, double value, int digits = -1) override;
void WriteData(const wxString & value) override;
void Write(const wxString & data) override;
// Non-override functions
void WriteSubTree(const ProjectSerializer & value);
const wxMemoryBuffer &GetDict() const;
const wxMemoryBuffer &GetData() const;
bool IsEmpty() const;
bool DictChanged() const;
// Returns empty string if decoding fails
static wxString Decode(const wxMemoryBuffer &buffer);
private:
void WriteName(const wxString & name);
private:
wxMemoryBuffer mBuffer;
bool mDictChanged;
static NameMap mNames;
static wxMemoryBuffer mDict;
};
#endif