@@ -1063,6 +1063,32 @@ qof_instance_set_kvp (QofInstance * inst, GValue const * value, unsigned count,
1063
1063
delete inst->kvp_data ->set_path (path, kvp_value_from_gvalue (value));
1064
1064
}
1065
1065
1066
+ template <typename T> std::optional<T>
1067
+ qof_instance_get_path_kvp (QofInstance* inst, const Path& path)
1068
+ {
1069
+ g_return_val_if_fail (QOF_IS_INSTANCE (inst), std::nullopt);
1070
+ auto kvp_value{inst->kvp_data ->get_slot (path)};
1071
+ return kvp_value ? std::make_optional<T>(kvp_value->get <T>()) : std::nullopt;
1072
+ }
1073
+
1074
+ template <typename T> void
1075
+ qof_instance_set_path_kvp (QofInstance* inst, std::optional<T> value, const Path& path)
1076
+ {
1077
+ g_return_if_fail (QOF_IS_INSTANCE (inst));
1078
+ delete inst->kvp_data ->set_path (path, value ? new KvpValue (*value) : nullptr );
1079
+ qof_instance_set_dirty (inst);
1080
+ }
1081
+
1082
+ template std::optional<const char *> qof_instance_get_path_kvp <const char *> (QofInstance*, const Path&);
1083
+ template std::optional<gnc_numeric> qof_instance_get_path_kvp <gnc_numeric> (QofInstance*, const Path&);
1084
+ template std::optional<GncGUID*> qof_instance_get_path_kvp <GncGUID*> (QofInstance*, const Path&);
1085
+ template std::optional<int64_t > qof_instance_get_path_kvp <int64_t > (QofInstance*, const Path&);
1086
+
1087
+ template void qof_instance_set_path_kvp <const char *> (QofInstance*, std::optional<const char *>, const Path& path);
1088
+ template void qof_instance_set_path_kvp <gnc_numeric> (QofInstance*, std::optional<gnc_numeric>, const Path& path);
1089
+ template void qof_instance_set_path_kvp <GncGUID*> (QofInstance*, std::optional<GncGUID*>, const Path& path);
1090
+ template void qof_instance_set_path_kvp <int64_t > (QofInstance*, std::optional<int64_t >, const Path& path);
1091
+
1066
1092
void qof_instance_get_path_kvp (QofInstance * inst, GValue * value, std::vector<std::string> const & path)
1067
1093
{
1068
1094
gvalue_from_kvp_value (inst->kvp_data ->get_slot (path), value);
0 commit comments