git-svn-id: svn://db.shs.com.ru/pip@482 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -49,11 +49,11 @@
|
||||
* \snippet picout.cpp own
|
||||
*/
|
||||
|
||||
PIMutex __PICout_mutex__;
|
||||
PIString __PICout_string__;
|
||||
|
||||
using namespace PICoutManipulators;
|
||||
|
||||
PIMutex & PICout::__mutex__() {static PIMutex ret; return ret;}
|
||||
PIString & PICout::__string__() {static PIString ret; return ret;}
|
||||
|
||||
bool PICout::buffer_ = false;
|
||||
|
||||
PRIVATE_DEFINITION_START(PICout)
|
||||
@@ -81,7 +81,7 @@ PICout::PICout(PIFlags<PICoutControl> controls): fo_(true), cc_(false), fc_(fals
|
||||
}
|
||||
attr_ = __Private__::dattr;
|
||||
#endif
|
||||
__PICout_mutex__.lock();
|
||||
PICout::__mutex__().lock();
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ PICout::~PICout() {
|
||||
if (fc_) applyFormat(PICoutManipulators::Default);
|
||||
if (cc_) return;
|
||||
newLine();
|
||||
__PICout_mutex__.unlock();
|
||||
PICout::__mutex__().unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -189,19 +189,21 @@ PICout PICout::operator <<(const PICoutAction v) {
|
||||
}
|
||||
|
||||
|
||||
#define PICOUTTOTARGET(v) {if (PICout::buffer_) __PICout_string__ << (v); else std::cout << (v);}
|
||||
#define PINUMERICCOUT if (cnb_ == 10) PICOUTTOTARGET(v) else PICOUTTOTARGET(PIString::fromNumber(v, cnb_))
|
||||
#define PICOUTTOTARGET(v) {if (PICout::buffer_) PICout::__string__() << (v); else std::cout << (v);}
|
||||
#define PICOUTTOTARGETS(v) {if (PICout::buffer_) PICout::__string__() << (v); else std::cout << (v).dataConsole();}
|
||||
//#define PICOUTTOTARGETS(v) {if (PICout::buffer_) PICout::__string__() << (v); else printf("%s", (v).dataConsole());}
|
||||
#define PINUMERICCOUT if (cnb_ == 10) PICOUTTOTARGET(v) else PICOUTTOTARGETS(PIString::fromNumber(v, cnb_))
|
||||
|
||||
|
||||
PICout PICout::operator <<(const char * v) {if (v[0] == '\0') return *this; space(); quote(); PICOUTTOTARGET(v) quote(); return *this;}
|
||||
|
||||
//PICout PICout::operator <<(const std::string & v) {space(); quote(); if (PICout::buffer_) __PICout_string__ << StdString2PIString(v); else std::cout << (v); quote(); return *this;}
|
||||
//PICout PICout::operator <<(const std::string & v) {space(); quote(); if (PICout::buffer_) PICout::__string__() << StdString2PIString(v); else std::cout << (v); quote(); return *this;}
|
||||
|
||||
PICout PICout::operator <<(const bool v) {space(); if (v) PICOUTTOTARGET("true") else PICOUTTOTARGET("false") return *this;}
|
||||
|
||||
PICout PICout::operator <<(const char v) {space(); PICOUTTOTARGET(v) return *this;}
|
||||
|
||||
PICout PICout::operator <<(const uchar v) {space(); if (cnb_ == 10) PICOUTTOTARGET(ushort(v)) else PICOUTTOTARGET(PIString::fromNumber(v, cnb_)) return *this;}
|
||||
PICout PICout::operator <<(const uchar v) {space(); if (cnb_ == 10) PICOUTTOTARGET(ushort(v)) else PICOUTTOTARGETS(PIString::fromNumber(v, cnb_)) return *this;}
|
||||
|
||||
PICout PICout::operator <<(const short int v) {space(); PINUMERICCOUT return *this;}
|
||||
|
||||
@@ -223,7 +225,7 @@ PICout PICout::operator <<(const float v) {space(); PICOUTTOTARGET(v) return *th
|
||||
|
||||
PICout PICout::operator <<(const double v) {space(); PICOUTTOTARGET(v) return *this;}
|
||||
|
||||
PICout PICout::operator <<(const void * v) {space(); PICOUTTOTARGET("0x") PICOUTTOTARGET(PIString::fromNumber(ullong(v), 16)) return *this;}
|
||||
PICout PICout::operator <<(const void * v) {space(); PICOUTTOTARGET("0x") PICOUTTOTARGETS(PIString::fromNumber(ullong(v), 16)) return *this;}
|
||||
|
||||
PICout PICout::operator <<(const PIObject * v) {
|
||||
space();
|
||||
@@ -231,7 +233,7 @@ PICout PICout::operator <<(const PIObject * v) {
|
||||
else {
|
||||
PICOUTTOTARGET(v->className())
|
||||
PICOUTTOTARGET("*(0x")
|
||||
PICOUTTOTARGET(PIString::fromNumber(ullong(v), 16))
|
||||
PICOUTTOTARGETS(PIString::fromNumber(ullong(v), 16))
|
||||
PICOUTTOTARGET(", \"")
|
||||
PICOUTTOTARGET(v->name())
|
||||
PICOUTTOTARGET("\")")
|
||||
@@ -242,29 +244,29 @@ PICout PICout::operator <<(const PIObject * v) {
|
||||
PICout PICout::operator <<(const PICoutSpecialChar v) {
|
||||
switch (v) {
|
||||
case Null:
|
||||
if (PICout::buffer_) __PICout_string__ << PIChar(0);
|
||||
if (PICout::buffer_) PICout::__string__() << PIChar(0);
|
||||
else std::cout << char(0);
|
||||
break;
|
||||
case NewLine:
|
||||
if (PICout::buffer_) __PICout_string__ << "\n";
|
||||
if (PICout::buffer_) PICout::__string__() << "\n";
|
||||
else std::cout << '\n';
|
||||
fo_ = true;
|
||||
break;
|
||||
case Tab:
|
||||
if (PICout::buffer_) __PICout_string__ << "\t";
|
||||
if (PICout::buffer_) PICout::__string__() << "\t";
|
||||
else std::cout << '\t';
|
||||
break;
|
||||
case Esc:
|
||||
#ifdef CC_VC
|
||||
if (PICout::buffer_) __PICout_string__ << PIChar(27);
|
||||
if (PICout::buffer_) PICout::__string__() << PIChar(27);
|
||||
else std::cout << char(27);
|
||||
#else
|
||||
if (PICout::buffer_) __PICout_string__ << "\e";
|
||||
if (PICout::buffer_) PICout::__string__() << "\e";
|
||||
else std::cout << '\e';
|
||||
#endif
|
||||
break;
|
||||
case Quote:
|
||||
if (PICout::buffer_) __PICout_string__ << "\"";
|
||||
if (PICout::buffer_) PICout::__string__() << "\"";
|
||||
else std::cout << '"';
|
||||
break;
|
||||
};
|
||||
@@ -292,7 +294,7 @@ PICout & PICout::restoreControl() {
|
||||
|
||||
PICout & PICout::space() {
|
||||
if (!fo_ && co_[AddSpaces]) {
|
||||
if (PICout::buffer_) __PICout_string__ << " ";
|
||||
if (PICout::buffer_) PICout::__string__() << " ";
|
||||
else std::cout << ' ';
|
||||
}
|
||||
fo_ = false;
|
||||
@@ -301,7 +303,7 @@ PICout & PICout::space() {
|
||||
|
||||
PICout & PICout::quote() {
|
||||
if (co_[AddQuotes]) {
|
||||
if (PICout::buffer_) __PICout_string__ << "\"";
|
||||
if (PICout::buffer_) PICout::__string__() << "\"";
|
||||
else std::cout << '"';
|
||||
}
|
||||
fo_ = false;
|
||||
@@ -310,7 +312,7 @@ PICout & PICout::quote() {
|
||||
|
||||
PICout & PICout::newLine() {
|
||||
if (co_[AddNewLine]) {
|
||||
if (PICout::buffer_) __PICout_string__ << "\n";
|
||||
if (PICout::buffer_) PICout::__string__() << "\n";
|
||||
else std::cout << std::endl;
|
||||
}
|
||||
fo_ = false;
|
||||
@@ -380,9 +382,9 @@ void PICout::applyFormat(PICoutFormat f) {
|
||||
|
||||
|
||||
bool PICout::setBufferActive(bool on, bool clear) {
|
||||
PIMutexLocker ml(__PICout_mutex__);
|
||||
PIMutexLocker ml(PICout::__mutex__());
|
||||
bool ret = PICout::buffer_;
|
||||
if (clear) __PICout_string__.clear();
|
||||
if (clear) PICout::__string__().clear();
|
||||
PICout::buffer_ = on;
|
||||
return ret;
|
||||
}
|
||||
@@ -394,14 +396,14 @@ bool PICout::isBufferActive() {
|
||||
|
||||
|
||||
PIString PICout::buffer(bool clear) {
|
||||
PIMutexLocker ml(__PICout_mutex__);
|
||||
PIString ret = __PICout_string__;
|
||||
if (clear) __PICout_string__.clear();
|
||||
PIMutexLocker ml(PICout::__mutex__());
|
||||
PIString ret = PICout::__string__();
|
||||
if (clear) PICout::__string__().clear();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void PICout::clearBuffer() {
|
||||
PIMutexLocker ml(__PICout_mutex__);
|
||||
__PICout_string__.clear();
|
||||
PIMutexLocker ml(PICout::__mutex__());
|
||||
PICout::__string__().clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user