11#ifndef __AUDACITY_PROJECT_FILE_IO__
12#define __AUDACITY_PROJECT_FILE_IO__
16#include <unordered_set>
26struct sqlite3_context;
38namespace BasicUI{
class WindowPlacement; }
47using BlockIDs = std::unordered_set<SampleBlockID>;
63 ,
public std::enable_shared_from_this<ProjectFileIO>
74 void SetFileName(
const FilePath &fileName);
79 bool mCommitted{
false };
84 static bool InitializeSQL();
100 void SetProjectTitle(
int number = -1);
103 const FilePath &GetFileName()
const;
104 void SetFileName(
const FilePath &fileName );
106 bool IsModified()
const;
107 bool IsTemporary()
const;
108 bool IsRecovered()
const;
110 bool AutoSave(
bool recording =
false);
111 bool AutoSaveDelete(sqlite3 *db =
nullptr);
115 bool ReopenProject();
119 std::optional<TentativeConnection>
120 LoadProject(
const FilePath &fileName,
bool ignoreAutosave);
124 bool SaveCopy(
const FilePath& fileName);
126 wxLongLong GetFreeDiskSpace()
const;
132 int64_t GetCurrentUsage(
133 const std::vector<const TrackList*> &trackLists)
const;
137 int64_t GetTotalUsage();
147 const wxString &helpPage);
150 int GetLastErrorCode()
const;
151 const wxString &GetLastLog()
const;
170 static const std::vector<wxString> &AuxiliaryFileSuffixes();
183 static bool RemoveProject(
const FilePath &filename);
192 bool IsOk() {
return !mPath.empty(); }
203 const std::vector<const TrackList *> &
tracks,
bool force =
false);
213 bool DeleteBlocks(
const BlockIDs &blockids,
bool complement);
217 using ExecCB = std::function<int(
int cols,
char **vals,
char **
names)>;
220 bool HasConnection()
const;
226 wxString GenerateDoc();
229 void OnCheckpointFailure();
231 void WriteXMLHeader(
XMLWriter &xmlFile)
const;
232 void WriteXML(
XMLWriter &xmlFile,
bool recording =
false,
241 int Exec(
const char *query,
const ExecCB &callback,
bool silent =
false);
248 bool OpenConnection(
FilePath fileName = {});
249 bool CloseConnection();
253 void SaveConnection();
256 void DiscardConnection();
259 void RestoreConnection();
264 bool Query(
const char *sql,
const ExecCB &callback,
bool silent =
false);
266 bool GetValue(
const char *sql, wxString &value,
bool silent =
false);
267 bool GetValue(
const char *sql, int64_t &value,
bool silent =
false);
270 bool InstallSchema(sqlite3 *db,
const char *schema =
"main");
273 bool WriteDoc(
const char *table,
const ProjectSerializer &autosave,
const char *schema =
"main");
276 static void InSet(sqlite3_context *context,
int argc, sqlite3_value **
argv);
279 bool CopyTo(
const FilePath &destpath,
283 const std::vector<const TrackList *> &
tracks = {}
299 bool ShouldCompact(
const std::vector<const TrackList *> &
tracks);
302 static unsigned int get2(
const unsigned char *ptr);
303 static unsigned int get4(
const unsigned char *ptr);
304 static int get_varint(
const unsigned char *ptr, int64_t *out);
Utility ClientData::Site to register hooks into a host class that attach client data.
std::unique_ptr< DBConnection > Connection
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
std::unordered_set< SampleBlockID > BlockIDs
ProjectFileIOMessage
Subscribe to ProjectFileIO to receive messages; always in idle time.
@ CheckpointFailure
Failure happened in a worker thread.
@ ProjectTitleChange
A normal occurrence.
std::vector< Attribute > AttributesList
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Subclasses may hold information such as a parent window pointer for a dialog.
Makes a temporary project that doesn't display on the screen.
AudacityProject & Project()
std::shared_ptr< AudacityProject > mpProject
An object that sends messages to an open-ended list of subscribed callbacks.
A listener notified of changes in preferences.
virtual void UpdatePrefs()=0
bool IsOk()
Returns false if the renaming in the constructor failed.
Object associated with a project that manages reading and writing of Audacity project file formats,...
ProjectFileIO & operator=(const ProjectFileIO &)=delete
AudacityProject & mProject
const wxString & GetProjectTitle() const
std::function< int(int cols, char **vals, char **names)> ExecCB
ProjectFileIO(const ProjectFileIO &)=delete
static unsigned int get2(const unsigned char *ptr)
std::shared_ptr< DBConnectionErrors > mpErrors
static int get_varint(const unsigned char *ptr, int64_t *out)
static unsigned int get4(const unsigned char *ptr)
a class used to (de)serialize the project catalog
Implementation of SampleBlock using Sqlite database.
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
This class is an interface which should be implemented by classes which wish to be able to load and s...
virtual XMLTagHandler * HandleXMLChild(const std::string_view &tag)=0
virtual bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs)=0
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.
A convenient default parameter for class template Site.
ProjectFileIO & mProjectFileIO
TentativeConnection(const TentativeConnection &other)=delete