Audacity 3.2.0
|
Wrapper to output XML data to files. More...
#include <XMLWriter.h>
Public Member Functions | |
XMLFileWriter (const FilePath &outputPath, const TranslatableString &caption, bool keepBackup=false) | |
virtual | ~XMLFileWriter () |
void | Commit () |
void | PreCommit () |
Does the part of Commit that might fail because of exhaustion of space. More... | |
void | PostCommit () |
void | Write (const wxString &data) override |
Write to file. Might throw. More... | |
FilePath | GetBackupName () const |
Public Member Functions inherited from XMLWriter | |
XMLWriter () | |
virtual | ~XMLWriter () |
virtual void | StartTag (const wxString &name) |
virtual void | EndTag (const wxString &name) |
void | WriteAttr (const wxString &name, const Identifier &value) |
virtual void | WriteAttr (const wxString &name, const wxString &value) |
virtual void | WriteAttr (const wxString &name, const wxChar *value) |
virtual void | WriteAttr (const wxString &name, int value) |
virtual void | WriteAttr (const wxString &name, bool value) |
virtual void | WriteAttr (const wxString &name, long value) |
virtual void | WriteAttr (const wxString &name, long long value) |
virtual void | WriteAttr (const wxString &name, size_t value) |
virtual void | WriteAttr (const wxString &name, float value, int digits=-1) |
virtual void | WriteAttr (const wxString &name, double value, int digits=-1) |
virtual void | WriteData (const wxString &value) |
virtual void | WriteSubTree (const wxString &value) |
virtual void | Write (const wxString &data)=0 |
Private Member Functions | |
void | ThrowException (const wxFileName &fileName, const TranslatableString &caption) |
void | CloseWithoutEndingTags () |
Private Attributes | |
const FilePath | mOutputPath |
const TranslatableString | mCaption |
FilePath | mBackupName |
const bool | mKeepBackup |
wxFFile | mBackupFile |
bool | mCommitted { false } |
Additional Inherited Members | |
Protected Attributes inherited from XMLWriter | |
bool | mInTag |
int | mDepth |
wxArrayString | mTagstack |
std::vector< int > | mHasKids |
Wrapper to output XML data to files.
XMLFileWriter This writes to a provisional file, and replaces the previously existing contents by a file rename in Commit() only after all writes succeed. The original contents may also be retained at a backup path name, as directed by the optional constructor argument. If it is destroyed before Commit(), then the provisional file is removed. If the construction and all operations are inside a GuardedCall or event handler, then the default delayed handler action in case of exceptions will notify the user of problems.
Definition at line 84 of file XMLWriter.h.
XMLFileWriter::XMLFileWriter | ( | const FilePath & | outputPath, |
const TranslatableString & | caption, | ||
bool | keepBackup = false |
||
) |
The caption is for message boxes to show in case of errors. Might throw.
XMLFileWriter class
Definition at line 297 of file XMLWriter.cpp.
References mBackupFile, mBackupName, mCaption, mKeepBackup, mOutputPath, ThrowException(), and wxT().
|
virtual |
Definition at line 330 of file XMLWriter.cpp.
References CloseWithoutEndingTags(), GuardedCall(), and mCommitted.
|
private |
Close file without automatically ending tags. Might throw.
Definition at line 387 of file XMLWriter.cpp.
References mCaption, and ThrowException().
Referenced by PreCommit(), and ~XMLFileWriter().
void XMLFileWriter::Commit | ( | ) |
Close all tags and then close the file. Might throw. If not, then create or modify the file at the output path. Composed of two steps, PreCommit() and PostCommit()
Definition at line 343 of file XMLWriter.cpp.
References PostCommit(), and PreCommit().
|
inline |
Definition at line 112 of file XMLWriter.h.
void XMLFileWriter::PostCommit | ( | ) |
Does other parts of Commit that are not likely to fail for exhaustion of space, but might for other reasons
Definition at line 360 of file XMLWriter.cpp.
References mBackupFile, mBackupName, mCaption, mCommitted, mKeepBackup, mOutputPath, FileException::Rename, and ThrowException().
Referenced by Commit().
void XMLFileWriter::PreCommit | ( | ) |
Does the part of Commit that might fail because of exhaustion of space.
Definition at line 350 of file XMLWriter.cpp.
References CloseWithoutEndingTags(), XMLWriter::EndTag(), and XMLWriter::mTagstack.
Referenced by Commit().
|
inlineprivate |
Definition at line 116 of file XMLWriter.h.
References FileException::Write.
Referenced by CloseWithoutEndingTags(), PostCommit(), Write(), and XMLFileWriter().
|
overridevirtual |
Write to file. Might throw.
Implements XMLWriter.
Definition at line 403 of file XMLWriter.cpp.
References Error, mCaption, and ThrowException().
|
private |
Definition at line 131 of file XMLWriter.h.
Referenced by PostCommit(), and XMLFileWriter().
|
private |
Definition at line 128 of file XMLWriter.h.
Referenced by PostCommit(), and XMLFileWriter().
|
private |
Definition at line 127 of file XMLWriter.h.
Referenced by CloseWithoutEndingTags(), PostCommit(), Write(), and XMLFileWriter().
|
private |
Definition at line 133 of file XMLWriter.h.
Referenced by PostCommit(), and ~XMLFileWriter().
|
private |
Definition at line 129 of file XMLWriter.h.
Referenced by PostCommit(), and XMLFileWriter().
|
private |
Definition at line 126 of file XMLWriter.h.
Referenced by PostCommit(), and XMLFileWriter().