From b2f9dc79924d89d31594f9ffbb28b65e98b86874 Mon Sep 17 00:00:00 2001 From: Andre Pany Date: Sun, 3 Mar 2024 21:11:08 +0100 Subject: [PATCH] Add toolkit functions to c_wrapper --- tools/c_wrapper.cpp | 101 +++++++++++++++++++++++++++++++++++++++++++- tools/c_wrapper.h | 20 ++++++++- 2 files changed, 119 insertions(+), 2 deletions(-) diff --git a/tools/c_wrapper.cpp b/tools/c_wrapper.cpp index a4023388046..10e32fd86b2 100644 --- a/tools/c_wrapper.cpp +++ b/tools/c_wrapper.cpp @@ -115,6 +115,19 @@ const char *vrvToolkit_getHumdrum(void *tkPtr) return buffer; } +bool vrvToolkit_getHumdrumFile(void *tkPtr, const char *filename) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->GetHumdrumFile(filename); +} + +const char *vrvToolkit_getID(void *tkPtr) +{ + Toolkit *tk = static_cast(tkPtr); + tk->SetCString(tk->GetID()); + return tk->GetCString(); +} + const char *vrvToolkit_convertHumdrumToHumdrum(void *tkPtr, const char *humdrumData) { Toolkit *tk = static_cast(tkPtr); @@ -192,6 +205,19 @@ int vrvToolkit_getPageWithElement(void *tkPtr, const char *xmlId) return tk->GetPageWithElement(xmlId); } +const char *vrvToolkit_getResourcePath(void *tkPtr) +{ + Toolkit *tk = static_cast(tkPtr); + tk->SetCString(tk->GetResourcePath()); + return tk->GetCString(); +} + +int vrvToolkit_getScale(void *tkPtr) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->GetScale(); +} + double vrvToolkit_getTimeForElement(void *tkPtr, const char *xmlId) { Toolkit *tk = static_cast(tkPtr); @@ -218,6 +244,12 @@ bool vrvToolkit_loadData(void *tkPtr, const char *data) return tk->LoadData(data); } +bool vrvToolkit_loadFile(void *tkPtr, const char *filename) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->LoadFile(filename); +} + bool vrvToolkit_loadZipDataBase64(void *tkPtr, const char *data) { Toolkit *tk = static_cast(tkPtr); @@ -256,13 +288,25 @@ const char *vrvToolkit_renderToExpansionMap(void *tkPtr) return tk->GetCString(); } -const char *vrvToolkit_renderToMIDI(void *tkPtr, const char *c_options) +bool vrvToolkit_renderToExpansionMapFile(void *tkPtr, const char *filename) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->RenderToExpansionMapFile(filename); +} + +const char *vrvToolkit_renderToMIDI(void *tkPtr) { Toolkit *tk = static_cast(tkPtr); tk->SetCString(tk->RenderToMIDI()); return tk->GetCString(); } +bool vrvToolkit_renderToMIDIFile(void *tkPtr, const char *filename) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->RenderToMIDIFile(filename); +} + const char *vrvToolkit_renderToPAE(void *tkPtr) { Toolkit *tk = static_cast(tkPtr); @@ -270,6 +314,12 @@ const char *vrvToolkit_renderToPAE(void *tkPtr) return tk->GetCString(); } +bool vrvToolkit_renderToPAEFile(void *tkPtr, const char *filename) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->RenderToPAEFile(filename); +} + const char *vrvToolkit_renderToSVG(void *tkPtr, int page_no, bool xmlDeclaration) { Toolkit *tk = static_cast(tkPtr); @@ -277,6 +327,12 @@ const char *vrvToolkit_renderToSVG(void *tkPtr, int page_no, bool xmlDeclaration return tk->GetCString(); } +bool vrvToolkit_renderToSVGFile(void *tkPtr, const char *filename, int pageNo) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->RenderToSVGFile(filename, pageNo); +} + const char *vrvToolkit_renderToTimemap(void *tkPtr, const char *c_options) { Toolkit *tk = static_cast(tkPtr); @@ -284,6 +340,12 @@ const char *vrvToolkit_renderToTimemap(void *tkPtr, const char *c_options) return tk->GetCString(); } +bool vrvToolkit_renderToTimemapFile(void *tkPtr, const char *filename, const char *c_options) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->RenderToTimemapFile(filename, c_options); +} + void vrvToolkit_resetOptions(void *tkPtr) { Toolkit *tk = static_cast(tkPtr); @@ -296,18 +358,48 @@ void vrvToolkit_resetXmlIdSeed(void *tkPtr, int seed) tk->ResetXmlIdSeed(seed); } +bool vrvToolkit_saveFile(void *tkPtr, const char *filename, const char *c_options) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->SaveFile(filename, c_options); +} + bool vrvToolkit_select(void *tkPtr, const char *selection) { Toolkit *tk = static_cast(tkPtr); return tk->Select(selection); } +bool vrvToolkit_setInputFrom(void *tkPtr, const char *inputFrom) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->SetInputFrom(inputFrom); +} + bool vrvToolkit_setOptions(void *tkPtr, const char *options) { Toolkit *tk = static_cast(tkPtr); return tk->SetOptions(options); } +bool vrvToolkit_setOutputTo(void *tkPtr, const char *outputTo) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->SetOutputTo(outputTo); +} + +bool vrvToolkit_setResourcePath(void *tkPtr, const char *path) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->SetResourcePath(path); +} + +bool vrvToolkit_setScale(void *tkPtr, int scale) +{ + Toolkit *tk = static_cast(tkPtr); + return tk->SetScale(scale); +} + const char *vrvToolkit_validatePAE(void *tkPtr, const char *data) { Toolkit *tk = static_cast(tkPtr); @@ -315,4 +407,11 @@ const char *vrvToolkit_validatePAE(void *tkPtr, const char *data) return tk->GetCString(); } +const char *vrvToolkit_validatePAEFile(void *tkPtr, const char *filename) +{ + Toolkit *tk = static_cast(tkPtr); + tk->SetCString(tk->ValidatePAEFile(filename)); + return tk->GetCString(); +} + } // extern C diff --git a/tools/c_wrapper.h b/tools/c_wrapper.h index 21ef1b7db7b..9b221a59828 100644 --- a/tools/c_wrapper.h +++ b/tools/c_wrapper.h @@ -21,6 +21,7 @@ void *vrvToolkit_constructorResourcePath(const char *resourcePath); void vrvToolkit_destructor(void *tkPtr); bool vrvToolkit_edit(void *tkPtr, const char *editorAction); +const char *vrvToolkit_editInfo(void *tkPtr); const char *vrvToolkit_getAvailableOptions(void *tkPtr); const char *vrvToolkit_getDefaultOptions(void *tkPtr); const char *vrvToolkit_getDescriptiveFeatures(void *tkPtr, const char *options); @@ -28,6 +29,8 @@ const char *vrvToolkit_getElementAttr(void *tkPtr, const char *xmlId); const char *vrvToolkit_getElementsAtTime(void *tkPtr, int millisec); const char *vrvToolkit_getExpansionIdsForElement(void *tkPtr, const char *xmlId); const char *vrvToolkit_getHumdrum(void *tkPtr); +bool vrvToolkit_getHumdrumFile(void *tkPtr, const char *filename); +const char *vrvToolkit_getID(void *tkPtr); const char *vrvToolkit_convertHumdrumToHumdrum(void *tkPtr, const char *humdrumData); const char *vrvToolkit_convertHumdrumToMIDI(void *tkPtr, const char *humdrumData); const char *vrvToolkit_convertMEIToHumdrum(void *tkPtr, const char *meiData); @@ -39,24 +42,39 @@ const char *vrvToolkit_getOptions(void *tkPtr); const char *vrvToolkit_getOptionUsageString(void *tkPtr); int vrvToolkit_getPageCount(void *tkPtr); int vrvToolkit_getPageWithElement(void *tkPtr, const char *xmlId); +const char *vrvToolkit_getResourcePath(void *tkPtr); +int vrvToolkit_getScale(void *tkPtr); double vrvToolkit_getTimeForElement(void *tkPtr, const char *xmlId); +const char *vrvToolkit_getTimesForElement(void *tkPtr, const char *xmlId); const char *vrvToolkit_getVersion(void *tkPtr); bool vrvToolkit_loadData(void *tkPtr, const char *data); +bool vrvToolkit_loadFile(void *tkPtr, const char *filename); bool vrvToolkit_loadZipDataBase64(void *tkPtr, const char *data); bool vrvToolkit_loadZipDataBuffer(void *tkPtr, const unsigned char *data, int length); void vrvToolkit_redoLayout(void *tkPtr, const char *c_options); void vrvToolkit_redoPagePitchPosLayout(void *tkPtr); const char *vrvToolkit_renderData(void *tkPtr, const char *data, const char *options); const char *vrvToolkit_renderToExpansionMap(void *tkPtr); -const char *vrvToolkit_renderToMIDI(void *tkPtr, const char *c_options); +bool vrvToolkit_renderToExpansionMapFile(void *tkPtr, const char *filename); +const char *vrvToolkit_renderToMIDI(void *tkPtr); +bool vrvToolkit_renderToMIDIFile(void *tkPtr, const char *filename); const char *vrvToolkit_renderToPAE(void *tkPtr); +bool vrvToolkit_renderToPAEFile(void *tkPtr, const char *filename); const char *vrvToolkit_renderToSVG(void *tkPtr, int page_no, bool xmlDeclaration); +bool vrvToolkit_renderToSVGFile(void *tkPtr, const char *filename, int pageNo); const char *vrvToolkit_renderToTimemap(void *tkPtr, const char *c_options); +bool vrvToolkit_renderToTimemapFile(void *tkPtr, const char *filename, const char *c_options); void vrvToolkit_resetOptions(void *tkPtr); void vrvToolkit_resetXmlIdSeed(void *tkPtr, int seed); +bool vrvToolkit_saveFile(void *tkPtr, const char *filename, const char *c_options); bool vrvToolkit_select(void *tkPtr, const char *selection); +bool vrvToolkit_setInputFrom(void *tkPtr, const char *inputFrom); bool vrvToolkit_setOptions(void *tkPtr, const char *options); +bool vrvToolkit_setOutputTo(void *tkPtr, const char *outputTo); +bool vrvToolkit_setResourcePath(void *tkPtr, const char *path); +bool vrvToolkit_setScale(void *tkPtr, int scale); const char *vrvToolkit_validatePAE(void *tkPtr, const char *data); +const char *vrvToolkit_validatePAEFile(void *tkPtr, const char *filename); #ifdef __cplusplus } // extern C