Overloading the << operator.

Outside Class definition.

std::ostream& operator<<(std::ostream& os, const QualifierEnum qe) {
    switch(qe) {
        case QualifierEnum::Pass: os << ""; break;
        case QualifierEnum::Fail: os << "-"; break;
        case QualifierEnum::SoftFail: os << "~"; break;
        case QualifierEnum::Neutral: os << "?"; break;
    }
    return os;
}

Within a Class definition.

Header File

class Sample {
  
  private:
    ...
  public:
    friend std::ostream& operator<<(std::ostream& os, Qualifier const &qualifier);
}

Here we use friend to prevent the compiler from complaining about the number of arguments.

Source File

std::ostream& operator<<(std::ostream& os, Qualifier const& qualifier) {
    if (qualifier.is_pass()) return os << "";
    return os << static_cast<char>(qualifier._value);
}

A guide for using CMake Generators to support other IDEs.

Some times we might be working in a team, and that team has members who prefer to use different IDEs or who develop on different platforms. In these cases we can leverage CMake’s generators.
This is a short guide on using a generator for Xcode and adding a second test file to break up testing.

[Read More]

A barebones C++ library template using CMake and Google Test

Objective

This is a BAREBONES C++ template with Google Test support using CMake. It is setup to allow for the building of a static library using TDD principles; but could be adapted for building a small program. This is in no way the ideal solution.

This template was created to allow for programming under Mac OS. But the files should work under other systems.

[Read More]