56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
#include "pip.h"
|
|
|
|
//! [own]
|
|
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;
|
|
}
|
|
//! [own]
|
|
|
|
void _() {
|
|
|
|
//! [0]
|
|
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"
|
|
//! [0]
|
|
|
|
}
|
|
|
|
|
|
//! [notifier]
|
|
class A: public PIObject {
|
|
PIOBJECT(A)
|
|
public:
|
|
A() {}
|
|
EVENT_HANDLER2(void, pcf, int, id, PIString*, buff) {
|
|
piCout << "PICout(" << id << ") finished:" << (*buff);
|
|
}
|
|
};
|
|
int main() {
|
|
A a;
|
|
CONNECTU(PICout::Notifier::object(), finished, &a, pcf);
|
|
PIString buffer = "my buff:";
|
|
PICout(&buffer, 1) << "int 10 ->" << 10 << ", time ->" << PITime::current();
|
|
return 0;
|
|
}
|
|
// PICout( 1 ) finished: my buff:int 10 -> 10 , time -> PITime(14:07:09:000)
|
|
//! [notifier]
|