Skip to content

Commit

Permalink
Implement gnc:generate-restore-forms, gnc-optiondb-save-to-scheme.
Browse files Browse the repository at this point in the history
  • Loading branch information
jralls committed Aug 1, 2021
1 parent c34986d commit a1af86e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 15 additions & 1 deletion libgnucash/app-utils/gnc-optiondb.i
Expand Up @@ -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"

Expand All @@ -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.
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions libgnucash/app-utils/options.scm
Expand Up @@ -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)
Expand Down

0 comments on commit a1af86e

Please sign in to comment.