Implement GncOptionValue<const QofQuery*>

QofQuery isn't a QofInstance and doesn't have a GUID.
This commit is contained in:
John Ralls 2021-03-11 18:03:36 -08:00
parent 0a8f66ee90
commit f66a918be4
4 changed files with 59 additions and 0 deletions

View File

@ -1157,4 +1157,34 @@ operator>> <GncOptionDateValue>(std::istream& iss,
return opt.in_stream(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_ #endif //GNC_OPTION_IMPL_HPP_

View File

@ -481,8 +481,12 @@ GncOption::from_scheme(std::istream& iss)
(std::is_same_v<std::decay_t<decltype(option)>, (std::is_same_v<std::decay_t<decltype(option)>,
GncOptionMultichoiceValue>) || GncOptionMultichoiceValue>) ||
std::is_same_v<std::decay_t<decltype(option)>, std::is_same_v<std::decay_t<decltype(option)>,
GncOptionValue<const QofQuery*>> ||
std::is_same_v<std::decay_t<decltype(option)>,
GncOptionValue<const QofInstance*>> || GncOptionValue<const QofInstance*>> ||
std::is_same_v<std::decay_t<decltype(option)>, std::is_same_v<std::decay_t<decltype(option)>,
GncOptionValidatedValue<const QofQuery*>> ||
std::is_same_v<std::decay_t<decltype(option)>,
GncOptionValidatedValue<const QofInstance*>>) GncOptionValidatedValue<const QofInstance*>>)
gnc_option_from_scheme(iss, option); gnc_option_from_scheme(iss, option);
else if constexpr else if constexpr
@ -571,6 +575,8 @@ template GncOption::GncOption(const char*, const char*, const char*,
const char*, const QofInstance*, GncOptionUIType); const char*, const QofInstance*, GncOptionUIType);
template GncOption::GncOption(const char*, const char*, const char*, template GncOption::GncOption(const char*, const char*, const char*,
const char*, SCM, GncOptionUIType); 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 bool GncOption::get_value<bool>() const;
template int GncOption::get_value<int>() 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(const char*) const;
template bool GncOption::validate(std::string) const; template bool GncOption::validate(std::string) const;
template bool GncOption::validate(const QofInstance*) 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(RelativeDatePeriod) const;
template bool GncOption::validate(GncMultichoiceOptionIndexVec) const; template bool GncOption::validate(GncMultichoiceOptionIndexVec) const;

View File

@ -40,6 +40,8 @@ extern "C"
struct OptionClassifier; struct OptionClassifier;
class GncOptionUIItem; class GncOptionUIItem;
using GncOptionUIItemPtr = std::unique_ptr<GncOptionUIItem>; using GncOptionUIItemPtr = std::unique_ptr<GncOptionUIItem>;
struct _QofQuery;
using QofQuery = _QofQuery;
struct QofInstance_s; struct QofInstance_s;
using QofInstance = QofInstance_s; using QofInstance = QofInstance_s;
template <typename ValueType> class GncOptionValue; template <typename ValueType> class GncOptionValue;
@ -53,12 +55,14 @@ using GncOptionVariant = std::variant<GncOptionValue<std::string>,
GncOptionValue<bool>, GncOptionValue<bool>,
GncOptionValue<int64_t>, GncOptionValue<int64_t>,
GncOptionValue<const QofInstance*>, GncOptionValue<const QofInstance*>,
GncOptionValue<const QofQuery*>,
GncOptionValue<SCM>, GncOptionValue<SCM>,
GncOptionAccountValue, GncOptionAccountValue,
GncOptionMultichoiceValue, GncOptionMultichoiceValue,
GncOptionRangeValue<int>, GncOptionRangeValue<int>,
GncOptionRangeValue<double>, GncOptionRangeValue<double>,
GncOptionValidatedValue<const QofInstance*>, GncOptionValidatedValue<const QofInstance*>,
GncOptionValidatedValue<const QofQuery*>,
GncOptionDateValue>; GncOptionDateValue>;
using GncOptionVariantPtr = std::unique_ptr<GncOptionVariant>; using GncOptionVariantPtr = std::unique_ptr<GncOptionVariant>;

View File

@ -208,6 +208,13 @@ scm_from_value<const QofInstance*>(const QofInstance* value)
return SWIG_NewPointerObj(ptr, type, FALSE); 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 template <typename ValueType> inline ValueType
scm_to_value(SCM new_value) scm_to_value(SCM new_value)
{ {
@ -273,6 +280,16 @@ scm_to_value<const QofInstance*>(SCM new_value)
return static_cast<const QofInstance*>(ptr); 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 template <>inline GncOptionAccountList
scm_to_value<GncOptionAccountList>(SCM new_value) 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_bool_option) gnc_make_option<bool>;
%template(gnc_make_int64_option) gnc_make_option<int64_t>; %template(gnc_make_int64_option) gnc_make_option<int64_t>;
%template(gnc_make_qofinstance_option) gnc_make_option<const QofInstance*>; %template(gnc_make_qofinstance_option) gnc_make_option<const QofInstance*>;
%template(gnc_make_query_option) gnc_make_option<const QofQuery*>;
%extend GncOption { %extend GncOption {
SCM get_scm_value() SCM get_scm_value()