PIP 5.6.1
Platform-Independent Primitives
Classes | Public Types | Public Member Functions | Static Public Member Functions | Related Functions | List of all members
PICout Class Reference

Universal output to console class. This class provides a universal output interface with support for various data types, formatting options, and multiple output devices (console, buffer). More...

#include <picout.h>

Classes

class  Notifier
 Class for emit notifications of PICout. More...
 

Public Types

enum  OutputDevice { NoDevices = 0x0 , Console = 0x1 , DEPRECATEDM =("use PICout::Console") = Console , Buffer = 0x2 , AllDevices = 0xFFFF }
 Enum contains output devices of PICout. More...
 

Public Member Functions

 PICout (int controls=PICoutManipulators::DefaultControls, PICoutStdStream stream=PICoutStdStream::StdOut)
 Default constructor with default features (AddSpaces and AddNewLine)
 
 PICout (bool active, PICoutStdStream stream=PICoutStdStream::StdOut)
 Construct with default features (AddSpaces and AddNewLine), but if "active" is false does nothing.
 
PICoutoperator<< (const char *v)
 Output operator for strings with "const char * " type.
 
PICoutoperator<< (const PIString &v)
 Output operator for PIString.
 
PICoutoperator<< (bool v)
 Output operator for boolean values.
 
PICoutoperator<< (char v)
 Output operator for "char" values.
 
PICoutoperator<< (uchar v)
 Output operator for "unsigned char" values.
 
PICoutoperator<< (short v)
 Output operator for "short" values.
 
PICoutoperator<< (ushort v)
 Output operator for "unsigned short" values.
 
PICoutoperator<< (int v)
 Output operator for "int" values Outputs an integer value to the configured stream with optional format (binary, octal, decimal, hexadecimal).
 
PICoutoperator<< (uint v)
 Output operator for "unsigned int" values Outputs an unsigned integer value to the configured stream with optional format (binary, octal, decimal, hexadecimal).
 
PICoutoperator<< (long v)
 Output operator for "long" values Outputs a long integer value to the configured stream with optional format (binary, octal, decimal, hexadecimal).
 
PICoutoperator<< (ulong v)
 Output operator for "unsigned long" values Outputs an unsigned long integer value to the configured stream with optional format (binary, octal, decimal, hexadecimal).
 
PICoutoperator<< (llong v)
 Output operator for "long long" values Outputs a long long integer value to the configured stream with optional format (binary, octal, decimal, hexadecimal).
 
PICoutoperator<< (ullong v)
 Output operator for "unsigned long long" values Outputs an unsigned long long integer value to the configured stream with optional format (binary, octal, decimal, hexadecimal).
 
PICoutoperator<< (float v)
 Output operator for "float" values.
 
PICoutoperator<< (double v)
 Output operator for "double" values.
 
PICoutoperator<< (ldouble v)
 Output operator for "ldouble" values.
 
PICoutoperator<< (const void *v)
 Output operator for pointers Outputs a pointer address to the configured stream in hexadecimal format.
 
PICoutoperator<< (const PIObject *v)
 Output operator for PIObject and ancestors Outputs a PIObject or its descendants to the configured stream, including class name and object name.
 
PICoutoperator<< (PICoutManipulators::PICoutSpecialChar v)
 Output operator for PICoutSpecialChar values.
 
PICoutoperator<< (PIFlags< PICoutManipulators::PICoutFormat > v)
 Output operator for PIFlags<PICoutFormat> values Sets output format flags (binary, octal, decimal, hexadecimal, bold, colors) for subsequent integer output.
 
PICoutoperator<< (PICoutManipulators::PICoutFormat v)
 Output operator for PICoutFormat values Sets output format flag (binary, octal, decimal, hexadecimal, bold, colors) for subsequent integer output.
 
PICoutoperator<< (PICoutManipulators::PICoutAction v)
 Do some action. More...
 
PICoutsetControl (PICoutManipulators::PICoutControl c, bool on=true)
 Set control flag "c" is "on" state.
 
PICoutsetControls (PICoutManipulators::PICoutControls c)
 Set control flags "c".
 
