PICout optimization
This commit is contained in:
@@ -155,11 +155,7 @@ WORD PICout::__Private__::dattr = 0;
|
||||
DWORD PICout::__Private__::smode = 0;
|
||||
#endif
|
||||
|
||||
PICout::PICout(PIFlags<PICoutControl> controls): fo_(true), cc_(false), fc_(false), act_(true), cnb_(10), co_(controls) {
|
||||
init();
|
||||
}
|
||||
|
||||
PICout::PICout(PICoutControl control): fo_(true), cc_(false), fc_(false), act_(true), cnb_(10), co_(control) {
|
||||
PICout::PICout(int controls): fo_(true), cc_(false), fc_(false), act_(true), cnb_(10), co_(controls) {
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -323,7 +319,7 @@ PICout PICout::operator <<(const PIFlags<PICoutManipulators::PICoutFormat> & v)
|
||||
}
|
||||
|
||||
|
||||
#define PICOUTTOTARGET(v) { \
|
||||
#define PICOUTTOTARGET(v) { \
|
||||
if (buffer_) {\
|
||||
(*buffer_) << (v);\
|
||||
} else {\
|
||||
@@ -331,15 +327,14 @@ PICout PICout::operator <<(const PIFlags<PICoutManipulators::PICoutFormat> & v)
|
||||
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() << (v);\
|
||||
}\
|
||||
}
|
||||
#define PICOUTTOTARGETS(v) { \
|
||||
if (buffer_) {\
|
||||
(*buffer_) << (v);\
|
||||
} else {\
|
||||
if (PICout::isOutputDeviceActive(PICout::StdOut)) std::cout << (v).dataConsole();\
|
||||
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() << (v);\
|
||||
}\
|
||||
|
||||
#define PINUMERICCOUT(v) { \
|
||||
if (!act_) return *this; \
|
||||
space(); \
|
||||
if (cnb_ == 10) PICOUTTOTARGET(v) \
|
||||
else writePIString(PIString::fromNumber(v, cnb_)); \
|
||||
return *this; \
|
||||
}
|
||||
#define PINUMERICCOUT if (cnb_ == 10) PICOUTTOTARGET(v) else PICOUTTOTARGETS(PIString::fromNumber(v, cnb_))
|
||||
|
||||
|
||||
PICout PICout::operator <<(const char * v) {if (!act_) return *this; if (v[0] == '\0') return *this; space(); quote(); PICOUTTOTARGET(v) quote(); return *this;}
|
||||
@@ -348,29 +343,29 @@ PICout PICout::operator <<(const bool v) {if (!act_) return *this; space(); if (
|
||||
|
||||
PICout PICout::operator <<(const char v) {if (!act_) return *this; space(); PICOUTTOTARGET(v) return *this;}
|
||||
|
||||
PICout PICout::operator <<(const uchar v) {if (!act_) return *this; space(); if (cnb_ == 10) PICOUTTOTARGET(ushort(v)) else PICOUTTOTARGETS(PIString::fromNumber(v, cnb_)) return *this;}
|
||||
PICout PICout::operator <<(const uchar v) {PINUMERICCOUT(ushort(v))}
|
||||
|
||||
PICout PICout::operator <<(const short int v) {if (!act_) return *this; space(); PINUMERICCOUT return *this;}
|
||||
PICout PICout::operator <<(const short int v) {PINUMERICCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const ushort v) {if (!act_) return *this; space(); PINUMERICCOUT return *this;}
|
||||
PICout PICout::operator <<(const ushort v) {PINUMERICCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const int v) {if (!act_) return *this; space(); PINUMERICCOUT return *this;}
|
||||
PICout PICout::operator <<(const int v) {PINUMERICCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const uint v) {if (!act_) return *this; space(); PINUMERICCOUT return *this;}
|
||||
PICout PICout::operator <<(const uint v) {PINUMERICCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const long v) {if (!act_) return *this; space(); PINUMERICCOUT return *this;}
|
||||
PICout PICout::operator <<(const long v) {PINUMERICCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const ulong v) {if (!act_) return *this; space(); PINUMERICCOUT return *this;}
|
||||
PICout PICout::operator <<(const ulong v) {PINUMERICCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const llong v) {if (!act_) return *this; space(); PINUMERICCOUT return *this;}
|
||||
PICout PICout::operator <<(const llong v) {PINUMERICCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const ullong v) {if (!act_) return *this; space(); PINUMERICCOUT return *this;}
|
||||
PICout PICout::operator <<(const ullong v) {PINUMERICCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const float v) {if (!act_) return *this; space(); PICOUTTOTARGET(v) return *this;}
|
||||
|
||||
PICout PICout::operator <<(const double v) {if (!act_) return *this; space(); PICOUTTOTARGET(v) return *this;}
|
||||
|
||||
PICout PICout::operator <<(const void * v) {if (!act_) return *this; space(); PICOUTTOTARGET("0x") PICOUTTOTARGETS(PIString::fromNumber(ullong(v), 16)) return *this;}
|
||||
PICout PICout::operator <<(const void * v) {if (!act_) return *this; space(); PICOUTTOTARGET("0x") writePIString(PIString::fromNumber(ullong(v), 16)); return *this;}
|
||||
|
||||
PICout PICout::operator <<(const PIObject * v) {
|
||||
if (!act_) return *this;
|
||||
@@ -379,9 +374,9 @@ PICout PICout::operator <<(const PIObject * v) {
|
||||
else {
|
||||
PICOUTTOTARGET(v->className())
|
||||
PICOUTTOTARGET("*(0x")
|
||||
PICOUTTOTARGETS(PIString::fromNumber(ullong(v), 16))
|
||||
writePIString(PIString::fromNumber(ullong(v), 16));
|
||||
PICOUTTOTARGET(", \"")
|
||||
PICOUTTOTARGET(v->name())
|
||||
writePIString(v->name());
|
||||
PICOUTTOTARGET("\")")
|
||||
}
|
||||
return *this;
|
||||
@@ -526,6 +521,30 @@ PICout & PICout::newLine() {
|
||||
}
|
||||
|
||||
|
||||
PICout & PICout::write(const char * str, int len) {
|
||||
if (buffer_) {
|
||||
buffer_->append(PIString(str, len));
|
||||
} else {
|
||||
if (PICout::isOutputDeviceActive(PICout::StdOut)) std::cout.write(str, len);
|
||||
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__().append(PIString(str, len));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
PICout & PICout::writePIString(const PIString & s) {
|
||||
if (buffer_) {
|
||||
buffer_->append(s);
|
||||
} else {
|
||||
if (PICout::isOutputDeviceActive(PICout::StdOut)) {
|
||||
for (const PIChar & c: s) std::wcout.put(c.toWChar());
|
||||
}
|
||||
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__().append(s);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void PICout::init() {
|
||||
#ifdef WINDOWS
|
||||
if (__Private__::hOut == 0) {
|
||||
|
||||
Reference in New Issue
Block a user