Archive for August, 2010

Dangerous COleDateTime::ParseDateTime

Friday, August 20th, 2010

COleDateTime::ParseDateTime is a handy function to parse a date string into a COleDateTime (and then SYSTEMTIME and then CTime).

The problem is that the expected date format depends on the user’s system settings. If you’re parsing a string that is always in the same format (from a file or from the internet), then parsing might work on your computer, but fail on the customer’s computer (in another country).

Solution: Use the locale ID parameter to force the parsing language.

CMap: Mapping CString to CStringArray

Monday, August 9th, 2010

Just a simple MFC trick. To map from CString to CStringArray use:

CMap<CString, LPCTSTR, CStringArrayX, CStringArrayX&>

where CStringArrayX is defined as:

class CStringArrayX : public CStringArray
 CStringArrayX() {}
 CStringArrayX(const CStringArrayX &qSource);
 CStringArrayX &operator = (const CStringArrayX &qSource);
CStringArrayX::CStringArrayX (const CStringArrayX &qSource)
 SetSize (qSource.GetSize());

 for (long c=qSource.GetSize()-1; c>=0; c--)
CStringArrayX &CStringArrayX::operator = (const CStringArrayX &qSource)
 SetSize (qSource.GetSize());
 for (long c=qSource.GetSize()-1; c>=0; c--)
 return (*this);

Hopefully this post keeps some people from searching as long as I did… 😉

Silencing command line builds

Monday, August 2nd, 2010

My builds have become more and more complex. Especially when releasing a new version it wasn’t always easy to tell at first glance whether all build steps succeeded. Some tools (I’m not telling names, here) are quite verbose and “pollute” the build log with things that I don’t really care about.

Here’s a simple freeware tool that I wrote to fix this: SilentCommandline.exe. It works as a DOS pipe with filter functions that can be configured in two external text files.

Using SilentCommandline:

Simply append it to your build batch files:

yourbuildcommand.exe |SilentCommandline.exe

It will take all output of  yourbuildcommand.exe, check if you want to see it and print it to stdout. To configure what you want to see, create 2 text files in the same folder where you keep SilentComandline.exe and name them silentlines.txt and silentlinesre.txt.

Config files:

The first one is simple. On string per line. If one of the strings equals a line from your build output, then this line will not be printed. You can use that for static texts that are always the same. Example:


The second file works basically the same, but allows you to use regular expressions in each line. Use it to handle build outputs that might change. Example:

Protected[0-9]* blocks of [0-9]* blocks total.


Here’s the download link to SilentCommandLine.exe

System requirements: Windows