Audacity 3.2.0
ProjectSerializer.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4 Audacity(R) is copyright (c) 1999-2010 Audacity Team.
5 License: GPL v2 or later. See License.txt.
6
7 ProjectSerializer.h
8
9*******************************************************************/
10
11#ifndef __AUDACITY_PROJECTSERIALIZER__
12#define __AUDACITY_PROJECTSERIALIZER__
13
14#include "XMLTagHandler.h"
15
16#include "MemoryStream.h" // member variables
17#include <wx/mstream.h>
18
19#include <unordered_set>
20#include <unordered_map>
21
22#include "Identifier.h"
23
24// From SampleBlock.h
25using SampleBlockID = long long;
26
31
32using NameMap = std::unordered_map<wxString, unsigned short>;
33using IdMap = std::unordered_map<unsigned short, std::string>;
34
35// This class's overrides do NOT throw AudacityException.
36class PROJECT_FILE_IO_API ProjectSerializer final : public XMLWriter
37{
38public:
39
40 static TranslatableString FailureMessage( const FilePath &filePath );
41
42 ProjectSerializer(size_t allocSize = 1024 * 1024);
43 virtual ~ProjectSerializer();
44
45 void StartTag(const wxString & name) override;
46 void EndTag(const wxString & name) override;
47
48 void WriteAttr(const wxString & name, const wxString &value) override;
49 void WriteAttr(const wxString & name, const wxChar *value) override;
50
51 void WriteAttr(const wxString & name, int value) override;
52 void WriteAttr(const wxString & name, bool value) override;
53 void WriteAttr(const wxString & name, long value) override;
54 void WriteAttr(const wxString & name, long long value) override;
55 void WriteAttr(const wxString & name, size_t value) override;
56 void WriteAttr(const wxString & name, float value, int digits = -1) override;
57 void WriteAttr(const wxString & name, double value, int digits = -1) override;
58
59 void WriteData(const wxString & value) override;
60 void Write(const wxString & data) override;
61
62 const MemoryStream& GetDict() const;
63 const MemoryStream& GetData() const;
64
65 bool IsEmpty() const;
66 bool DictChanged() const;
67
68 // Returns empty string if decoding fails
70
71private:
72 void WriteName(const wxString& name);
73
74private:
77
80};
81
82#endif
long long SampleBlockID
Definition: CloudSyncDTO.h:26
wxString FilePath
Definition: Project.h:21
std::unordered_map< unsigned short, std::string > IdMap
std::unordered_map< wxString, unsigned short > NameMap
wxString name
Definition: TagsEditor.cpp:166
A facade-like class, that implements buffered reading from the underlying data stream.
A low overhead memory stream with O(1) append, low heap fragmentation and a linear memory view.
a class used to (de)serialize the project catalog
static MemoryStream mDict
static NameMap mNames
MemoryStream mBuffer
Holds a msgid for the translation catalog; may also bind format arguments.
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:25
virtual void WriteData(const wxString &value)
Definition: XMLWriter.cpp:202
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:79
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:36
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:102
virtual void Write(const wxString &data)=0
STRINGS_API int Decode(const wxString &in, void *out)
Definition: Base64.cpp:67