Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EQCurveWriter Class Reference

Serializer of curves into XML files. More...

#include <EqualizationCurves.h>

Collaboration diagram for EQCurveWriter:
[legend]

Public Member Functions

 EQCurveWriter (const EQCurveArray &curves)
 
void SaveCurves (const wxString &fileName={})
 

Private Member Functions

void WriteXML (XMLWriter &xmlFile) const
 

Private Attributes

const EQCurveArraymCurves
 

Detailed Description

Serializer of curves into XML files.

Definition at line 63 of file EqualizationCurves.h.

Constructor & Destructor Documentation

◆ EQCurveWriter()

EQCurveWriter::EQCurveWriter ( const EQCurveArray curves)
inlineexplicit

Definition at line 65 of file EqualizationCurves.h.

65: mCurves{ curves } {}
const EQCurveArray & mCurves

Member Function Documentation

◆ SaveCurves()

void EQCurveWriter::SaveCurves ( const wxString &  fileName = {})

Definition at line 295 of file EqualizationCurves.cpp.

296{
297 wxFileName fn;
298 if( fileName.empty() )
299 {
300 // Construct default curve filename
301 //
302 // LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict
303 // between wxStandardPaths and wxConfig under Linux. The latter
304 // creates a normal file as "$HOME/.audacity", while the former
305 // expects the ".audacity" portion to be a directory.
306 fn = wxFileName( FileNames::DataDir(), wxT("EQCurves.xml") );
307
308 // If the directory doesn't exist...
309 if( !fn.DirExists() )
310 {
311 // Attempt to create it
312 if( !fn.Mkdir( fn.GetPath(), 511, wxPATH_MKDIR_FULL ) )
313 {
314 // MkDir() will emit message
315 return;
316 }
317 }
318 }
319 else
320 fn = fileName;
321
322 GuardedCall( [&] {
323 // Create/Open the file
324 const wxString fullPath{ fn.GetFullPath() };
325 XMLFileWriter eqFile{ fullPath, XO("Error Saving Equalization Curves") };
326
327 // Write the curves
328 WriteXML( eqFile );
329
330 eqFile.Commit();
331 } );
332}
wxT("CloseDown"))
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), F3 delayedHandler=DefaultDelayedHandlerAction) noexcept(noexcept(handler(std::declval< AudacityException * >())) &&noexcept(handler(nullptr)) &&noexcept(std::function< void(AudacityException *)>{std::move(delayedHandler)}))
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
XO("Cut/Copy/Paste")
static const auto fn
void WriteXML(XMLWriter &xmlFile) const
Wrapper to output XML data to files.
Definition: XMLWriter.h:84
FILES_API FilePath DataDir()
Audacity user data directory.

References FileNames::DataDir(), fn, GuardedCall(), WriteXML(), wxT(), and XO().

Referenced by EqualizationCurvesDialog::OnExport(), and EqualizationUI::ValidateUI().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteXML()

void EQCurveWriter::WriteXML ( XMLWriter xmlFile) const
private

Definition at line 455 of file EqualizationCurves.cpp.

457{
458 // Start our hierarchy
459 xmlFile.StartTag( wxT( "equalizationeffect" ) );
460
461 // Write all curves
462 int numCurves = mCurves.size();
463 int curve;
464 for( curve = 0; curve < numCurves; curve++ )
465 {
466 // Start a NEW curve
467 xmlFile.StartTag( wxT( "curve" ) );
468 xmlFile.WriteAttr( wxT( "name" ), mCurves[ curve ].Name );
469
470 // Write all points
471 int numPoints = mCurves[ curve ].points.size();
472 int point;
473 for( point = 0; point < numPoints; point++ )
474 {
475 // Write NEW point
476 xmlFile.StartTag( wxT( "point" ) );
477 xmlFile.WriteAttr( wxT( "f" ), mCurves[ curve ].points[ point ].Freq, 12 );
478 xmlFile.WriteAttr( wxT( "d" ), mCurves[ curve ].points[ point ].dB, 12 );
479 xmlFile.EndTag( wxT( "point" ) );
480 }
481
482 // Terminate curve
483 xmlFile.EndTag( wxT( "curve" ) );
484 }
485
486 // Terminate our hierarchy
487 xmlFile.EndTag( wxT( "equalizationeffect" ) );
488}
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

References wxT().

Referenced by SaveCurves().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mCurves

const EQCurveArray& EQCurveWriter::mCurves
private

Definition at line 70 of file EqualizationCurves.h.


The documentation for this class was generated from the following files: