|
Does the serialization class CArchive automatically handle byte ordering differences on different platforms ? I have a class which i am serializing on an Big Endian platform but will be deserializing it on a little endian platform. Is there anything i need to watch out for ? The only bit of info i have managed to find on the net is this article http://www.drdobbs.com/184409538;jsessionid=T1RL5VK3F2RBFQE1GHPCKHWATMY32JVN?_requestid=488503[^] However it is a bit outdated.
[Solution]
OK for those who are interested, it seems as if CArchive does not do any byte swapping at all. The reason being is that all versions of windows run the same endianess.. http://social.msdn.microsoft.com/Forums/en/windowsmobiledev/thread/04c92ef9-e38e-415f-8958-ec9f7c196fd3[^]
The two items in the CArchive class that would have anything to do with byte swapping actually do nothing at all.
i.e. CArchive::IsByteSwapping and CArchive::bNoByteSwap Cheers
Garth
I don't really care whether or not i really care or not.
modified on Tuesday, March 2, 2010 6:29 AM
|
|
|
|
|
Well, you may perform a little test.
[added]
I guess the outdated article's content is still true (at least for compatibility reasons).
[/added]If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Well....I'm just taking the easy way out Actually i was hoping someone had already performed a little test already. And i also don't currently have access to the little endian platform. Cheers
Garth
I don't really care whether or not i really care or not.
|
|
|
|
|
Garth Watkins wrote: And i also don't currently have access to the little endian platform.
You don't need: just see, with you fovourite hex editor, if the binary file is properly 'little-endianned'... If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
How is that going to help ? Lets say for instance i serialize class to a file. I then open the file in a hex editor. That's going to tell me what format (Little Endian/Big Endian) the CArchive class saves data in. It's not going to tell me whether or not it gets restored in the proper way when deserializing it on another platform that has a different byte order. Cheers
Garth
I don't really care whether or not i really care or not.
|
|
|
|
|
Garth Watkins wrote: That's going to tell me what format (Little Endian/Big Endian) the CArchive class saves data in. It's not going to tell me whether or not it gets restored in the proper way when deserializing it on another platform that has a different byte order.
It should serialize it in little-endian format. That way you may be pretty confident it will work on other platforms (as quick-test result 'pretty confident' is good, anyway, I suppose checking the endianess is a bit painful).
I would say (based on Dr.Dobb's article): if you don't make mistakes, it will work.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
We want to download a file from the url.
If we are download a text file then this code will download the file successfully, but if we are trying to download a exe or even a jpg file then this code does not work fine.
We are using following code -
DWORD dwSize = 0;
DWORD dwDownloaded = 0;
LPSTR pszOutBuffer;
BOOL bResults = FALSE;
HINTERNET hSession = NULL,
hConnect = NULL,
hRequest = NULL;
hSession = WinHttpOpen( L"WinHTTP Example/1.0",
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);
if (hSession)
hConnect = WinHttpConnect(hSession, L"localhost.com", INTERNET_DEFAULT_HTTP_PORT, 0);
if (hConnect)
hRequest = WinHttpOpenRequest( hConnect, L"GET",
L"/CMS/upload/1.txt",
NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_REFRESH);
if (hRequest)
bResults = WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
if (bResults)
bResults = WinHttpReceiveResponse( hRequest, NULL);
if (bResults)
{
dwSize = 0;
if (!WinHttpQueryDataAvailable( hRequest, &dwSize))
printf("Error %u in WinHttpQueryDataAvailable.\n", GetLastError());
if (dwSize > 0)
{
pszOutBuffer = new char[dwSize+1];
}
if (!pszOutBuffer)
{
printf("Out of memory\n");
dwSize=0;
}
else
{
if (dwSize>0)
{
ZeroMemory(pszOutBuffer, dwSize+1);
if (!WinHttpReadData( hRequest, (LPVOID)pszOutBuffer, dwSize, &dwDownloaded))
printf("Error %u in WinHttpReadData.\n", GetLastError());
}
}
HANDLE hFile;
DWORD dwNumWritten;
BOOL bTest;
ofstream outfile ("D:\\1.txt",ofstream::binary);
outfile.write(pszOutBuffer,sizeof(dwSize) * 50);
Please help me what I am doing wrong.
|
|
|
|
|
You could use the URLDownloadToFile API.
|
|
|
|
|
I have tried the method which are suggest by u, Superman but it gives following error ---
unresolved external symbol _URLDownloadToFileW@20 referenced in function "void __cdecl funDownloadFile(void)" (?funDownloadFile@@YAXXZ)
|
|
|
|
|
Add Urlmon.lib to Project Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies .
|
|
|
|
|
Now it is working fine ... thanks a lot buddy..
|
|
|
|
|
avika wrote: but if we are trying to download a exe or even a jpg file then this code does not work fine.
What do you mean exactly?
BTW you should use the 'code block ' button to post code.
avika wrote: outfile.write(pszOutBuffer,sizeof(dwSize) * 50);
BTW2 Why 50 in the above line?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
if We are pass only outfile.write(pszOutBuffer,sizeof(dwSize)); then it show less data in the text file. But if We pass the outfile.write(pszOutBuffer,sizeof(dwSize) * 50); then it show complete data thats why we are passing this.
|
|
|
|
|
avika wrote: outfile.write(pszOutBuffer,sizeof(dwSize) * 50);
That should be
outfile.write(pszOutBuffer,dwSize);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
This above code works for binary image download, but the problem is:
For an image file with 18k size, only 4k can be download and just half of the image can be seen on the client side.
Any ideas?
Thanks.
|
|
|
|
|
Question:
In Polymorphism we give same name to function (function overloading).. so each function takes same memory or different?? If Yes than How and If no then why??
Please reply me as earlier as possible
|
|
|
|
|
First think, when posting use a relevant title. "hlp its urgent" is relevant at all: we know that you want help (why would you ask a question otherwise ?). Furthermore urgent requests are considered rude. Why would your question be more urgent than somebody else's question ?
Please, next time before posting, read the posting guidelines ("How to ask a question") at the top of this message board.
Now for your question, I suggest you take a look at this[^]. You can also google for "virtual table" for more information.
|
|
|
|
|
When you overload a function, basically you're giving the same name to two different functions (the compiler produces two functions with two different names in the object file) hence two different portions of code memory are, of course, used.
DX Roster wrote: Please reply me as earlier as possible If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Yes, I know that.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
It is possible by name mangling.
The compiler actually generates different names for the functions.
Read how Visual C++ compiler does this - Microsoft Visual C++ Name Mangling[^]
|
|
|
|
|
Mmmh, I'm confused now. I don't know if he was talking about function overloading or function overriding. He used the word overloading but he also talked about polymorphism (which has nothing to do with overloading but with overriding).
|
|
|
|
|
Cedric Moonen wrote: he also talked about polymorphism (which has nothing to do with overloading but with overriding).
Overloading is also a type of polymorphism - compile time polymorphism.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
There you have it.
Let's leave it to him to choose what he wants.
|
|
|
|
|
sir i want to know that if i write two function with same name(Polymorphism function overloading) then both function will take same memory or different..
if both will take same memory then how???
|
|
|
|