PIP 1.7.1 Platform-Independent Primitives

Classes | Public Types | Public Member Functions | Related Functions | List of all members
PICout Class Reference

Class for formatted output similar std::cout. More...

## Classes
class | Notifier
| Class for emit notifications of PICout. More...

## Public Types
enum | OutputDevice { NoDevices = 0x0, StdOut = 0x1, Buffer = 0x2, AllDevices = 0xFFFF }
| Enum contains output devices of PICout. More...

## Public Member Functions
| PICout (PIFlags< PICoutManipulators::PICoutControl > controls=PICoutManipulators::AddSpaces|PICoutManipulators::AddNewLine)
| Default constructor with default features (AddSpaces and AddNewLine)
| PICout (PIString *buffer, int id=0, PIFlags< PICoutManipulators::PICoutControl > controls=PICoutManipulators::AddSpaces|PICoutManipulators::AddNewLine)
| Construct with external buffer and id "id". See Notifier for details.
PICout | operator<< (const char *v)
| Output operator for strings with `"const char * "` type.
PICout | operator<< (const bool v)
| Output operator for strings with `"std::string"` type. More...
PICout | operator<< (const char v)
| Output operator for `"char"` values.
PICout | operator<< (const uchar v)
| Output operator for `"unsigned char"` values.
PICout | operator<< (const short v)
| Output operator for `"short"` values.
PICout | operator<< (const ushort v)
| Output operator for `"unsigned short"` values.
PICout | operator<< (const int v)
| Output operator for `"int"` values.
PICout | operator<< (const uint v)
| Output operator for `"unsigned int"` values.
PICout | operator<< (const long v)
| Output operator for `"long"` values.
PICout | operator<< (const ulong v)
| Output operator for `"unsigned long"` values.
PICout | operator<< (const llong v)
| Output operator for `"long long"` values.
PICout | operator<< (const ullong v)
| Output operator for `"unsigned long long"` values.
PICout | operator<< (const float v)
| Output operator for `"float"` values.
PICout | operator<< (const double v)
| Output operator for `"double"` values.
PICout | operator<< (const void *v)
| Output operator for pointers.
PICout | operator<< (const PIObject *v)
| Output operator for PIObject and ancestors.
PICout | operator<< (const PICoutManipulators::PICoutSpecialChar v)
| Output operator for PICoutSpecialChar values.
PICout | operator<< (const PIFlags< PICoutManipulators::PICoutFormat > &v)
| Output operator for PIFlags<PICoutFormat> values.
PICout | operator<< (const PICoutManipulators::PICoutFormat v)
| Output operator for PICoutFormat values.
PICout | operator<< (const PICoutManipulators::PICoutAction v)
| Do some action. More...
PICout & | setControl (PICoutManipulators::PICoutControl c, bool on=true)
| Set control flag "c" is "on" state.
PICout & | setControl (PICoutManipulators::PICoutControls c, bool save=false)
| Set control flags "c" and if "save" exec saveControl()
PICout & | saveControl ()
| Save control flags to internal stack. More...
PICout & | restoreControl ()
| Restore control flags from internal stack. More...
PICout & | space ()
| Conditional put space character to output. More...
PICout & | quote ()
| Conditional put quote character to output. More...
PICout & | newLine ()
| Conditional put new line character to output. More...

## Related Functions
(Note that these are not member functions.)
PICout | operator<< (PICout s, const PIString &v)
| Output operator to PICout.
PICout | operator<< (PICout s, const PIStringList &v)
| Output operator to PICout.
PICout | operator<< (PICout s, const PISystemTime &v)
| Output operator to PICout.
PICout | operator<< (PICout s, const PITime &v)
| Output operator to PICout.
PICout | operator<< (PICout s, const PIDate &v)
| Output operator to PICout.
PICout | operator<< (PICout s, const PIDateTime &v)
| Output operator to PICout.

## Detailed Description

Class for formatted output similar std::cout.

# Synopsis

This class provide many stream operators for output with some features. Output to PICout is thread-sequential, i.e. doesn`t mixed from parallel threads.

# Features

- insertion spaces between entries
- insertion new line at the end of output
- strings are quoted
- custom output operator can be easily written

# Usage

int a = 10, b = 32, c = 11;
piCout << a << Hex << b << Bin << c;
// 10 20 1011
piCout << "this" << "is" << Green << "green" << Default << "word";
// this is green word
PICout(AddSpaces | AddNewLine | AddQuotes) << Tab << "tab and" << "quotes";
// "tab and" "quotes"

# Writing your own output operator

inline PICout operator <<(PICout s, const PIByteArray & ba) {
s.space(); // insert space after previous output
s.quote(); // ONLY if you want to quoted your type
s.setControl(0, true); // clear all features and
// save them to stack,
// now it`s behavior similar to std::cout
// your output
for (uint i = 0; i < ba.size(); ++i)
s << ba[i];
s.restoreControl(); // restore features from stack
s.quote(); // ONLY if you want to quoted your type
return s;
}

## Member Enumeration Documentation

## ◆ OutputDevice

enum PICout::OutputDevice

Enum contains output devices of PICout.

Enumerator
NoDevices | PICout is disabled
StdOut | Standard console output
Buffer | Internal buffer
AllDevices | All

## Member Function Documentation

## ◆ operator<<() [1/2]

PICout PICout::operator<< | ( | const bool | v | ) |

Output operator for strings with `"std::string"` type.

Output operator for boolean values

## ◆ operator<<() [2/2]

PICout PICout::operator<< | ( | const PICoutManipulators::PICoutAction | v | ) |

Do some action.

TODO : wondows ClearScreen !!!

## ◆ saveControl()

PICout & PICout::saveControl | ( |  | ) |

Save control flags to internal stack.

See also
  restoreControl()

## ◆ restoreControl()

PICout & PICout::restoreControl | ( |  | ) |

Restore control flags from internal stack.

See also
  saveControl()

## ◆ space()

PICout & PICout::space | ( |  | ) |

Conditional put space character to output.

If it is not a first output and control AddSpaces is set space character is put

See also
  quote(), newLine()

## ◆ quote()

PICout & PICout::quote | ( |  | ) |

Conditional put quote character to output.

If control AddQuotes is set quote character is put

See also
  space(), newLine()

## ◆ newLine()

PICout & PICout::newLine | ( |  | ) |

Conditional put new line character to output.

If control AddNewLine is set new line character is put

See also
  space(), quote()