You are not logged in.
Hi,
I am working with xml nodes and when assigning some values from xml to record i use mormot's functions obviously but it seems variant conversions does not work with OleStr or OleVariant types. Value is something like '688' and there is no case for OleStr so it will use SetVarDataUnRefSimpleValue which returns false.
This is not a major problem or anything, it just catch my eye and want you to know.
Best regards.
Last edited by koraycayiroglu (Yesterday 11:19:24)
Offline
SetVariantUnRefSimpleValue() only supports "simple" types, as documented and stated by its name.
WideString / BSTR are properly handled as varOleStr in mORMot code but not by this SetVariantUnRefSimpleValue() function for sure.
OleVariant could mean anything.
What does OleVariant mean in your case?
Where is SetVariantUnRefSimpleValue() called in your code?
Offline
it's very simple.
procedure Test(const Node: IXMLNode);
begin
if not VarIsEmptyOrNull(Node.ChildValues['RecID']) then self.fRecID := VariantToInteger(Node.ChildValues['RecID']);
end;Using ChildValues returns a OleVariant type and when i send that value to VariantToInteger, V's VType is 8 which is varOleStr. there is no case for varOleStr so it falls into else case and uses SetVarDataUnRefSimpleValue and fails.
Offline
It works just as documented: VariantToInteger() expect true numerical Variant and won't convert any string.
Here the input is a string, not a numerical value. So the function fails.
But anyway, which VariantToInteger() version are you using? there is no such function with a single parameter in mORMot.
The easiest may be to change your code e.g. to use regular RTL function, e.g. StringToInteger().
Or you can try the new AnyVariantToInteger() method:
https://github.com/synopse/mORMot2/commit/06d6452bc
Offline