|
Boost libraries will slow down compilation, mainly due to the amount of code in the headers and the number of template instantiations needed. To speed it up, include Boost headers into a pre-compiled header. But not Boost.Bind or Boost.Lambda headers, as they use declare some objects that need to be single instance, and putting them in pre-compiled headers can mess that up.
You need to balance the convenience that Boost headers get you against the compile times. It's worth it 99% of the time.
|
|
|
|
|
I can't understand why it is worth. 99% of the time when using boost, I think the document should be enough, is it?
|
|
|
|
|
followait wrote: I can't understand why it is worth. 99% of the time when using boost, I think the document should be enough, is it?
Huh?
Steve
|
|
|
|
|
Thanks for you help.
But I can't agree that header files contains so much implementations code, I think it will slow down the compilation a lot (not sure). Could you tell what's the benifit by doing so?
|
|
|
|
|
I still don't understand what your asking. Boost relies heavily on templates, which can tend to slow down compilation. The solution, as previously mentioned, is to use pre-compiled headers.
Steve
|
|
|
|
|
followait wrote: But I can't agree that header files contains so much implementations code,
Template code *has* to be in headers if you're going to instantiate it for different template parameters, because every time you instantiate, you create a new implementation of the class/function.
|
|
|
|
|
|
If it is, where can I find it?
Thanks.
|
|
|
|
|
Not open as such, but it gets installed with versions of Visual Studio you pay for. In my VS2008 installation, it's in C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src.
|
|
|
|
|
Actually is should be here (along with other things): "C:\Program Files\Microsoft Visual Studio 9.0\VC\include". The CRT and the STL are two different things.
Steve
|
|
|
|
|
Call it a tie - we're both correct. Yes, CRT and STL are different, and yes, the include directory has most of the STL, but there's a reasonable amount of it that's in the crt/src directory as well (mostly code that's common across all template instantiations and pre-instantiated items like std::string (==std::basic_string<char> ) and the streams.
|
|
|
|
|
I had problem in migrating from VC6 to VC2005
typedef _A::size_type size_type; works fine in the vc 6 and flashes the below error after migrating to VC 2005
"thirdparty\dinkumpatches\xstring(39) : error C2146: syntax error : missing ';' before identifier 'size_type'"
pls advice
|
|
|
|
|
it looks like the "_A" isnt defined. Look where it was defined in the VC6 and than you why it isnt defined in VS2005. I guess it is a define which surrounds the "_A". Bad code
Greetings from Germany
|
|
|
|
|
Hi all,
In mfc I use CInternetSession to download files from an http server. What can I use via WTL?
Thanks,
Jayjay
|
|
|
|
|
|
Thanks,
Sorry what i meant was what can i use for ATL not WTL an ATL version of CInternet session.
|
|
|
|
|
You should be able to use this with ATL, it just wraps the WinInet API.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hi,
Will the distribute mfc libraries? Or even static link?
Because I think this still will.
Thanks,
Jayjay
|
|
|
|
|
Look at the code he pointed at - the only thing it references is WinInet - which is distributed as part of Windows, NOT MFC.
If you're conversant with the MFC classes, as you are, you're not going to find anything much easier or better than that wrapper - the only change I'd make would be to wrap the classes in a namespace so the names don't collide with MFC.
|
|
|
|
|
Thanks I am now using it, now I can't understand how I can write a file that i have downloaded.
Here is my code:
<br />
CString strStaus;<br />
CInternetSession Session(_T("Test Application"));<br />
CHttpConnection Connection1(Session,_T("http://10.5.1.4/downloads/Managepoint/ManagePoint431InstallerBuild_55.zip") ) ;<br />
BYTE Buffer[4096];<br />
<br />
<br />
CHttpFile File2(Session,_T("http://10.5.1.4/downloads/Managepoint/ManagePoint431InstallerBuild_55.zip") ) ;<br />
for (DWORD dwRead2;dwRead2=File2.Read(Buffer,sizeof(Buffer)) ; ) <br />
{<br />
}<br />
Thanks,
Jj
|
|
|
|
|
CHttpFile File1(Connection1,_T("GET"),_T("/"));
File1.SendRequest();
ULONGLONG const nBytes = </code><code>File1.GetLength();</code>
<code>BYTE* bytes = new BYTE[</code><code>nBytes</code><code>];
File1.Read(bytes ,</code><code>nBytes</code><code>) ;
HANDLE hFile = CreateFile(some-file-name, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
DWORD bytesWritten;
WriteFile(hFile, bytes, (DWORD)nBytes, &bytesWritten, 0);
CloseHandle(hFile);
I've assumed the file you're downloading is < 2GB (should be a safe assumption) and haven't put in any error handling. But that should work.
|
|
|
|
|
Thanks what i did to write was
<br />
for (DWORD dwRead2;dwRead2=File2.Read(Buffer,sizeof(Buffer));)
{<br />
fwrite(Buffer, sizeof (char), dwRead2 , pFile); <br />
}<br />
|
|
|
|
|
I got the header sorted out now, i got an important question though. How can I prevent the re-download of the file if it is already successfilly downloaded because the problem is that after i successfully downloaded the file and restarted my program it downloads again and adds the files to the complete files thus doubling the size of the file and making the file useless.
<br />
std::string strTmpFileName = "Temp_OutlookAddinInstallerBuild_30.zip";<br />
std::string strFileNameAtLocalMachine= "OutlookAddinInstallerBuild_30.zip";<br />
<br />
CString strStaus;<br />
double dCurrentFileSize;<br />
<br />
DWORD dwBytesWrrittenToFile =0;<br />
<br />
if(IfLocalFileExist(strTmpFileName.c_str(), &dCurrentFileSize)) <br />
{<br />
dOffsetToSeek = dCurrentFileSize;<br />
}<br />
<br />
CString strRangeQuest;<br />
<br />
if(dCurrentFileSize>0){ <br />
strRangeQuest.Format( _T("%sRange: bytes=%d-\r\n"), szHeaders,static_cast<ULONGLONG>(dCurrentFileSize));<br />
}<br />
else <br />
strRangeQuest = szHeaders;<br />
<br />
dwBytesWrrittenToFile = dOffsetToSeek;<br />
<br />
if ( !(pFile = fopen (strTmpFileName.c_str(), "ab" ) ) )<br />
{<br />
CString strMsg;<br />
strMsg.Format("Error:%d", GetLastError());<br />
return false;<br />
}<br />
if(dOffsetToSeek >=0)<br />
{<br />
strStaus.Format("Seeking to local file...");<br />
int n = fseek(pFile, dOffsetToSeek, SEEK_SET);<br />
}<br />
<br />
CInternetSession Session(_T("Test Application"));<br />
CHttpConnection Connection1(Session,_T("http://10.5.1.4/downloads/OutlookAddin/OutlookAddinInstallerBuild_30.zip"));<br />
BYTE Buffer[4096];<br />
<br />
CHttpFile File2(Session,_T("http://10.5.1.4/downloads/OutlookAddin/OutlookAddinInstallerBuild_30.zip"));<br />
CInternetFile::CInfo Info(File2);<br />
File2.SendRequest(strRangeQuest);<br />
int FileSize = Info.GetTotalDataLength();<br />
<br />
if (FileSize == dCurrentFileSize)<br />
{<br />
return 0;<br />
}<br />
<br />
for (DWORD dwRead2;dwRead2=File2.Read(Buffer,sizeof(Buffer));)<br />
{<br />
fwrite(Buffer, sizeof (char), dwRead2 , pFile); <br />
}<br />
<br />
MoveFile(strTmpFileName.c_str(), strFileNameAtLocalMachine.c_str() );<br />
<br />
return 0;<br />
Thanks,
jayjay
|
|
|
|
|
monsieur_jj wrote: How can I prevent the re-download of the file if it is already successfilly downloaded because the problem is that after i successfully downloaded the file and restarted my program it downloads again and adds the files to the complete files thus doubling the size of the file and making the file useless.
Check for file existence when starting the download process - if the file you want to write is already present, you need to take some action, whether it's overwriting the file or writing to a differently named file.
|
|
|
|
|
I got the writing sorted out however im still looking for ways to have a pause resume capability,
<br />
BYTE Buffer[4096];<br />
<br />
CHttpFile File1(Connection1,_T("GET"),_T("/"));<br />
File1.SendRequest();<br />
for (DWORD dwRead1;dwRead1=File1.Read(Buffer,sizeof(Buffer)););<br />
<br />
CHttpFile File2(Session,_T("http://www.codeproject.com/"));<br />
for (DWORD dwRead2;dwRead2=File2.Read(Buffer,sizeof(Buffer)););<br />
I am getting an error C2668 'function' : ambiguous call to overloaded function at File1.
what can i do to resolve this?
|
|
|
|