PICoutsaveAndSetControls (PICoutManipulators::PICoutControls c)
 Exec saveControls() and set control flags to "c".
 
PICoutsaveControls ()
 Save control flags to internal stack Saves the current control flags to an internal stack for later restoration using restoreControls(). More...
 
PICoutrestoreControls ()
 Restore control flags from internal stack Restores the control flags from the internal stack that were previously saved using saveControls(). More...
 
PICoutspace ()
 Conditional put space character to output Conditionally adds a space character to the output if the AddSpaces control flag is enabled. More...
 
PICoutquote ()
 Conditional put quote character to output Conditionally adds quote characters to the output if the AddQuotes control flag is enabled. More...
 
PICoutnewLine ()
 Conditional put new line character to output Conditionally adds a newline character to the output if the AddNewLine control flag is enabled. More...
 
PICoutwrite (char c)
 Write char Writes a single character directly to the output stream without any formatting.
 
PICoutwrite (const char *str)
 Write raw data Writes raw C-style string data directly to the output stream without any formatting.
 
PICoutwrite (const char *str, int len)
 Write raw data Writes raw data of specified length directly to the output stream without any formatting.
 
PICoutwrite (const PIString &s)
 Write raw PIString Writes raw PIString data directly to the output stream without any formatting.
 

Static Public Member Functions

static void stdoutPIString (const PIString &str, PICoutStdStream s=PICoutStdStream::StdOut)
 Output PIString to stdout.
 
static PIString getBuffer ()
 Returns internal PIString buffer.
 
static PIString getBufferAndClear ()
 Returns internal PIString buffer and clear it.
 
static void clearBuffer ()
 Clear internal PIString buffer.
 
static bool setOutputDevice (OutputDevice d, bool on=true)
 Set output to device "d" enabled "on". Returns if it was enabled.
 
static bool enableOutputDevice (OutputDevice d)
 Turn on output device "d". Returns if it was enabled.
 
static bool disableOutputDevice (OutputDevice d)
 Turn off output device "d". Returns if it was enabled.
 
static void setOutputDevices (OutputDevices d)
 Set output to devices to "d".
 
static OutputDevices currentOutputDevices ()
 Returns current output devices.
 
static bool isOutputDeviceActive (OutputDevice d)
 Returns if output device "d" is active.
 
static PICout withExternalBuffer (PIString *buffer, PIFlags< PICoutManipulators::PICoutControl > controls=PICoutManipulators::AddSpaces)
 Construct with external buffer. Creates a PICout instance that outputs to an external PIString buffer with specified control flags.
 
static PICout withExternalBufferAndID (PIString *buffer, int id, PIFlags< PICoutManipulators::PICoutControl > controls=PICoutManipulators::DefaultControls)
 Construct with external buffer and ID "id". See Notifier for details Creates a PICout instance with external buffer and notification ID. When the last copy is destroyed, it emits a finished() event via Notifier.
 
static int registerExternalBufferID ()
 Returns unique external buffer ID for later use in withExternalBufferAndID()
 

Related Functions

(Note that these are not member functions.)

PICout operator<< (PICout s, const PISystemMonitor::ThreadStats &v)
 Output operator to PICout.
 
template<typename T >
PICout operator<< (PICout s, const PIDeque< T > &v)
 Output operator to PICout.
 
template<typename Key , typename Type >
PICout operator<< (PICout s, const PIMap< Key, Type > &v)
 Output operator to PICout.
 
template<typename Type0 , typename Type1 >
PICout operator<< (PICout s, const PIPair< Type0, Type1 > &v)
 Output operator to PICout.
 
template<typename T >
PICout operator<< (PICout s, const PIVector< T > &v)
 Output operator to PICout.
 
template<typename T >
PICout operator<< (PICout s, const PIVector2D< T > &v)
 Output operator for PIVector2D to PICout.
 
PICout operator<< (PICout s, const PIBinaryLog::BinLogInfo &bi)
 Writes PIBinaryLog::BinLogInfo summary to PICout.
 
PICout operator<< (PICout s, const PIDir &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIFile::FileInfo &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PISerial::DeviceInfo &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIUSB::Endpoint &v)
 Writes endpoint description to PICout.
 
