manipulators

custom stream manipulator for class

Hello All, I am trying to write a simple audit class that takes input via operator << and writes the audit after receiving a custom manipulator like this: class CAudit { public: //needs to be templated CAudit& operator << ( LPCSTR data ) { audittext << data; return *this; } //attempted manipulator s...

C++ - How to reset the output stream manipulator flags

I've got a line of code that sets the fill value to a '-' character in my output, but need to reset the setfill flag to its default whitespace character. How do I do that? cout << setw(14) << " CHARGE/ROOM" << endl; cout << setfill('-') << setw(11) << '-' << " " << setw(15) << '-' << " " << setw(11) << '-' << endl; I thought this ...

Custom C++ manipulator problem

Hi guys, I'm trying to implement my own stream manipulator inside my logging class. It's basically endline manipulator which changes state of a flag. However when I try to use it, I'll get: ftypes.cpp:57: error: no match for ‘operator<<’ in ‘log->Log::debug() << log->Log::endl’ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/...

Overload handling of std::endl ?

I want to define a class MyStream so that: MyStream myStream; myStream << 1 << 2 << 3 << std::endl << 5 << 6 << std::endl << 7 << 8 << std::endl; gives output [blah]123 [blah]56 [blah]78 Basically, I want a "[blah]" inserted at the front, then inserted after every non terminating std::endl ? The difficulty here is NOT the logic ma...

XML Dialect for scripting robot tasks

In my next project I will have to implement an automation solution to test a hardware device. basically, the test involves an industrial robotic arm picking a device to be tested, holding it at some specified position and then using a series of other devices like motors and sensors to exercise several areas of the product to be tested. ...

How do I use a manipulator to fomat my hex output with padded left zeros

The little test program below prints out: And SS Number IS =3039 I would like the number to print out with padded left zeros such that the total length is 8. So: And SS Number IS =00003039 (notice the extra zeros left padded) And I would like to know how to do this using manipulators and a stringstream as shown below. Thank...

Creating ostream manipulators for a specific class

I have a class that is derived from ostream: class my_ostream: public std::ostream { // ... } I want to make a manipulator (for example do_something), that works specifically to this class, like this: my_ostream s; s << "some text" << do_something << "some more text"; I did the following: std::ostream &do_something(std::ostrea...

ostream showbase non-present for zero value, and internal doesn't work for HANDLE? Must I fudge it?

PSPS: (a Pre-scripted Post-script) It has just come to mind that a more prescient question would have included the notion of: Is this non-display of "0x"(showbase) for zero-value integers a standard behaviour, or is it just a quirk of my MinGW implementation? It all began on a pleasant Sunday morning... I want to dump some Handles i...

ignore punctuation using manipulator

Is it possibile to ignore punctuacion using std manipulator on cin? For example suppose you have an input stream (in the actual case a file) like: "one, two three". I want to be able to do: f >> ignore_punct >> a; f >> ignore_punct >> b; f >> ignore_punct >> c; at the end a=="one", b=="two", c=="three". ...