Many people mistakenly believe that polymorph ism has to be done in a OO language, such as C++.
Where it is true that C++ gives a quite straightforward implement, one might be shocked to find out that procedure language may have some advantages.
The techniques are not newly invented. It has been existed for more than a decade. For example, in Windows GDI, a DC represents a output device.
Saturday, August 30, 2008
Tuesday, March 18, 2008
std::iostream adaptor for com::IStream interface
I am working on a C++ library that uses std::iostream for all kinds of IO. Now I finished it and started to add a COM wrapper above it. One of the issues is to convert IStream into std::istream. At the first glance, it is not easy since istream has a dozen methods.
Monday, January 28, 2008
Friday, November 23, 2007
Exchange Server Woes
We are a very small company. Many companies at our size do not have servers because they can not afford a dedicated system administrator. But we are different. I got my MCSE 10 years ago, and I thoroughly understand TCP/IP network.
The Exchange server is a core part of the network - the place we archive all e-mails and important documents. The search facility in outlook (the Advanced Search) is fantastic for searching emails and binary files.
Since we are a small company, after we set up the server we have not backed it up once. At that time, we felt that e-mails archives are not quite important, and we can always recover the loss if needed. Today, we have a different view - because we have so many e-mails and documents managed by Exchange.
I noticed that the Exchange server eats disk space very quickly. The hard disk that the exchange server occupies has a capacity of 80GB. When it was installed, it has plenty of space (about 70G). Today we are surprised to learn that there are only 20GB spare space left. I noticed that there are virtually thousands of log files under the MDBDATA folder.
After reading several pages of a book, and reading numerous web pages, I finanlly work out a solution. There is a flag called "enable circular loggin" that you can turn on. In this mode Exchange server will reuse a log file over and over again. The down side is that you can no longer perform differential backup. But hay, a full backup turned out to be only 1.5G for us. We can certainly afford doing full backups every day.
The Exchange server is a core part of the network - the place we archive all e-mails and important documents. The search facility in outlook (the Advanced Search) is fantastic for searching emails and binary files.
Since we are a small company, after we set up the server we have not backed it up once. At that time, we felt that e-mails archives are not quite important, and we can always recover the loss if needed. Today, we have a different view - because we have so many e-mails and documents managed by Exchange.
I noticed that the Exchange server eats disk space very quickly. The hard disk that the exchange server occupies has a capacity of 80GB. When it was installed, it has plenty of space (about 70G). Today we are surprised to learn that there are only 20GB spare space left. I noticed that there are virtually thousands of log files under the MDBDATA folder.
After reading several pages of a book, and reading numerous web pages, I finanlly work out a solution. There is a flag called "enable circular loggin" that you can turn on. In this mode Exchange server will reuse a log file over and over again. The down side is that you can no longer perform differential backup. But hay, a full backup turned out to be only 1.5G for us. We can certainly afford doing full backups every day.
Monday, October 8, 2007
svn_load_dirs.pl woes
I use subversion to manage all software projects. It is a nice utility, much better than the commercial SourceSafe. And it is free. Have not encounter any problems in the past three years.
Today I am trying to upgrade boost from 1.33 to 1.34. There are a lot of changes between the two versions, so it is not possible to manually change them. Furthermore, although WinMerge is nice to show all the differences, it does not understand subversion command. If a file exists in 1.34 but not in 1.33, the correct command is "svn copy" rather than copy.
My installation does not have this magic file svn_load_dirs.pl. I grabbed it from collab: http://svn.collab.net/repos/svn/tags/1.4.2/contrib/client-side/svn_load_dirs.pl.in. I did a copy and paste, and run the command, it gives me an error:
'SVN_BINDIR@' is not recognized as an internal or external command,
Not good. Look further I found the file extension ends with .in. So some work needs to be done to convert it to .pl. Open the file, I found this line:
# Specify the location of the svn command.
my $svn = '@SVN_BINDIR@/svn';
Cool. Changed the line to
my $svn = 'C:\Program Files\Subversion\bin\svn.exe';
and it worked properly.
Today I am trying to upgrade boost from 1.33 to 1.34. There are a lot of changes between the two versions, so it is not possible to manually change them. Furthermore, although WinMerge is nice to show all the differences, it does not understand subversion command. If a file exists in 1.34 but not in 1.33, the correct command is "svn copy" rather than copy.
My installation does not have this magic file svn_load_dirs.pl. I grabbed it from collab: http://svn.collab.net/repos/svn/tags/1.4.2/contrib/client-side/svn_load_dirs.pl.in. I did a copy and paste, and run the command, it gives me an error:
'SVN_BINDIR@' is not recognized as an internal or external command,
Not good. Look further I found the file extension ends with .in. So some work needs to be done to convert it to .pl. Open the file, I found this line:
# Specify the location of the svn command.
my $svn = '@SVN_BINDIR@/svn';
Cool. Changed the line to
my $svn = 'C:\Program Files\Subversion\bin\svn.exe';
and it worked properly.
Thursday, October 4, 2007
Default C/C++ char is signed
Programmer often forgot that the default char type is signed, instead of unsigned. In VC, /J gives the char unsigned. We ran into a problem this week:
if ( character > 126 character < 32) {
sprintf(sTemp, "%02X", character);
os << '#' <<>
In VC 2003, sTemp gives "FFFFFFFFFac" for character 0xac. To correct the issue, convert it to unsigned integer type, such as
sprintf(sTemp, "%02X", (unsigned char)character );
Note that this statement
if ( character > 126 character <>
implies that the character is unsigned type. This variable should be declared as unsigned char at the beginning.
if ( character > 126 character < 32) {
sprintf(sTemp, "%02X", character);
os << '#' <<>
In VC 2003, sTemp gives "FFFFFFFFFac" for character 0xac. To correct the issue, convert it to unsigned integer type, such as
sprintf(sTemp, "%02X", (unsigned char)character );
Note that this statement
if ( character > 126 character <>
implies that the character is unsigned type. This variable should be declared as unsigned char at the beginning.
Wednesday, August 29, 2007
Quirks in STL string class
Today I found a pretty annoyance when using STL string class. The find function returns the index if it find the string, and string::npos if it does not. For example,
std::string str("joeliscrazy");
index = str.find("joes");
The find returns a type of string::size_type, which is size_t in most implementations. Now since size_type is unsigned, you no longer can write the following statement
if ( index < 0 ) { }
Unless you define index as a signed type, such as int.
Other string libraries (java, .Net and MFC) use signed type as index, thus avoid this problem. Since most modern platforms provide 32-bit integer, who on the earth require a unsigned int as string index?
std::string str("joeliscrazy");
index = str.find("joes");
The find returns a type of string::size_type, which is size_t in most implementations. Now since size_type is unsigned, you no longer can write the following statement
if ( index < 0 ) { }
Unless you define index as a signed type, such as int.
Other string libraries (java, .Net and MFC) use signed type as index, thus avoid this problem. Since most modern platforms provide 32-bit integer, who on the earth require a unsigned int as string index?
Subscribe to:
Posts (Atom)