Implement gnc:generate-restore-forms, gnc-optiondb-save-to-scheme.

This commit is contained in:
John Ralls
2021-07-13 12:44:13 -07:00
parent c34986dad4
commit a1af86ed40
2 changed files with 19 additions and 1 deletions

View File

@@ -514,6 +514,7 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
#include <algorithm>
#include <array>
#include <string>
#include <sstream>
#include "gnc-option.hpp"
#include "gnc-option-ui.hpp"
@@ -530,7 +531,12 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
* overloads. The latter isn't useful to SWIG, ignore it.
*/
%ignore GncOptionDB::register_option(const char*, GncOption&&);
/* GncOptionDB::save_to_scheme takes and returns a std::stream. Good luck
* converting *that* to anything useful!
*/
%ignore GncOptionDB::save_to_scheme(std::ostream&, const char*);
%ignore GncOptionDB::save_option_scheme(std::ostream&, const char*, const std::string&, const std::string&);
%ignore GncOptionDB::load_option_scheme(std::itream&);
/* The following functions are overloaded in gnc-optiondb.hpp to provide both
* GncOptionDB* and GncOptionDBPtr& versions. That confuses SWIG so ignore the
* raw-ptr version.
@@ -1232,6 +1238,14 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
});
});
}
std::string
gnc_optiondb_save_to_scheme(GncOptionDBPtr& odb, const char* prolog)
{
std::ostringstream oss;
odb->save_to_scheme(oss, prolog);
return oss.str();
}
%}
#endif //SWIGGUILE

View File

@@ -35,6 +35,10 @@
(define-public (gnc:value->string value)
(format #f "~s" value))
(define-public (gnc:generate-restore-forms options name)
(let ((optiondb (options 'generate-restore-forms)))
(gnc-optiondb-save-to-scheme optiondb name)))
(define-public (gnc:lookup-option options section name)
(if options
(gnc-lookup-option (options 'lookup) section name)