Tag: C++

Swiften on Lambdas

One of the cool new features of the upcoming C++ (0x) standard is support for lambda expressions, providing functional-style inline function declarations. After seeing Herb Sutter’s PDC 2010 webcast on lambdas, I wanted to try this out on Swiften, the XMPP library behind Swift. I adapted the introductory EchoBot example from XMPP: The Definitive Guide, and ported it from Python to a C++ application using Swiften. The result is surprisingly clean.

Continue reading →

Posted in Programming and Swift | Tagged C++, C++0x, CLang, GCC, Herb Sutter, Jabber, Lambdas, Swift, Swiften, Visual Studio, and XMPP

“Swiften Developer’s Guide” available

People have recently been showing interest in using Swiften, Swift’s C++ XMPP library, for building their own XMPP applications. We therefore created the Swiften Developer’s Guide with a tutorial-style guide to Swiften (including examples), and made it available together with the Swiften API Documentation. If you’re interested in creating an XMPP client or component, be sure to give these documents (and some of the examples from the Swift code repository) a look!

Posted in Swift | Tagged C++, Jabber, Swift, Swiften, and XMPP

“Beautiful Testing” XMPP Chapter

Adam Goucher and Tim Riley (Director of QA at Mozilla) announced a few months ago that they are putting together a Beautiful Testing book for O’Reilly. I took the opportunity to write a chapter about testing in the context of XMPP (more specifically, about testing protocol implementations in Swift), and just submitted the final draft for technical review. The book is expected to be released this August.

Continue reading →

Posted in Swift and Writing | Tagged Books, C++, Jabber, Nothing But Nets, O’Reilly, Swift, Unit Testing, and XMPP

Improving QtTest usability with QtTestUtil

As much as I like CppUnit for writing C++ unit tests, I still prefer using Qt’s built-in QtTest module for Qt-based projects. This avoids a dependency on an external library, lowering the threshold for running and writing unit tests. Unfortunately, QtTest is very basic, and lacks some useful features such as automatic test registration and running multiple test suites in one test binary. In order to improve QtTest’s usability, I started creating some macros and classes that fill in some of the gaps, and bundled them into QtTestUtil.

Continue reading →

Posted in Software | Tagged C++, CppUnit, Programming, Qt, QtUnit, and Unit Testing

Mixing Cocoa and Qt

Qt does a great job at abstracting out platform-specific features into platform-independent C++ APIs. However, sometimes you still need to write platform-specific code for features that are not in Qt (e.g. to access the platform’s address book),  or to access platform-specific applications (e.g. iTunes) or libraries (e.g. Sparkle). On Mac OS X, almost all interfaces are offered through the Cocoa Objective-C interface, and the interfaces that are written in C++ have been deprecated and will disappear soon in favor of Cocoa. Although the language of Cocoa is different from Qt’s, Qt and GCC make it very easy to call these interfaces from within your application. In this post, I will show how this can be done by making an auto-updating application using Sparkle.

Continue reading →

Posted in Programming | Tagged C++, Cocoa, GCC, Mac OS X, Objective-C, Programming, Qt, and Sparkle

:set noexpandtab

Google recently published a C++ style guide, containing all the rules that Google code adheres to. Many of the style tips are quite sensible, and well accepted by many developers out there. However, I was surprised to find the following rule:

Spaces vs. Tabs: Use only spaces, and indent 2 spaces at a time. We use spaces for indentation. Do not use tabs in your code. You should set your editor to emit spaces when you hit the tab key.

I never really understood why so many people have such a hatred towards tabs. Is it just because they have seen code where some editor has mixed tabs with spaces (which of course results in a horrible mess)? Or do they have valid counter-arguments, even when tabs are used consistently?

Continue reading →

Posted in Programming | Tagged C++, Coding Style, Google, Programming, and Tabs

Unit testing method overrides

It probably happened to most of us developers before: while refactoring, you change the name of a virtual method, but forget to change the name of the overriding method in one of your derived classes. Compilation works fine, all unit tests pass, but your program doesn’t work: the overriding method is never called. Java (and C#) programmers can avoid this problem by putting @Override (and override) in front of their methods, which causes the compiler to print out an error message if the method is not overriding anything. However, most other languages leave you hanging with this problem. Luckily, with statically typed languages like C++, you can avoid these bugs by slightly adapting your unit tests.

Continue reading →

Posted in Programming | Tagged C++, Programming, and Unit Testing

LGMTray: A Lightweight GMail Notifier

I have been looking for a Linux system tray application to notify me of new mail on my GMail account. Unfortunately, all the notifiers I found either did not run on Linux, or had dependencies I was unable to meet on my machine (because I lack system administrator privileges). This is why I wrote LGMTray, a very basic GMail notifier, with very few dependencies.

Continue reading →

Posted in Software | Tagged C++, FreeDesktop.org, GMail, LGMTray, and Tray