C++ API bug with getLongArray
Moderators: Lapo, Bax, MBagnati
C++ API bug with getLongArray
If i send a long value(1000010000123) by longarray from server,the value which c++ client received is (-717379845).Please check it.
Re: C++ API bug with getLongArray
Could anybody help me?
Re: C++ API bug with getLongArray
Hi,
it is an API error.
To fix please apply these changes:
Change #1
File: \Entities\Data\SFSObject.cpp
Method: boost::shared_ptr<string> SFSObject::Dump()
at line 287 there is
case SFSDATATYPE_LONG_ARRAY:
that is implemented in this way
Replace
with
Change #2
File: \Protocol\Serialization\DefaultSFSDataSerializer.cpp
Method: boost::shared_ptr<SFSDataWrapper> DefaultSFSDataSerializer::BinDecode_LONG_ARRAY(boost::shared_ptr<ByteArray> buffer)
Replace the whole method with this code
Thanks for your collaboration
it is an API error.
To fix please apply these changes:
Change #1
File: \Entities\Data\SFSObject.cpp
Method: boost::shared_ptr<string> SFSObject::Dump()
at line 287 there is
case SFSDATATYPE_LONG_ARRAY:
that is implemented in this way
Code: Select all
case SFSDATATYPE_LONG_ARRAY:
{
strDump->append("[");
vector<long long>::iterator iteratorWrapperData;
for(iteratorWrapperData = ((vector<long long>*)wrapper->Data().get())->begin(); iteratorWrapperData != ((vector<long long>*)wrapper->Data().get())->end(); ++iteratorWrapperData)
{
boost::shared_ptr<string> temporaryString (new string());
boost::shared_ptr<string> format (new string("[%ld]"));
StringFormatter<long long> (temporaryString, format, *iteratorWrapperData);
strDump->append(*temporaryString);
}
strDump->append("]");
break;
}
Replace
Code: Select all
boost::shared_ptr<string> format (new string("[%ld]"));
with
Code: Select all
boost::shared_ptr<string> format (new string("[%lld]"));
Change #2
File: \Protocol\Serialization\DefaultSFSDataSerializer.cpp
Method: boost::shared_ptr<SFSDataWrapper> DefaultSFSDataSerializer::BinDecode_LONG_ARRAY(boost::shared_ptr<ByteArray> buffer)
Replace the whole method with this code
Code: Select all
boost::shared_ptr<SFSDataWrapper> DefaultSFSDataSerializer::BinDecode_LONG_ARRAY(boost::shared_ptr<ByteArray> buffer)
{
long int size = GetTypedArraySize(buffer);
boost::shared_ptr<vector<long long> > arrayobj (new vector<long long>());
for (int j = 0; j < size; j++)
{
long long value;
buffer->ReadLong(value);
arrayobj->push_back(value);
}
return boost::shared_ptr<SFSDataWrapper>(new SFSDataWrapper(SFSDATATYPE_LONG_ARRAY, arrayobj));
}
Thanks for your collaboration
Who is online
Users browsing this forum: No registered users and 48 guests