mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Implement GncOptionValue<const QofQuery*>
QofQuery isn't a QofInstance and doesn't have a GUID.
This commit is contained in:
parent
0a8f66ee90
commit
f66a918be4
@ -1157,4 +1157,34 @@ operator>> <GncOptionDateValue>(std::istream& iss,
|
||||
return opt.in_stream(iss);
|
||||
}
|
||||
|
||||
/** QofQuery Options
|
||||
*/
|
||||
|
||||
inline std::istream&
|
||||
gnc_option_from_scheme(std::istream& iss, GncOptionValue<const QofQuery*>& opt)
|
||||
{
|
||||
//FIXME: Implement or maybe rethink.
|
||||
return iss;
|
||||
}
|
||||
|
||||
inline std::ostream&
|
||||
gnc_option_to_scheme(std::ostream& oss, GncOptionValue<const QofQuery*>& opt)
|
||||
{
|
||||
//FIXME: Implement or maybe rethink.
|
||||
return oss;
|
||||
}
|
||||
|
||||
inline std::istream&
|
||||
gnc_option_from_scheme(std::istream& iss, GncOptionValidatedValue<const QofQuery*>& opt)
|
||||
{
|
||||
//FIXME: Implement or maybe rethink.
|
||||
return iss;
|
||||
}
|
||||
|
||||
inline std::ostream&
|
||||
gnc_option_to_scheme(std::ostream& oss, GncOptionValidatedValue<const QofQuery*>& opt)
|
||||
{
|
||||
//FIXME: Implement or maybe rethink.
|
||||
return oss;
|
||||
}
|
||||
#endif //GNC_OPTION_IMPL_HPP_
|
||||
|
@ -481,8 +481,12 @@ GncOption::from_scheme(std::istream& iss)
|
||||
(std::is_same_v<std::decay_t<decltype(option)>,
|
||||
GncOptionMultichoiceValue>) ||
|
||||
std::is_same_v<std::decay_t<decltype(option)>,
|
||||
GncOptionValue<const QofQuery*>> ||
|
||||
std::is_same_v<std::decay_t<decltype(option)>,
|
||||
GncOptionValue<const QofInstance*>> ||
|
||||
std::is_same_v<std::decay_t<decltype(option)>,
|
||||
GncOptionValidatedValue<const QofQuery*>> ||
|
||||
std::is_same_v<std::decay_t<decltype(option)>,
|
||||
GncOptionValidatedValue<const QofInstance*>>)
|
||||
gnc_option_from_scheme(iss, option);
|
||||
else if constexpr
|
||||
@ -571,6 +575,8 @@ template GncOption::GncOption(const char*, const char*, const char*,
|
||||
const char*, const QofInstance*, GncOptionUIType);
|
||||
template GncOption::GncOption(const char*, const char*, const char*,
|
||||
const char*, SCM, GncOptionUIType);
|
||||
template GncOption::GncOption(const char*, const char*, const char*,
|
||||
const char*, const QofQuery*, GncOptionUIType);
|
||||
|
||||
template bool GncOption::get_value<bool>() const;
|
||||
template int GncOption::get_value<int>() const;
|
||||
@ -634,6 +640,7 @@ template bool GncOption::validate(double) const;
|
||||
template bool GncOption::validate(const char*) const;
|
||||
template bool GncOption::validate(std::string) const;
|
||||
template bool GncOption::validate(const QofInstance*) const;
|
||||
template bool GncOption::validate(const QofQuery*) const;
|
||||
template bool GncOption::validate(RelativeDatePeriod) const;
|
||||
template bool GncOption::validate(GncMultichoiceOptionIndexVec) const;
|
||||
|
||||
|
@ -40,6 +40,8 @@ extern "C"
|
||||
struct OptionClassifier;
|
||||
class GncOptionUIItem;
|
||||
using GncOptionUIItemPtr = std::unique_ptr<GncOptionUIItem>;
|
||||
struct _QofQuery;
|
||||
using QofQuery = _QofQuery;
|
||||
struct QofInstance_s;
|
||||
using QofInstance = QofInstance_s;
|
||||
template <typename ValueType> class GncOptionValue;
|
||||
@ -53,12 +55,14 @@ using GncOptionVariant = std::variant<GncOptionValue<std::string>,
|
||||
GncOptionValue<bool>,
|
||||
GncOptionValue<int64_t>,
|
||||
GncOptionValue<const QofInstance*>,
|
||||
GncOptionValue<const QofQuery*>,
|
||||
GncOptionValue<SCM>,
|
||||
GncOptionAccountValue,
|
||||
GncOptionMultichoiceValue,
|
||||
GncOptionRangeValue<int>,
|
||||
GncOptionRangeValue<double>,
|
||||
GncOptionValidatedValue<const QofInstance*>,
|
||||
GncOptionValidatedValue<const QofQuery*>,
|
||||
GncOptionDateValue>;
|
||||
|
||||
using GncOptionVariantPtr = std::unique_ptr<GncOptionVariant>;
|
||||
|
@ -208,6 +208,13 @@ scm_from_value<const QofInstance*>(const QofInstance* value)
|
||||
return SWIG_NewPointerObj(ptr, type, FALSE);
|
||||
}
|
||||
|
||||
template <> inline SCM
|
||||
scm_from_value<const QofQuery*>(const QofQuery* value)
|
||||
{
|
||||
auto ptr{static_cast<void*>(const_cast<QofQuery*>(value))};
|
||||
return SWIG_NewPointerObj(ptr, SWIGTYPE_p__QofQuery, FALSE);
|
||||
}
|
||||
|
||||
template <typename ValueType> inline ValueType
|
||||
scm_to_value(SCM new_value)
|
||||
{
|
||||
@ -273,6 +280,16 @@ scm_to_value<const QofInstance*>(SCM new_value)
|
||||
return static_cast<const QofInstance*>(ptr);
|
||||
}
|
||||
|
||||
template <> inline const QofQuery*
|
||||
scm_to_value<const QofQuery*>(SCM new_value)
|
||||
{
|
||||
if (new_value == SCM_BOOL_F)
|
||||
return nullptr;
|
||||
void* ptr{};
|
||||
SWIG_ConvertPtr(new_value, &ptr, SWIGTYPE_p__QofQuery, 0);
|
||||
return static_cast<const QofQuery*>(ptr);
|
||||
}
|
||||
|
||||
template <>inline GncOptionAccountList
|
||||
scm_to_value<GncOptionAccountList>(SCM new_value)
|
||||
{
|
||||
@ -689,6 +706,7 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
|
||||
%template(gnc_make_bool_option) gnc_make_option<bool>;
|
||||
%template(gnc_make_int64_option) gnc_make_option<int64_t>;
|
||||
%template(gnc_make_qofinstance_option) gnc_make_option<const QofInstance*>;
|
||||
%template(gnc_make_query_option) gnc_make_option<const QofQuery*>;
|
||||
|
||||
%extend GncOption {
|
||||
SCM get_scm_value()
|
||||
|
Loading…
Reference in New Issue
Block a user