PICout operator<< (PICout s, const PIBaseTransfer::Part &v)
 Writes Part to PICout.
 
PICout operator<< (PICout s, const PIFileTransfer::PFTFileInfo &v)
 Output PICout operator for PFTFileInfo.
 
template<typename Type >
PICout operator<< (PICout &s, const PILine< Type > &v)
 Writes segment coordinates to PICout.
 
template<typename T >
PICout operator<< (PICout s, const complex< T > &v)
 Writes a complex number as (real; imag).
 
template<typename Type >
PICout operator<< (PICout &s, const PIPoint< Type > &v)
 Writes point coordinates to PICout.
 
template<typename Type >
PICout operator<< (PICout &s, const PIRect< Type > &v)
 Writes rectangle description to PICout.
 
PICout operator<< (PICout s, const PIJSON &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PISystemInfo::MountInfo &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIConstChars &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIStringList &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIBitArray &ba)
 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.
 
PICout operator<< (PICout s, const PINetworkAddress &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PISystemTime &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PISystemTime::Frequency &f)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIValueTree &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIVariant &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIVariantTypes::Enumerator &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIVariantTypes::Enum &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIVariantTypes::File &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIVariantTypes::Dir &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIVariantTypes::Color &v)
 Output operator to PICout.
 
PICout operator<< (PICout s, const PIVariantTypes::IODevice &v)
 Output operator to PICout.
 

Detailed Description

Universal output to console class. This class provides a universal output interface with support for various data types, formatting options, and multiple output devices (console, buffer).

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

Usage

using namespace PICoutManipulators;
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"
PICout(int controls=PICoutManipulators::DefaultControls, PICoutStdStream stream=PICoutStdStream::StdOut)
Default constructor with default features (AddSpaces and AddNewLine)
Definition: picout.cpp:180
Namespace contains enums that controls PICout.
Definition: picout.h:70
@ Bin
Definition: picout.h:115
@ Hex
Definition: picout.h:118
@ Tab
Definition: picout.h:78
@ AddNewLine
Definition: picout.h:104
@ AddQuotes
Definition: picout.h:105
@ AddSpaces
Definition: picout.h:103
@ Default
Definition: piscreentypes.h:45
@ Green
Definition: piscreentypes.h:48
#define piCout
Definition: picout.h:36

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.saveAndSetControls(0); // 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.restoreControls(); // restore features from stack
s.quote(); // ONLY if you want to quoted your type
return s;
}
The PIByteArray class provides an array of bytes with efficient memory management and various manipul...
Definition: pibytearray.h:42
Universal output to console class. This class provides a universal output interface with support for ...
Definition: picout.h:166
PICout & operator<<(const char *v)
Output operator for strings with "const char * " type.
Definition: picout.cpp:448
return s
Store operator.
Definition: pisystemmonitor.h:312

Member Enumeration Documentation

◆ OutputDevice

Enum contains output devices of PICout.

Enumerator
NoDevices 

PICout is disabled

Console 

Standard console output

Buffer 

Internal buffer

AllDevices 

All

Member Function Documentation

◆ operator<<()

PICout & PICout::operator<< ( PICoutManipulators::PICoutAction  v)

Do some action.

TODO : wondows ClearScreen !!!

◆ saveControls()

PICout & PICout::saveControls ( )

Save control flags to internal stack Saves the current control flags to an internal stack for later restoration using restoreControls().

See also
restoreControls()

◆ restoreControls()

PICout & PICout::restoreControls ( )

Restore control flags from internal stack Restores the control flags from the internal stack that were previously saved using saveControls().

See also
saveControls()

◆ space()

PICout & PICout::space ( )

Conditional put space character to output Conditionally adds a space character to the output if the AddSpaces control flag is enabled.

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 Conditionally adds quote characters to the output if the AddQuotes control flag is enabled.

If control AddQuotes is set quote character is put

See also
space(), newLine()

◆ newLine()

PICout & PICout::newLine ( )

Conditional put new line character to output Conditionally adds a newline character to the output if the AddNewLine control flag is enabled.

If control AddNewLine is set new line character is put

See also
space(), quote()