(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.


Description: Manipulators for ecl streams.

Keywords: ecl streams manipulators

Tutorial Level: INTERMEDIATE


Ecl manipulators are defined to enable some similar functionality to c++'s cout manipulators for ecl's streams. However they extend the concept to use class instantiations rather than functions. This provides one important advantage over the former, these manipulators can retain state. Given that they're also easy to customise, this opens up many possibilities.

The default manipulators defined in the ecl export a few global instantiations, namely

  • ecl::endl

  • ecl::clrscr


Using manipulators follows the same pattern as for standard c++ style cout manipulators.

   1 int main() {
   2     ecl::OConsoleStream ostream;
   3     ostream << ecl::clrscr;
   4     ostream << "Dude" << ecl::endl;
   5     return;
   6 }

Creating your own Manipulators

  • Any manipulator that you wish to define must inherit from this parent class in the following manner:

include <ecl/streams/manipulators.hpp>

class MyManipulator : public ecl::Manipulator<MyManipulator> {
    template <typename OutputStream>
    void action (OutputStream& ostream) {
        // ...

Wiki: ecl_streams/Tutorials/Manipulators (last edited 2012-01-30 00:43:51 by DanielStonier)