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;}
|
EVENT_HANDLER1(void, eh1, float, f) {piCout << "eh1" << f;}
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc < 2) return 0;
|
if (argc < 2) return 0;
|
||||||
@@ -63,6 +64,7 @@ int main(int argc, char *argv[]) {
|
|||||||
PIByteArray rb(4);
|
PIByteArray rb(4);
|
||||||
int rd = shm.read(rb.data(), rb.size_s());
|
int rd = shm.read(rb.data(), rb.size_s());
|
||||||
piCout << "readed" << rd << PIString(rb);
|
piCout << "readed" << rd << PIString(rb);
|
||||||
|
|
||||||
// PIFFTWf fft;
|
// PIFFTWf fft;
|
||||||
// fft.preparePlan(50, PIFFTWf::foReal);
|
// fft.preparePlan(50, PIFFTWf::foReal);
|
||||||
// PIVector<complexf> out = fft.calcFFT(in);
|
// PIVector<complexf> out = fft.calcFFT(in);
|
||||||
|
|||||||
@@ -57,9 +57,6 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
extern PIMutex __PICout_mutex__;
|
|
||||||
|
|
||||||
|
|
||||||
PRIVATE_DEFINITION_START(PIConsole)
|
PRIVATE_DEFINITION_START(PIConsole)
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
void getWinCurCoord() {GetConsoleScreenBufferInfo(hOut, &csbi); ccoord = csbi.dwCursorPosition;}
|
void getWinCurCoord() {GetConsoleScreenBufferInfo(hOut, &csbi); ccoord = csbi.dwCursorPosition;}
|
||||||
@@ -198,11 +195,11 @@ bool PIConsole::setTab(uint index) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
lock();
|
lock();
|
||||||
__PICout_mutex__.lock();
|
PICout::__mutex__().lock();
|
||||||
cur_tab = index;
|
cur_tab = index;
|
||||||
clearScreen();
|
clearScreen();
|
||||||
fillLabels();
|
fillLabels();
|
||||||
__PICout_mutex__.unlock();
|
PICout::__mutex__().unlock();
|
||||||
unlock();
|
unlock();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -531,11 +528,11 @@ void PIConsole::begin() {
|
|||||||
SetConsoleMode(PRIVATE->hOut, ENABLE_WRAP_AT_EOL_OUTPUT);
|
SetConsoleMode(PRIVATE->hOut, ENABLE_WRAP_AT_EOL_OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
max_y = 0;
|
max_y = 0;
|
||||||
__PICout_mutex__.lock();
|
PICout::__mutex__().lock();
|
||||||
clearScreen();
|
clearScreen();
|
||||||
hideCursor();
|
hideCursor();
|
||||||
fillLabels();
|
fillLabels();
|
||||||
__PICout_mutex__.unlock();
|
PICout::__mutex__().unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -554,7 +551,7 @@ void PIConsole::run() {
|
|||||||
height = ws.ws_row;
|
height = ws.ws_row;
|
||||||
#endif
|
#endif
|
||||||
//fflush(0); return;
|
//fflush(0); return;
|
||||||
__PICout_mutex__.lock();
|
PICout::__mutex__().lock();
|
||||||
if (pwidth != width || pheight != height) {
|
if (pwidth != width || pheight != height) {
|
||||||
clearScreen();
|
clearScreen();
|
||||||
fillLabels();
|
fillLabels();
|
||||||
@@ -626,7 +623,7 @@ void PIConsole::run() {
|
|||||||
moveTo(0, max_y + 2);
|
moveTo(0, max_y + 2);
|
||||||
#endif
|
#endif
|
||||||
fflush(0);
|
fflush(0);
|
||||||
__PICout_mutex__.unlock();
|
PICout::__mutex__().unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,6 @@
|
|||||||
|
|
||||||
using namespace PIScreenTypes;
|
using namespace PIScreenTypes;
|
||||||
|
|
||||||
extern PIMutex __PICout_mutex__;
|
|
||||||
|
|
||||||
|
|
||||||
PRIVATE_DEFINITION_START(PIScreen::SystemConsole)
|
PRIVATE_DEFINITION_START(PIScreen::SystemConsole)
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//extern PIMutex __PICout_mutex__;
|
//extern PIMutex PICout::__mutex__;
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
# define PIPE_BUFFER_SIZE 1024
|
# define PIPE_BUFFER_SIZE 1024
|
||||||
|
|||||||
@@ -49,11 +49,11 @@
|
|||||||
* \snippet picout.cpp own
|
* \snippet picout.cpp own
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PIMutex __PICout_mutex__;
|
|
||||||
PIString __PICout_string__;
|
|
||||||
|
|
||||||
using namespace PICoutManipulators;
|
using namespace PICoutManipulators;
|
||||||
|
|
||||||
|
PIMutex & PICout::__mutex__() {static PIMutex ret; return ret;}
|
||||||
|
PIString & PICout::__string__() {static PIString ret; return ret;}
|
||||||
|
|
||||||
bool PICout::buffer_ = false;
|
bool PICout::buffer_ = false;
|
||||||
|
|
||||||
PRIVATE_DEFINITION_START(PICout)
|
PRIVATE_DEFINITION_START(PICout)
|
||||||
@@ -81,7 +81,7 @@ PICout::PICout(PIFlags<PICoutControl> controls): fo_(true), cc_(false), fc_(fals
|
|||||||
}
|
}
|
||||||
attr_ = __Private__::dattr;
|
attr_ = __Private__::dattr;
|
||||||
#endif
|
#endif
|
||||||
__PICout_mutex__.lock();
|
PICout::__mutex__().lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ PICout::~PICout() {
|
|||||||
if (fc_) applyFormat(PICoutManipulators::Default);
|
if (fc_) applyFormat(PICoutManipulators::Default);
|
||||||
if (cc_) return;
|
if (cc_) return;
|
||||||
newLine();
|
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 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 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 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 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 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;}
|
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 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) {
|
PICout PICout::operator <<(const PIObject * v) {
|
||||||
space();
|
space();
|
||||||
@@ -231,7 +233,7 @@ PICout PICout::operator <<(const PIObject * v) {
|
|||||||
else {
|
else {
|
||||||
PICOUTTOTARGET(v->className())
|
PICOUTTOTARGET(v->className())
|
||||||
PICOUTTOTARGET("*(0x")
|
PICOUTTOTARGET("*(0x")
|
||||||
PICOUTTOTARGET(PIString::fromNumber(ullong(v), 16))
|
PICOUTTOTARGETS(PIString::fromNumber(ullong(v), 16))
|
||||||
PICOUTTOTARGET(", \"")
|
PICOUTTOTARGET(", \"")
|
||||||
PICOUTTOTARGET(v->name())
|
PICOUTTOTARGET(v->name())
|
||||||
PICOUTTOTARGET("\")")
|
PICOUTTOTARGET("\")")
|
||||||
@@ -242,29 +244,29 @@ PICout PICout::operator <<(const PIObject * v) {
|
|||||||
PICout PICout::operator <<(const PICoutSpecialChar v) {
|
PICout PICout::operator <<(const PICoutSpecialChar v) {
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case Null:
|
case Null:
|
||||||
if (PICout::buffer_) __PICout_string__ << PIChar(0);
|
if (PICout::buffer_) PICout::__string__() << PIChar(0);
|
||||||
else std::cout << char(0);
|
else std::cout << char(0);
|
||||||
break;
|
break;
|
||||||
case NewLine:
|
case NewLine:
|
||||||
if (PICout::buffer_) __PICout_string__ << "\n";
|
if (PICout::buffer_) PICout::__string__() << "\n";
|
||||||
else std::cout << '\n';
|
else std::cout << '\n';
|
||||||
fo_ = true;
|
fo_ = true;
|
||||||
break;
|
break;
|
||||||
case Tab:
|
case Tab:
|
||||||
if (PICout::buffer_) __PICout_string__ << "\t";
|
if (PICout::buffer_) PICout::__string__() << "\t";
|
||||||
else std::cout << '\t';
|
else std::cout << '\t';
|
||||||
break;
|
break;
|
||||||
case Esc:
|
case Esc:
|
||||||
#ifdef CC_VC
|
#ifdef CC_VC
|
||||||
if (PICout::buffer_) __PICout_string__ << PIChar(27);
|
if (PICout::buffer_) PICout::__string__() << PIChar(27);
|
||||||
else std::cout << char(27);
|
else std::cout << char(27);
|
||||||
#else
|
#else
|
||||||
if (PICout::buffer_) __PICout_string__ << "\e";
|
if (PICout::buffer_) PICout::__string__() << "\e";
|
||||||
else std::cout << '\e';
|
else std::cout << '\e';
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case Quote:
|
case Quote:
|
||||||
if (PICout::buffer_) __PICout_string__ << "\"";
|
if (PICout::buffer_) PICout::__string__() << "\"";
|
||||||
else std::cout << '"';
|
else std::cout << '"';
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@@ -292,7 +294,7 @@ PICout & PICout::restoreControl() {
|
|||||||
|
|
||||||
PICout & PICout::space() {
|
PICout & PICout::space() {
|
||||||
if (!fo_ && co_[AddSpaces]) {
|
if (!fo_ && co_[AddSpaces]) {
|
||||||
if (PICout::buffer_) __PICout_string__ << " ";
|
if (PICout::buffer_) PICout::__string__() << " ";
|
||||||
else std::cout << ' ';
|
else std::cout << ' ';
|
||||||
}
|
}
|
||||||
fo_ = false;
|
fo_ = false;
|
||||||
@@ -301,7 +303,7 @@ PICout & PICout::space() {
|
|||||||
|
|
||||||
PICout & PICout::quote() {
|
PICout & PICout::quote() {
|
||||||
if (co_[AddQuotes]) {
|
if (co_[AddQuotes]) {
|
||||||
if (PICout::buffer_) __PICout_string__ << "\"";
|
if (PICout::buffer_) PICout::__string__() << "\"";
|
||||||
else std::cout << '"';
|
else std::cout << '"';
|
||||||
}
|
}
|
||||||
fo_ = false;
|
fo_ = false;
|
||||||
@@ -310,7 +312,7 @@ PICout & PICout::quote() {
|
|||||||
|
|
||||||
PICout & PICout::newLine() {
|
PICout & PICout::newLine() {
|
||||||
if (co_[AddNewLine]) {
|
if (co_[AddNewLine]) {
|
||||||
if (PICout::buffer_) __PICout_string__ << "\n";
|
if (PICout::buffer_) PICout::__string__() << "\n";
|
||||||
else std::cout << std::endl;
|
else std::cout << std::endl;
|
||||||
}
|
}
|
||||||
fo_ = false;
|
fo_ = false;
|
||||||
@@ -380,9 +382,9 @@ void PICout::applyFormat(PICoutFormat f) {
|
|||||||
|
|
||||||
|
|
||||||
bool PICout::setBufferActive(bool on, bool clear) {
|
bool PICout::setBufferActive(bool on, bool clear) {
|
||||||
PIMutexLocker ml(__PICout_mutex__);
|
PIMutexLocker ml(PICout::__mutex__());
|
||||||
bool ret = PICout::buffer_;
|
bool ret = PICout::buffer_;
|
||||||
if (clear) __PICout_string__.clear();
|
if (clear) PICout::__string__().clear();
|
||||||
PICout::buffer_ = on;
|
PICout::buffer_ = on;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -394,14 +396,14 @@ bool PICout::isBufferActive() {
|
|||||||
|
|
||||||
|
|
||||||
PIString PICout::buffer(bool clear) {
|
PIString PICout::buffer(bool clear) {
|
||||||
PIMutexLocker ml(__PICout_mutex__);
|
PIMutexLocker ml(PICout::__mutex__());
|
||||||
PIString ret = __PICout_string__;
|
PIString ret = PICout::__string__();
|
||||||
if (clear) __PICout_string__.clear();
|
if (clear) PICout::__string__().clear();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PICout::clearBuffer() {
|
void PICout::clearBuffer() {
|
||||||
PIMutexLocker ml(__PICout_mutex__);
|
PIMutexLocker ml(PICout::__mutex__());
|
||||||
__PICout_string__.clear();
|
PICout::__string__().clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,6 @@
|
|||||||
# define piCoutObj if (piDebug && debug()) PICout() << "" << (PIString("[") + className() + " \"" + name() + "\"]")
|
# define piCoutObj if (piDebug && debug()) PICout() << "" << (PIString("[") + className() + " \"" + name() + "\"]")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern PIMutex __PICout_mutex__;
|
|
||||||
extern PIString __PICout_string__;
|
|
||||||
|
|
||||||
//! \brief Namespace contains enums controlled PICout
|
//! \brief Namespace contains enums controlled PICout
|
||||||
namespace PICoutManipulators {
|
namespace PICoutManipulators {
|
||||||
@@ -251,6 +249,9 @@ public:
|
|||||||
static PIString buffer(bool clear = false);
|
static PIString buffer(bool clear = false);
|
||||||
static void clearBuffer();
|
static void clearBuffer();
|
||||||
|
|
||||||
|
static PIMutex & __mutex__();
|
||||||
|
static PIString & __string__();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applyFormat(PICoutManipulators::PICoutFormat f);
|
void applyFormat(PICoutManipulators::PICoutFormat f);
|
||||||
|
|
||||||
|
|||||||
@@ -181,7 +181,8 @@ PIInit::PIInit() {
|
|||||||
memset(__sysoemname__, 0, 256);
|
memset(__sysoemname__, 0, 256);
|
||||||
memcpy(__sysoemname__, "ibm-", 4);
|
memcpy(__sysoemname__, "ibm-", 4);
|
||||||
memcpy(&(__sysoemname__[4]), cpinfo.CodePageName, l);
|
memcpy(&(__sysoemname__[4]), cpinfo.CodePageName, l);
|
||||||
//piCout << cpinfo.CodePageName;
|
uint ccp = GetConsoleCP();
|
||||||
|
printf("%i\n", ccp);
|
||||||
# else
|
# else
|
||||||
/*PIString en(getenv("LANG"));
|
/*PIString en(getenv("LANG"));
|
||||||
if (!en.isEmpty())
|
if (!en.isEmpty())
|
||||||
|
|||||||
@@ -1024,7 +1024,12 @@ PICout operator <<(PICout s, const PIString & v) {
|
|||||||
if (PICout::isBufferActive())
|
if (PICout::isBufferActive())
|
||||||
s << v.data();
|
s << v.data();
|
||||||
else
|
else
|
||||||
s << v.dataConsole();
|
s <<
|
||||||
|
#ifdef WINDOWS
|
||||||
|
(const char*)v.toByteArray().data();
|
||||||
|
#else
|
||||||
|
v.dataConsole;
|
||||||
|
#endif
|
||||||
s.restoreControl();
|
s.restoreControl();
|
||||||
s.quote();
|
s.quote();
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
Reference in New Issue
Block a user