For example I have Real32 DataBuffer. If I call getInt64,what will happen? Truncate or error?
If a Real64/Double DataBuffer, I also call getInt64(). What will happen?
@ming.cheng
I checked and found that DataBuffer::getDouble() works with Real and Double. Otherwise, you will get the following exception.
Invalid DataBuffer type [4] in DataBuffer::getDouble(). Only RealEnum or DoubleEnum types are allowed.
I can call getInt() for Real but I only get the integer part.
case DataBuffer::RealEnum: _out->out("\n GetInt for Real: %lld\n", dataBuffer.getInt()); _out->out("\n GetDouble for Real: %f\n", dataBuffer.getDouble()); printf("\nGetAsString(): %s\n", dataBuffer.getAsString().c_str());break;GetInt for Real: 3GetDouble for Real: 3.720099GetAsString(): 3.720099
Integer type of DataBuffer but getAsDouble(), what will happen. Basically my application's receiving variable can be a different type. For example I could getDouble() then cast the value into integer. Just want to explore whether I can call getInt64() directly. Same for all Integral DataBuffer, may I call getDouble()?
Thanks for reaching out to us.
I checked the document and found that "The getInt64 method has been [DEPRECATED]. The setInt and getInt methods provide a simpler interface and can be used to replace the setInt64 and getInt64 methods."
However, the document states that it can throw InvalidUsageException when Illegal DataBuffer Type found.
I recommended checking the type before calling associated methods.
I hope that this information is of help.
So when come to type handling, must be apple to apple, pear to pear. Otherwise user will get InvalidUsageException error. If necessary, user should convert a value to another type by user code.
but for Real64Enum/Real32Enum databuffer, user can still use getDouble() as normal double value?
According to the question, it looks like you are developing a new application with RFA C++.
RFA C++ is a legacy API and we don't recommend developing a new application with the legacy API.
If you are developing a new application to consume real-time data, please consider using the RTSDK C/C++ (EMA C++) instead. Please also refer to the API Compatibility Matrix for the support operating systems and compilers.