11#ifndef __AUDACITY_PROJECT_FILE_IO__
12#define __AUDACITY_PROJECT_FILE_IO__
15#include <unordered_set>
25struct sqlite3_context;
37namespace BasicUI{
class WindowPlacement; }
46using BlockIDs = std::unordered_set<SampleBlockID>;
62 ,
public std::enable_shared_from_this<ProjectFileIO>
68 static bool InitializeSQL();
84 void SetProjectTitle(
int number = -1);
88 void SetFileName(
const FilePath &fileName );
90 bool IsModified()
const;
91 bool IsTemporary()
const;
92 bool IsRecovered()
const;
94 bool AutoSave(
bool recording =
false);
95 bool AutoSaveDelete(sqlite3 *db =
nullptr);
101 bool LoadProject(
const FilePath &fileName,
bool ignoreAutosave);
102 bool UpdateSaved(
const TrackList *tracks =
nullptr);
104 bool SaveCopy(
const FilePath& fileName);
106 wxLongLong GetFreeDiskSpace()
const;
112 int64_t GetCurrentUsage(
113 const std::vector<const TrackList*> &trackLists)
const;
117 int64_t GetTotalUsage();
127 const wxString &helpPage);
130 int GetLastErrorCode()
const;
131 const wxString &GetLastLog()
const;
150 static const std::vector<wxString> &AuxiliaryFileSuffixes();
163 static bool RemoveProject(
const FilePath &filename);
172 bool IsOk() {
return !mPath.empty(); }
183 const std::vector<const TrackList *> &tracks,
bool force =
false);
193 bool DeleteBlocks(
const BlockIDs &blockids,
bool complement);
197 using ExecCB = std::function<int(
int cols,
char **vals,
char **
names)>;
200 bool HasConnection()
const;
206 wxString GenerateDoc();
209 void OnCheckpointFailure();
211 void WriteXMLHeader(
XMLWriter &xmlFile)
const;
212 void WriteXML(
XMLWriter &xmlFile,
bool recording =
false,
221 int Exec(
const char *query,
const ExecCB &callback,
bool silent =
false);
228 bool OpenConnection(
FilePath fileName = {});
229 bool CloseConnection();
233 void SaveConnection();
236 void DiscardConnection();
239 void RestoreConnection();
244 bool Query(
const char *sql,
const ExecCB &callback,
bool silent =
false);
246 bool GetValue(
const char *sql, wxString &value,
bool silent =
false);
247 bool GetValue(
const char *sql, int64_t &value,
bool silent =
false);
250 bool InstallSchema(sqlite3 *db,
const char *schema =
"main");
253 bool WriteDoc(
const char *table,
const ProjectSerializer &autosave,
const char *schema =
"main");
256 static void InSet(sqlite3_context *context,
int argc, sqlite3_value **
argv);
259 bool CopyTo(
const FilePath &destpath,
263 const std::vector<const TrackList *> &tracks = {}
279 bool ShouldCompact(
const std::vector<const TrackList *> &tracks);
282 static unsigned int get2(
const unsigned char *ptr);
283 static unsigned int get4(
const unsigned char *ptr);
284 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::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< std::shared_ptr< WaveTrack > > WaveTrackArray
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.
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.
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
A convenient default parameter for class template Site.