git-svn-id: svn://db.shs.com.ru/pip@482 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2
main.cpp
2
main.cpp
@@ -46,6 +46,7 @@ public:
|
||||
EVENT_HANDLER1(void, eh1, float, f) {piCout << "eh1" << f;}
|
||||
};
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 2) return 0;
|
||||
@@ -63,6 +64,7 @@ int main(int argc, char *argv[]) {
|
||||
PIByteArray rb(4);
|
||||
int rd = shm.read(rb.data(), rb.size_s());
|
||||
piCout << "readed" << rd << PIString(rb);
|
||||
|
||||
// PIFFTWf fft;
|
||||
// fft.preparePlan(50, PIFFTWf::foReal);
|
||||
// PIVector<complexf> out = fft.calcFFT(in);
|
||||
|
||||
@@ -57,9 +57,6 @@
|
||||
**/
|
||||
|
||||
|
||||
extern PIMutex __PICout_mutex__;
|
||||
|
||||
|
||||
PRIVATE_DEFINITION_START(PIConsole)
|
||||
#ifdef WINDOWS
|
||||
void getWinCurCoord() {GetConsoleScreenBufferInfo(hOut, &csbi); ccoord = csbi.dwCursorPosition;}
|
||||
@@ -198,11 +195,11 @@ bool PIConsole::setTab(uint index) {
|
||||
return true;
|
||||
}
|
||||
lock();
|
||||
__PICout_mutex__.lock();
|
||||
PICout::__mutex__().lock();
|
||||
cur_tab = index;
|
||||
clearScreen();
|
||||
fillLabels();
|
||||
__PICout_mutex__.unlock();
|
||||
PICout::__mutex__().unlock();
|
||||
unlock();
|
||||
return true;
|
||||
}
|
||||
@@ -531,11 +528,11 @@ void PIConsole::begin() {
|
||||
SetConsoleMode(PRIVATE->hOut, ENABLE_WRAP_AT_EOL_OUTPUT);
|
||||
#endif
|
||||
max_y = 0;
|
||||
__PICout_mutex__.lock();
|
||||
PICout::__mutex__().lock();
|
||||
clearScreen();
|
||||
hideCursor();
|
||||
fillLabels();
|
||||
__PICout_mutex__.unlock();
|
||||
PICout::__mutex__().unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -554,7 +551,7 @@ void PIConsole::run() {
|
||||
height = ws.ws_row;
|
||||
#endif
|
||||
//fflush(0); return;
|
||||
__PICout_mutex__.lock();
|
||||
PICout::__mutex__().lock();
|
||||
if (pwidth != width || pheight != height) {
|
||||
clearScreen();
|
||||
fillLabels();
|
||||
@@ -626,7 +623,7 @@ void PIConsole::run() {
|
||||
moveTo(0, max_y + 2);
|
||||
#endif
|
||||
fflush(0);
|
||||
__PICout_mutex__.unlock();
|
||||
PICout::__mutex__().unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
|
||||
using namespace PIScreenTypes;
|
||||
|
||||
extern PIMutex __PICout_mutex__;
|
||||
|
||||
|
||||
PRIVATE_DEFINITION_START(PIScreen::SystemConsole)
|
||||
#ifdef WINDOWS
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
//extern PIMutex __PICout_mutex__;
|
||||
//extern PIMutex PICout::__mutex__;
|
||||
|
||||
#ifdef WINDOWS
|
||||
# define PIPE_BUFFER_SIZE 1024
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
# define piCoutObj if (piDebug && debug()) PICout() << "" << (PIString("[") + className() + " \"" + name() + "\"]")
|
||||
#endif
|
||||
|
||||
extern PIMutex __PICout_mutex__;
|
||||
extern PIString __PICout_string__;
|
||||
|
||||
//! \brief Namespace contains enums controlled PICout
|
||||
namespace PICoutManipulators {
|
||||
@@ -251,6 +249,9 @@ public:
|
||||
static PIString buffer(bool clear = false);
|
||||
static void clearBuffer();
|
||||
|
||||
static PIMutex & __mutex__();
|
||||
static PIString & __string__();
|
||||
|
||||
private:
|
||||
void applyFormat(PICoutManipulators::PICoutFormat f);
|
||||
|
||||
|
||||
@@ -181,7 +181,8 @@ PIInit::PIInit() {
|
||||
memset(__sysoemname__, 0, 256);
|
||||
memcpy(__sysoemname__, "ibm-", 4);
|
||||
memcpy(&(__sysoemname__[4]), cpinfo.CodePageName, l);
|
||||
//piCout << cpinfo.CodePageName;
|
||||
uint ccp = GetConsoleCP();
|
||||
printf("%i\n", ccp);
|
||||
# else
|
||||
/*PIString en(getenv("LANG"));
|
||||
if (!en.isEmpty())
|
||||
|
||||
@@ -1024,7 +1024,12 @@ PICout operator <<(PICout s, const PIString & v) {
|
||||
if (PICout::isBufferActive())
|
||||
s << v.data();
|
||||
else
|
||||
s << v.dataConsole();
|
||||
s <<
|
||||
#ifdef WINDOWS
|
||||
(const char*)v.toByteArray().data();
|
||||
#else
|
||||
v.dataConsole;
|
||||
#endif
|
||||
s.restoreControl();
|
||||
s.quote();
|
||||
return s;
|
||||
|
||||
Reference in New Issue
Block a user