I was able to hack at it and get something that works for me. I wrote a small ProjectSerializerDecode test harness that takes in the binary xml stored in the sqlite3/aup3 files, then decode it and print out the string in ascii.
#include <FileNames.h>
#include <ProjectSerializer.h>
#include <xml/XMLFileReader.h>
#include <cstring>
#include <iostream>
#include <stdexcept>
TranslatableString AudacityMessageBoxCaptionStr() { }
void ShowErrorDialog( wxWindow * parent,
const TranslatableString & dlogTitle,
const TranslatableString & message,
const wxString & helpPage,
bool close,
const wxString & log ) { }
void ShowExceptionDialog( wxWindow * parent,
const TranslatableString & dlogTitle,
const TranslatableString & message,
const wxString & helpPage,
bool close,
const wxString & log ) { }
wxString TranslatableString::DoGetContext( const Formatter & formatter ) { }
wxString TranslatableString::DoSubstitute( const Formatter & formatter,
const wxString & format,
const wxString & context,
bool debug ) { }
wxString FileNames::AbbreviatePath( const wxFileName & fileName ) { return {}; }
int main()
{
const std::size_t INIT_BUFFER_SIZE = 1024;
try
{
std::freopen( nullptr, "rb", stdin );
if( std::ferror( stdin ) )
{
throw std::runtime_error( std::strerror( errno ) );
}
std::size_t len;
std::array< char, INIT_BUFFER_SIZE > buf;
wxMemoryBuffer input;
while( (len = std::fread( buf.data(), sizeof( buf[0] ), buf.size(), stdin) ) > 0 )
{
if( std::ferror( stdin ) && !std::feof( stdin ) )
{
throw std::runtime_error( std::strerror( errno ) );
}
input.AppendData( &buf.front(), len );
}
wxString project = ProjectSerializer::Decode( input );
std::cout << project;
}
catch( std::exception const & e )
{
std::cerr << e.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
set( TARGET ProjectSerializerDecode )
set( TARGET_ROOT ${topdir}/ProjectSerializerDecode )
message( STATUS "========= Configuraing ${TARGET} =========" )
def_vars()
add_executable( ${TARGET}
${topdir}/libraries/lib-strings/Internat.cpp
${topdir}/src/AudacityException.cpp
${topdir}/src/FileException.cpp
${topdir}/src/ProjectSerializer.cpp
${topdir}/src/xml/XMLWriter.cpp
ProjectSerializerDecode.cpp )
target_include_directories( ${TARGET} PRIVATE
${topdir}/src
${topdir}/libraries/lib-strings/
${topdir}/include
${topdir}/libraries/lib-utility/ )
target_compile_definitions( ${TARGET} PUBLIC STRINGS_API= AUDACITY_DLL_API= )
target_link_libraries( ${TARGET} PUBLIC wxwidgets::wxwidgets )
target_compile_options( ${TARGET} PRIVATE -DPROHIBITED==delete )
djshaw@culsu:~/svn/misc/wizardsInWinter$ diff audacity-Audacity-3.0.5/CMakeLists.txt djshaw-Audacity-3.0.5/CMakeLists.txt
522a523
> add_subdirectory( "ProjectSerializerDecode" )
I can compile with
$ mkdir -p build && cd build && cmake -G "Unix Makefiles" -Daudacity_use_ffmpeg=loaded .. && make ProjectSerializerDecode
And I run with:
$ sqlite3 music/QuincyJones-CominHomeBaby.aup3 "SELECT HEX( dict ) || HEX( doc ) FROM project WHERE id = 1 LIMIT 1;" | xxd -p -r | ./ProjectSerializerDecode
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
<project xmlns="http://audacity.sourceforge.net/xml/" version="1.3.0" audacityversion="3.0.5" sel0="84.7168713477" sel1="84.7168713477" selLow="1309.4169921875" selHigh="1309.4169921875" vpos="0" h="120.0388672121" zoom="26.8246450069" rate="44100.0" snapto="off" selectionformat="hh:mm:ss + milliseconds" frequencyformat="seconds" bandwidthformat="seconds">
<tags>
...
I’ll be piping the output of ProjectSerializerDecode into further programs for analysis.
Any feedback and criticisms on the code and CMake changes are welcome.