PICout refactoring, new SHSTKMacros

This commit is contained in:
2022-08-07 22:07:26 +03:00
parent 1eaecb288f
commit 8551499a5e
36 changed files with 106 additions and 106 deletions

View File

@@ -20,12 +20,7 @@ main library
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
include(SHSTKMacros) include(SHSTKMacros)
shstk_set_find_dirs(pip) shstk_set_find_dirs(pip PIP)
if(PIP_DIR)
list(APPEND pip_LIBDIR "${PIP_DIR}/lib")
list(APPEND pip_INCDIR "${PIP_DIR}/include/pip")
list(APPEND pip_BINDIR "${PIP_DIR}/bin")
endif()
set(__libs "usb;crypt;console;fftw;compress;io_utils;opencl;cloud;lua") set(__libs "usb;crypt;console;fftw;compress;io_utils;opencl;cloud;lua")

View File

@@ -4,7 +4,7 @@
inline PICout operator <<(PICout s, const PIByteArray & ba) { inline PICout operator <<(PICout s, const PIByteArray & ba) {
s.space(); // insert space after previous output s.space(); // insert space after previous output
s.quote(); // ONLY if you want to quoted your type s.quote(); // ONLY if you want to quoted your type
s.setControl(0, true); // clear all features and s.saveAndSetControls(0); // clear all features and
// save them to stack, // save them to stack,
// now it`s behavior similar to std::cout // now it`s behavior similar to std::cout
@@ -12,7 +12,7 @@ inline PICout operator <<(PICout s, const PIByteArray & ba) {
for (uint i = 0; i < ba.size(); ++i) for (uint i = 0; i < ba.size(); ++i)
s << ba[i]; s << ba[i];
s.restoreControl(); // restore features from stack s.restoreControls(); // restore features from stack
s.quote(); // ONLY if you want to quoted your type s.quote(); // ONLY if you want to quoted your type
return s; return s;
} }

View File

@@ -538,12 +538,11 @@ TilePICout::TilePICout(const PIString & n): TileList(n) {
max_lines = 1024; max_lines = 1024;
selection_mode = TileList::SingleSelection; selection_mode = TileList::SingleSelection;
PICout::setOutputDevices(PICout::Buffer); PICout::setOutputDevices(PICout::Buffer);
PICout::setBufferActive(true);
} }
void TilePICout::drawEvent(PIScreenDrawer * d) { void TilePICout::drawEvent(PIScreenDrawer * d) {
PIString out = PICout::buffer(true); PIString out = PICout::getBufferAndClear();
if (!out.isEmpty()) { if (!out.isEmpty()) {
PIStringList l = out.split("\n"); PIStringList l = out.split("\n");
bool scroll = (cur == content.size_s() - 1) || !has_focus; bool scroll = (cur == content.size_s() - 1) || !has_focus;

View File

@@ -218,7 +218,7 @@ inline PICout operator <<(PICout s, const PICodeInfo::TypeInfo & v) {
inline PICout operator <<(PICout s, const PICodeInfo::EnumeratorInfo & v) {s << v.name << " = " << v.value << " Meta" << v.meta; return s;} inline PICout operator <<(PICout s, const PICodeInfo::EnumeratorInfo & v) {s << v.name << " = " << v.value << " Meta" << v.meta; return s;}
inline PICout operator <<(PICout s, const PICodeInfo::ClassInfo & v) { inline PICout operator <<(PICout s, const PICodeInfo::ClassInfo & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << "class " << v.name; s << "class " << v.name;
if (!v.parents.isEmpty()) { if (!v.parents.isEmpty()) {
s << ": "; s << ": ";
@@ -246,12 +246,12 @@ inline PICout operator <<(PICout s, const PICodeInfo::ClassInfo & v) {
s << PICoutManipulators::Tab << i << " Meta" << i.meta << ";\n"; s << PICoutManipulators::Tab << i << " Meta" << i.meta << ";\n";
} }
s << "}\n"; s << "}\n";
s.restoreControl(); s.restoreControls();
return s; return s;
} }
inline PICout operator <<(PICout s, const PICodeInfo::EnumInfo & v) { inline PICout operator <<(PICout s, const PICodeInfo::EnumInfo & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << "enum " << v.name << " Meta" << v.meta << " {\n"; s << "enum " << v.name << " Meta" << v.meta << " {\n";
for (const auto & i: v.members) { for (const auto & i: v.members) {
bool f = true; bool f = true;
@@ -260,7 +260,7 @@ inline PICout operator <<(PICout s, const PICodeInfo::EnumInfo & v) {
s << PICoutManipulators::Tab << i << "\n"; s << PICoutManipulators::Tab << i << "\n";
} }
s << "}\n"; s << "}\n";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -2439,14 +2439,14 @@ inline std::ostream & operator <<(std::ostream & s, const PIDeque<T> & v) {
template<typename T> template<typename T>
inline PICout operator <<(PICout s, const PIDeque<T> & v) { inline PICout operator <<(PICout s, const PIDeque<T> & v) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
s << "{"; s << "{";
for (size_t i = 0; i < v.size(); ++i) { for (size_t i = 0; i < v.size(); ++i) {
s << v[i]; s << v[i];
if (i < v.size() - 1) s << ", "; if (i < v.size() - 1) s << ", ";
} }
s << "}"; s << "}";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -845,7 +845,7 @@ inline std::ostream & operator <<(std::ostream & s, const PIMap<Key, Type> & v)
template<typename Key, typename Type> template<typename Key, typename Type>
inline PICout operator <<(PICout s, const PIMap<Key, Type> & v) { inline PICout operator <<(PICout s, const PIMap<Key, Type> & v) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
s << "{"; s << "{";
bool first = true; bool first = true;
for (typename PIMap<Key, Type>::const_iterator i = v.begin(); i != v.end(); ++i) { for (typename PIMap<Key, Type>::const_iterator i = v.begin(); i != v.end(); ++i) {
@@ -855,7 +855,7 @@ inline PICout operator <<(PICout s, const PIMap<Key, Type> & v) {
s << i.key() << ": " << i.value(); s << i.key() << ": " << i.value();
} }
s << "}"; s << "}";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -114,9 +114,9 @@ inline std::ostream & operator <<(std::ostream & s, const PIPair<Type0, Type1> &
template<typename Type0, typename Type1> template<typename Type0, typename Type1>
inline PICout operator <<(PICout s, const PIPair<Type0, Type1> & v) { inline PICout operator <<(PICout s, const PIPair<Type0, Type1> & v) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
s << "(" << v.first << ", " << v.second << ")"; s << "(" << v.first << ", " << v.second << ")";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -145,7 +145,7 @@ template <typename T> PISet<T> operator &(const PISet<T> & v0, const PISet<T> &
template<typename Type> template<typename Type>
inline PICout operator <<(PICout s, const PISet<Type> & v) { inline PICout operator <<(PICout s, const PISet<Type> & v) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
s << "{"; s << "{";
bool first = true; bool first = true;
for (typename PIMap<Type, uchar>::const_iterator i = v.begin(); i != v.end(); ++i) { for (typename PIMap<Type, uchar>::const_iterator i = v.begin(); i != v.end(); ++i) {
@@ -155,7 +155,7 @@ inline PICout operator <<(PICout s, const PISet<Type> & v) {
s << i.key(); s << i.key();
} }
s << "}"; s << "}";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -2316,7 +2316,7 @@ inline std::ostream & operator <<(std::ostream & s, const PIVector<T> & v) {
template<typename T> template<typename T>
inline PICout operator <<(PICout s, const PIVector<T> & v) { inline PICout operator <<(PICout s, const PIVector<T> & v) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
s << "{"; s << "{";
for (size_t i = 0; i < v.size(); ++i) { for (size_t i = 0; i < v.size(); ++i) {
s << v[i]; s << v[i];
@@ -2325,7 +2325,7 @@ inline PICout operator <<(PICout s, const PIVector<T> & v) {
} }
} }
s << "}"; s << "}";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -292,7 +292,7 @@ protected:
template<typename T> template<typename T>
inline PICout operator <<(PICout s, const PIVector2D<T> & v) { inline PICout operator <<(PICout s, const PIVector2D<T> & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << "{"; s << "{";
for (size_t i = 0; i < v.rows(); ++i) { for (size_t i = 0; i < v.rows(); ++i) {
s << "{ "; s << "{ ";
@@ -305,7 +305,7 @@ inline PICout operator <<(PICout s, const PIVector2D<T> & v) {
} }
if (v.isEmpty()) s << "{ }"; if (v.isEmpty()) s << "{ }";
s << "}"; s << "}";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -23,12 +23,12 @@
PICout operator <<(PICout s, const PIBitArray & ba) { PICout operator <<(PICout s, const PIBitArray & ba) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
for (uint i = 0; i < ba.bitSize(); ++i) { for (uint i = 0; i < ba.bitSize(); ++i) {
s << int(ba[i]); s << int(ba[i]);
if (i % 8 == 7) s << ' '; if (i % 8 == 7) s << ' ';
} }
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -406,14 +406,14 @@ PIByteArray PIByteArray::fromHex(PIString str) {
PICout operator <<(PICout s, const PIByteArray & ba) { PICout operator <<(PICout s, const PIByteArray & ba) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
s << "{"; s << "{";
for (uint i = 0; i < ba.size(); ++i) { for (uint i = 0; i < ba.size(); ++i) {
s << ba[i]; s << ba[i];
if (i < ba.size() - 1) s << ", "; if (i < ba.size() - 1) s << ", ";
} }
s << "}"; s << "}";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -359,7 +359,7 @@ PIChar PIChar::toLower() const {
PICout operator <<(PICout s, const PIChar & v) { PICout operator <<(PICout s, const PIChar & v) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
if (v.isAscii()) s << char(v.ch); if (v.isAscii()) s << char(v.ch);
else { else {
#ifdef PIP_ICU #ifdef PIP_ICU
@@ -380,6 +380,6 @@ PICout operator <<(PICout s, const PIChar & v) {
s << PIString(v); s << PIString(v);
#endif #endif
} }
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -267,8 +267,8 @@ PICout PICout::operator <<(const PICoutAction v) {
#endif #endif
} }
break; break;
case PICoutManipulators::SaveContol: saveControl(); break; case PICoutManipulators::SaveContol: saveControls(); break;
case PICoutManipulators::RestoreControl: restoreControl(); break; case PICoutManipulators::RestoreControl: restoreControls(); break;
default: break; default: break;
}; };
return *this; return *this;
@@ -440,14 +440,14 @@ PICout PICout::operator <<(const PICoutSpecialChar v) {
} }
PICout & PICout::saveControl() { PICout & PICout::saveControls() {
if (!act_) return *this; if (!act_) return *this;
PRIVATE->cos_.push(co_); PRIVATE->cos_.push(co_);
return *this; return *this;
} }
PICout & PICout::restoreControl() { PICout & PICout::restoreControls() {
if (!act_) return *this; if (!act_) return *this;
if (!PRIVATE->cos_.isEmpty()) { if (!PRIVATE->cos_.isEmpty()) {
co_ = PRIVATE->cos_.top(); co_ = PRIVATE->cos_.top();
@@ -650,24 +650,17 @@ void PICout::applyFormat(PICoutFormat f) {
} }
bool PICout::setBufferActive(bool on, bool clear) { PIString PICout::getBuffer() {
PIMutexLocker ml(PICout::__mutex__()); PIMutexLocker ml(PICout::__mutex__());
bool ret = isBufferActive(); PIString ret = PICout::__string__();
if (clear) PICout::__string__().clear();
setOutputDevice(Buffer, on);
return ret; return ret;
} }
bool PICout::isBufferActive() { PIString PICout::getBufferAndClear() {
return isOutputDeviceActive(Buffer);
}
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(); PICout::__string__().clear();
return ret; return ret;
} }

View File

@@ -261,19 +261,23 @@ public:
//! \~russian Установить флаг "c" в "on" состояние //! \~russian Установить флаг "c" в "on" состояние
PICout & setControl(PICoutManipulators::PICoutControl c, bool on = true) {co_.setFlag(c, on); return *this;} PICout & setControl(PICoutManipulators::PICoutControl c, bool on = true) {co_.setFlag(c, on); return *this;}
//! \~english Set control flags "c" and if "save" exec \a saveControl() //! \~english Set control flags "c"
//! \~russian Установить флаг "c" и если "save" то выполнить \a saveControl() //! \~russian Установить флаги "c"
PICout & setControl(PICoutManipulators::PICoutControls c, bool save = false) {if (save) saveControl(); co_ = c; return *this;} PICout & setControls(PICoutManipulators::PICoutControls c) {co_ = c; return *this;}
//! \~english Exec \a saveControls() and set control flags to "c"
//! \~russian Иыполнить \a saveControls() и Установить флаги "c"
PICout & saveAndSetControls(PICoutManipulators::PICoutControls c) {saveControls(); co_ = c; return *this;}
//! \~english Save control flags to internal stack //! \~english Save control flags to internal stack
//! \~russian Сохраняет состояние флагов во внутренний стек //! \~russian Сохраняет состояние флагов во внутренний стек
//! \~\sa \a restoreControl() //! \~\sa \a restoreControl()
PICout & saveControl(); PICout & saveControls();
//! \~english Restore control flags from internal stack //! \~english Restore control flags from internal stack
//! \~russian Восстанавливает состояние флагов из внутреннего стека //! \~russian Восстанавливает состояние флагов из внутреннего стека
//! \~\sa \a saveControl() //! \~\sa \a saveControl()
PICout & restoreControl(); PICout & restoreControls();
//! \~english Conditional put space character to output //! \~english Conditional put space character to output
//! \~russian Условно добавляет пробел //! \~russian Условно добавляет пробел
@@ -307,17 +311,13 @@ public:
//! \~russian Вывод \a PIString в stdout //! \~russian Вывод \a PIString в stdout
static void stdoutPIString(const PIString & s); static void stdoutPIString(const PIString & s);
//! \~english Set output device to \a PICout::Buffer and if "clear" clear it //! \~english Returns internal PIString buffer
//! \~russian Устанавливает устройство вывода на \a PICout::Buffer и если "clear" то очищает его //! \~russian Возвращает внутренний PIString буфер
static bool setBufferActive(bool on, bool clear = false); static PIString getBuffer();
//! \~english Equivalent to \a isOutputDeviceActive(OutputDevice) //! \~english Returns internal PIString buffer and clear it
//! \~russian Аналог \a isOutputDeviceActive(OutputDevice) //! \~russian Возвращает внутренний PIString буфер и очищает его
static bool isBufferActive(); static PIString getBufferAndClear();
//! \~english Returns internal PIString buffer and if "clear" clear it
//! \~russian Возвращает внутренний PIString буфер и если "clear" то очищает его
static PIString buffer(bool clear = false);
//! \~english Clear internal PIString buffer //! \~english Clear internal PIString buffer
//! \~russian Очищает внутренний PIString буфер //! \~russian Очищает внутренний PIString буфер
@@ -328,10 +328,22 @@ public:
//! \~russian Устройство вывода "d" устанавливается в "on". Возвращает было ли устройство активно //! \~russian Устройство вывода "d" устанавливается в "on". Возвращает было ли устройство активно
static bool setOutputDevice(OutputDevice d, bool on = true); static bool setOutputDevice(OutputDevice d, bool on = true);
//! \~english Turn on output device "d". Returns if it was enabled
//! \~russian Включает устройство вывода "d". Возвращает было ли устройство активно
static bool enableOutputDevice(OutputDevice d) {return setOutputDevice(d, true);}
//! \~english Turn off output device "d". Returns if it was enabled
//! \~russian Выключает устройство вывода "d". Возвращает было ли устройство активно
static bool disableOutputDevice(OutputDevice d) {return setOutputDevice(d, false);}
//! \~english Set output to devices to "d" //! \~english Set output to devices to "d"
//! \~russian Устанавливает устройства вывода "d" //! \~russian Устанавливает устройства вывода "d"
static void setOutputDevices(OutputDevices d); static void setOutputDevices(OutputDevices d);
//! \~english Returns current output devices
//! \~russian Возвращает текущие устройства вывода
static OutputDevices currentOutputDevices() {return devs;}
//! \~english Returns if output device "d" is active //! \~english Returns if output device "d" is active
//! \~russian Возвращает активно ли устройство вывода "d" //! \~russian Возвращает активно ли устройство вывода "d"
static bool isOutputDeviceActive(OutputDevice d); static bool isOutputDeviceActive(OutputDevice d);

View File

@@ -312,30 +312,30 @@ PIString datetime2string(const PIDateTime & date, const PIString & format) {
PICout operator <<(PICout s, const PITime & v) { PICout operator <<(PICout s, const PITime & v) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
s << "PITime(" << v.hours << ":"; s << "PITime(" << v.hours << ":";
s << PIString::fromNumber(v.minutes).expandLeftTo(2, '0') << ":"; s << PIString::fromNumber(v.minutes).expandLeftTo(2, '0') << ":";
s << PIString::fromNumber(v.seconds).expandLeftTo(2, '0') << ":"; s << PIString::fromNumber(v.seconds).expandLeftTo(2, '0') << ":";
s << PIString::fromNumber(v.milliseconds).expandLeftTo(3, '0') << ")"; s << PIString::fromNumber(v.milliseconds).expandLeftTo(3, '0') << ")";
s.restoreControl(); s.restoreControls();
return s; return s;
} }
PICout operator <<(PICout s, const PIDate & v) { PICout operator <<(PICout s, const PIDate & v) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
s << "PIDate(" << v.day << "-"; s << "PIDate(" << v.day << "-";
s << PIString::fromNumber(v.month).expandLeftTo(2, '0') << "-"; s << PIString::fromNumber(v.month).expandLeftTo(2, '0') << "-";
s << v.year << ")"; s << v.year << ")";
s.restoreControl(); s.restoreControls();
return s; return s;
} }
PICout operator <<(PICout s, const PIDateTime & v) { PICout operator <<(PICout s, const PIDateTime & v) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
s << "PIDateTime("; s << "PIDateTime(";
s << v.day << "-"; s << v.day << "-";
s << PIString::fromNumber(v.month).expandLeftTo(2, '0') << "-"; s << PIString::fromNumber(v.month).expandLeftTo(2, '0') << "-";
@@ -344,7 +344,7 @@ PICout operator <<(PICout s, const PIDateTime & v) {
s << PIString::fromNumber(v.minutes).expandLeftTo(2, '0') << ":"; s << PIString::fromNumber(v.minutes).expandLeftTo(2, '0') << ":";
s << PIString::fromNumber(v.seconds).expandLeftTo(2, '0') << ":"; s << PIString::fromNumber(v.seconds).expandLeftTo(2, '0') << ":";
s << PIString::fromNumber(v.milliseconds).expandLeftTo(3, '0') << ")"; s << PIString::fromNumber(v.milliseconds).expandLeftTo(3, '0') << ")";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -751,13 +751,14 @@ bool dumpApplicationToFile(const PIString & path, bool with_objects) {
f.setName("__S__DumpFile"); f.setName("__S__DumpFile");
f.clear(); f.clear();
if (!f.open(PIIODevice::WriteOnly)) return false; if (!f.open(PIIODevice::WriteOnly)) return false;
bool ba = PICout::isBufferActive(); auto out_devs = PICout::currentOutputDevices();
PICout::setBufferActive(true, true); PICout::setOutputDevices(PICout::Buffer);
PICout::clearBuffer();
dumpApplication(with_objects); dumpApplication(with_objects);
PIIOTextStream ts(&f); PIIOTextStream ts(&f);
ts << PICout::buffer(); ts << PICout::getBuffer();
f.close(); f.close();
PICout::setBufferActive(ba, true); PICout::setOutputDevices(out_devs);
PIFile::rename(path + "_tmp", path); PIFile::rename(path + "_tmp", path);
return true; return true;
} }

View File

@@ -146,6 +146,6 @@ BINARY_STREAM_READ(PIStringList) {
//! \relatesalso PICout //! \relatesalso PICout
//! \~english Output operator to \a PICout //! \~english Output operator to \a PICout
//! \~russian Оператор вывода в \a PICout //! \~russian Оператор вывода в \a PICout
inline PICout operator <<(PICout s, const PIStringList & v) {s.space(); s.setControl(0, true); s << "{"; for (uint i = 0; i < v.size(); ++i) {s << "\"" << v[i] << "\""; if (i < v.size() - 1) s << ", ";} s << "}"; s.restoreControl(); return s;} inline PICout operator <<(PICout s, const PIStringList & v) {s.space(); s.saveAndSetControls(0); s << "{"; for (uint i = 0; i < v.size(); ++i) {s << "\"" << v[i] << "\""; if (i < v.size() - 1) s << ", ";} s << "}"; s.restoreControls(); return s;}
#endif // PISTRINGLIST_H #endif // PISTRINGLIST_H

View File

@@ -186,7 +186,7 @@ private:
//! \relatesalso PICout //! \relatesalso PICout
//! \~english \brief Output operator to PICout //! \~english \brief Output operator to PICout
//! \~russian \brief Оператор вывода в PICout //! \~russian \brief Оператор вывода в PICout
inline PICout operator <<(PICout s, const PISystemTime & v) {s.space(); s.setControl(0, true); s << "(" << v.seconds << " s, " << v.nanoseconds << " ns)"; s.restoreControl(); return s;} inline PICout operator <<(PICout s, const PISystemTime & v) {s.space(); s.saveAndSetControls(0); s << "(" << v.seconds << " s, " << v.nanoseconds << " ns)"; s.restoreControls(); return s;}

View File

@@ -809,12 +809,12 @@ BINARY_STREAM_READ(PIVariant) {
} }
inline PICout operator <<(PICout s, const PIVariant & v) { inline PICout operator <<(PICout s, const PIVariant & v) {
s.space(); s.setControl(0, true); s.space(); s.saveAndSetControls(0);
s << "PIVariant(" << v.typeName(); s << "PIVariant(" << v.typeName();
if (v.isValid()) if (v.isValid())
s << ", " << v.toString(); s << ", " << v.toString();
s << ")"; s << ")";
s.restoreControl(); return s; s.restoreControls(); return s;
} }

View File

@@ -172,7 +172,7 @@ inline PICout operator <<(PICout s, const PIVariantTypes::File & v) {s << "File(
inline PICout operator <<(PICout s, const PIVariantTypes::Dir & v) {s << "Dir(\"" << v.dir << "\")"; return s;} inline PICout operator <<(PICout s, const PIVariantTypes::Dir & v) {s << "Dir(\"" << v.dir << "\")"; return s;}
inline PICout operator <<(PICout s, const PIVariantTypes::Color & v) {s.saveControl(); s << PICoutManipulators::Hex << "Color(#" << v.rgba << ")"; s.restoreControl(); return s;} inline PICout operator <<(PICout s, const PIVariantTypes::Color & v) {s.saveControls(); s << PICoutManipulators::Hex << "Color(#" << v.rgba << ")"; s.restoreControls(); return s;}
inline PICout operator <<(PICout s, const PIVariantTypes::IODevice & v) {s << v.toPICout(); return s;} inline PICout operator <<(PICout s, const PIVariantTypes::IODevice & v) {s << v.toPICout(); return s;}

View File

@@ -350,25 +350,25 @@ private:
//! \relatesalso PICout \brief Output operator PIBinaryLog::BinLogInfo to PICout //! \relatesalso PICout \brief Output operator PIBinaryLog::BinLogInfo to PICout
inline PICout operator <<(PICout s, const PIBinaryLog::BinLogInfo & bi) { inline PICout operator <<(PICout s, const PIBinaryLog::BinLogInfo & bi) {
s.space(); s.space();
s.setControl(0, true); s.saveAndSetControls(0);
s << "[PIBinaryLog] " << bi.path << "\n"; s << "[PIBinaryLog] " << bi.path << "\n";
if (bi.log_size < 0) { if (bi.log_size < 0) {
s << "invalid file path"; s << "invalid file path";
s.restoreControl(); s.restoreControls();
return s; return s;
} }
if (bi.log_size == 0) { if (bi.log_size == 0) {
s << "Invalid empty file"; s << "Invalid empty file";
s.restoreControl(); s.restoreControls();
return s; return s;
} if (bi.records_count < 0 && bi.records_count > -4) { } if (bi.records_count < 0 && bi.records_count > -4) {
s << "Invalid file or corrupted signature"; s << "Invalid file or corrupted signature";
s.restoreControl(); s.restoreControls();
return s; return s;
} }
if (bi.records_count < -3) { if (bi.records_count < -3) {
s << "Invalid binlog version"; s << "Invalid binlog version";
s.restoreControl(); s.restoreControls();
return s; return s;
} }
s << "read records " << bi.records_count << " in " << bi.records.size() << " types, log size " << bi.log_size; s << "read records " << bi.records_count << " in " << bi.records.size() << " types, log size " << bi.log_size;
@@ -380,7 +380,7 @@ inline PICout operator <<(PICout s, const PIBinaryLog::BinLogInfo & bi) {
s << "\n record start " << bri.start_time << " , end " << bri.end_time; s << "\n record start " << bri.start_time << " , end " << bri.end_time;
s << "\n record size " << bri.minimum_size << " - " << bri.maximum_size; s << "\n record size " << bri.minimum_size << " - " << bri.maximum_size;
} }
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -518,7 +518,7 @@ PIP_EXPORT std::ostream & operator <<(std::ostream & s, const PIConfig::Branch &
PIP_EXPORT std::ostream & operator <<(std::ostream & s, const PIConfig::Entry & v); PIP_EXPORT std::ostream & operator <<(std::ostream & s, const PIConfig::Entry & v);
#endif #endif
inline PICout operator <<(PICout s, const PIConfig::Branch & v) {s.setControl(0, true); v.piCoutt(s, ""); s.restoreControl(); return s;} inline PICout operator <<(PICout s, const PIConfig::Branch & v) {s.saveAndSetControls(0); v.piCoutt(s, ""); s.restoreControls(); return s;}
inline PICout operator <<(PICout s, const PIConfig::Entry & v) { inline PICout operator <<(PICout s, const PIConfig::Entry & v) {
s << v.value() << "(" << v.type() << v.comment() << ")"; s << v.value() << "(" << v.type() << v.comment() << ")";
return s; return s;

View File

@@ -189,7 +189,7 @@ inline bool operator !=(const PIFile::FileInfo & v0, const PIFile::FileInfo & v1
//! \relatesalso PICout //! \relatesalso PICout
//! \~english Output operator to \a PICout //! \~english Output operator to \a PICout
//! \~russian Оператор вывода в \a PICout //! \~russian Оператор вывода в \a PICout
inline PICout operator <<(PICout s, const PIDir & v) {s.setControl(0, true); s << "PIDir(\"" << v.path() << "\")"; s.restoreControl(); return s;} inline PICout operator <<(PICout s, const PIDir & v) {s.saveAndSetControls(0); s << "PIDir(\"" << v.path() << "\")"; s.restoreControls(); return s;}
#endif // PIDIR_H #endif // PIDIR_H

View File

@@ -515,7 +515,7 @@ private:
inline bool operator <(const PIEthernet::Interface & v0, const PIEthernet::Interface & v1) {return (v0.name < v1.name);} inline bool operator <(const PIEthernet::Interface & v0, const PIEthernet::Interface & v1) {return (v0.name < v1.name);}
inline bool operator ==(const PIEthernet::Interface & v0, const PIEthernet::Interface & v1) {return (v0.name == v1.name && v0.address == v1.address && v0.netmask == v1.netmask);} inline bool operator ==(const PIEthernet::Interface & v0, const PIEthernet::Interface & v1) {return (v0.name == v1.name && v0.address == v1.address && v0.netmask == v1.netmask);}
inline bool operator !=(const PIEthernet::Interface & v0, const PIEthernet::Interface & v1) {return (v0.name != v1.name || v0.address != v1.address || v0.netmask != v1.netmask);} inline bool operator !=(const PIEthernet::Interface & v0, const PIEthernet::Interface & v1) {return (v0.name != v1.name || v0.address != v1.address || v0.netmask != v1.netmask);}
inline PICout operator <<(PICout s, const PIEthernet::Address & v) {s.space(); s.setControl(0, true); s << "Address(" << v.toString() << ")"; s.restoreControl(); return s;} inline PICout operator <<(PICout s, const PIEthernet::Address & v) {s.space(); s.saveAndSetControls(0); s << "Address(" << v.toString() << ")"; s.restoreControls(); return s;}
inline bool operator ==(const PIEthernet::Address & v0, const PIEthernet::Address & v1) {return (v0.ip() == v1.ip() && v0.port() == v1.port());} inline bool operator ==(const PIEthernet::Address & v0, const PIEthernet::Address & v1) {return (v0.ip() == v1.ip() && v0.port() == v1.port());}
inline bool operator !=(const PIEthernet::Address & v0, const PIEthernet::Address & v1) {return (v0.ip() != v1.ip() || v0.port() != v1.port());} inline bool operator !=(const PIEthernet::Address & v0, const PIEthernet::Address & v1) {return (v0.ip() != v1.ip() || v0.port() != v1.port());}

View File

@@ -334,12 +334,12 @@ private:
//! \~english Output operator to \a PICout //! \~english Output operator to \a PICout
//! \~russian Оператор вывода в \a PICout //! \~russian Оператор вывода в \a PICout
inline PICout operator <<(PICout s, const PIFile::FileInfo & v) { inline PICout operator <<(PICout s, const PIFile::FileInfo & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << "FileInfo(\"" << v.path << "\", " << PIString::readableSize(v.size) << ", " s << "FileInfo(\"" << v.path << "\", " << PIString::readableSize(v.size) << ", "
<< v.perm_user.toString() << " " << v.perm_group.toString() << " " << v.perm_other.toString() << ", " << v.perm_user.toString() << " " << v.perm_group.toString() << " " << v.perm_other.toString() << ", "
<< v.time_access.toString() << ", " << v.time_modification.toString() << v.time_access.toString() << ", " << v.time_modification.toString()
<< ", 0x" << PICoutManipulators::Hex << v.flags << ")"; << ", 0x" << PICoutManipulators::Hex << v.flags << ")";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -154,7 +154,7 @@ BINARY_STREAM_READ (PIBaseTransfer::Part) {s >> v.id >> v.size >> v.start; retur
BINARY_STREAM_WRITE(PIBaseTransfer::StartRequest) {s << v.packets << v.size; return s;} BINARY_STREAM_WRITE(PIBaseTransfer::StartRequest) {s << v.packets << v.size; return s;}
BINARY_STREAM_READ (PIBaseTransfer::StartRequest) {s >> v.packets >> v.size; return s;} BINARY_STREAM_READ (PIBaseTransfer::StartRequest) {s >> v.packets >> v.size; return s;}
inline PICout operator <<(PICout s, const PIBaseTransfer::Part & v) {s.setControl(0, true); s << "Part(\"" << v.id << "\", " << PIString::readableSize(v.start) << " b | " << PIString::readableSize(v.size) << " b)"; s.restoreControl(); return s;} inline PICout operator <<(PICout s, const PIBaseTransfer::Part & v) {s.saveAndSetControls(0); s << "Part(\"" << v.id << "\", " << PIString::readableSize(v.start) << " b | " << PIString::readableSize(v.size) << " b)"; s.restoreControls(); return s;}
#endif // PIBASETRANSFER_H #endif // PIBASETRANSFER_H

View File

@@ -126,12 +126,12 @@ BINARY_STREAM_READ (PIFileTransfer::PFTFileInfo) {
} }
inline PICout operator <<(PICout s, const PIFileTransfer::PFTFileInfo & v) { inline PICout operator <<(PICout s, const PIFileTransfer::PFTFileInfo & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << "FileInfo(\"" << v.dest_path << "\", " << PIString::readableSize(v.size) << ", " s << "FileInfo(\"" << v.dest_path << "\", " << PIString::readableSize(v.size) << ", "
<< v.perm_user.toString() << " " << v.perm_group.toString() << " " << v.perm_other.toString() << ", " << v.perm_user.toString() << " " << v.perm_group.toString() << " " << v.perm_other.toString() << ", "
<< v.time_access.toString() << ", " << v.time_modification.toString() << v.time_access.toString() << ", " << v.time_modification.toString()
<< ", 0x" << PICoutManipulators::Hex << v.flags << ")"; << ", 0x" << PICoutManipulators::Hex << v.flags << ")";
s.restoreControl(); s.restoreControls();
return s; return s;
} }
#endif // PIFILETRANSFER_H #endif // PIFILETRANSFER_H

View File

@@ -180,9 +180,9 @@ public:
//! \~russian Перегруженный оператор для вывода координат в \a PICout. //! \~russian Перегруженный оператор для вывода координат в \a PICout.
template<typename Type> template<typename Type>
PICout operator <<(PICout & s, const PILine<Type> & v) { PICout operator <<(PICout & s, const PILine<Type> & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << "Line{" << v.p0 << ", " << v.p1 << "}"; s << "Line{" << v.p0 << ", " << v.p1 << "}";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -70,7 +70,7 @@ inline complexd log10(const complexd & c) {return log(c) / M_LN10;}
#endif #endif
template<typename T> template<typename T>
inline PICout operator <<(PICout s, const complex<T> & v) {s.space(); s.setControl(0, true); s << "(" << v.real() << "; " << v.imag() << ")"; s.restoreControl(); return s;} inline PICout operator <<(PICout s, const complex<T> & v) {s.space(); s.saveAndSetControls(0); s << "(" << v.real() << "; " << v.imag() << ")"; s.restoreControls(); return s;}
inline PIVector<double> abs(const PIVector<complexd> & v) { inline PIVector<double> abs(const PIVector<complexd> & v) {

View File

@@ -153,9 +153,9 @@ public:
//! \~russian Перегруженный оператор для вывода координат в \a PICout. //! \~russian Перегруженный оператор для вывода координат в \a PICout.
template<typename Type> template<typename Type>
PICout operator <<(PICout & s, const PIPoint<Type> & v) { PICout operator <<(PICout & s, const PIPoint<Type> & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << "Point{" << v.x << ", " << v.y << "}"; s << "Point{" << v.x << ", " << v.y << "}";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -341,9 +341,9 @@ private:
template<typename Type> template<typename Type>
PICout operator <<(PICout & s, const PIRect<Type> & v) { PICout operator <<(PICout & s, const PIRect<Type> & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << "Rect{" << v.bottomLeft() << ":" << v.width() << "x" << v.height() << "}"; s << "Rect{" << v.bottomLeft() << ":" << v.width() << "x" << v.height() << "}";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -144,12 +144,12 @@ private:
//! \~english Output operator to \a PICout //! \~english Output operator to \a PICout
//! \~russian Оператор вывода в \a PICout //! \~russian Оператор вывода в \a PICout
inline PICout operator <<(PICout s, const PISystemInfo::MountInfo & v) { inline PICout operator <<(PICout s, const PISystemInfo::MountInfo & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << "MountInfo(" << v.device << " mounted on \"" << v.mount_point << "\", type " << v.filesystem s << "MountInfo(" << v.device << " mounted on \"" << v.mount_point << "\", type " << v.filesystem
<< ", label \"" << v.label << "\", all " << PIString::readableSize(v.space_all) << ", label \"" << v.label << "\", all " << PIString::readableSize(v.space_all)
<< ", used " << PIString::readableSize(v.space_used) << ", used " << PIString::readableSize(v.space_used)
<< ", free " << PIString::readableSize(v.space_free) << ")"; << ", free " << PIString::readableSize(v.space_free) << ")";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -280,13 +280,13 @@ private:
//! \~english Output operator to \a PICout //! \~english Output operator to \a PICout
//! \~russian Оператор вывода в \a PICout //! \~russian Оператор вывода в \a PICout
inline PICout operator <<(PICout s, const PISystemMonitor::ThreadStats & v) { inline PICout operator <<(PICout s, const PISystemMonitor::ThreadStats & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << "ThreadInfo(\"" << v.name << "\", created " << v.created s << "ThreadInfo(\"" << v.name << "\", created " << v.created
<< ", work " << v.work_time.toMilliseconds() << " ms" << ", work " << v.work_time.toMilliseconds() << " ms"
<< ", kernel " << v.kernel_time.toMilliseconds() << " ms" << ", kernel " << v.kernel_time.toMilliseconds() << " ms"
<< ", user " << v.user_time.toMilliseconds() << " ms" << ", user " << v.user_time.toMilliseconds() << " ms"
<< ")\n"; << ")\n";
s.restoreControl(); s.restoreControls();
return s; return s;
} }

View File

@@ -701,6 +701,6 @@ void PIOpenCL::KernelArg::init(void * _k, uint index) {
PICout operator <<(PICout s, const PIOpenCL::KernelArg & v) { PICout operator <<(PICout s, const PIOpenCL::KernelArg & v) {
s.setControl(0); s << "Arg(" << v.base_type_name << " " << v.arg_name << " (addr=" << v.address_qualifier << ",acc=" << v.access_qualifier << ",typ=" << v.type_qualifier << ",dims=" << v.dims << "))"; s.setControls(0); s << "Arg(" << v.base_type_name << " " << v.arg_name << " (addr=" << v.address_qualifier << ",acc=" << v.access_qualifier << ",typ=" << v.type_qualifier << ",dims=" << v.dims << "))";
s.restoreControl(); return s; s.restoreControls(); return s;
} }

View File

@@ -375,7 +375,7 @@ void PIUSB::flush() {
PICout operator<<(PICout s, const PIUSB::Endpoint & v) { PICout operator<<(PICout s, const PIUSB::Endpoint & v) {
s.setControl(0, true); s.saveAndSetControls(0);
s << PICoutManipulators::NewLine << "{" << PICoutManipulators::NewLine; s << PICoutManipulators::NewLine << "{" << PICoutManipulators::NewLine;
if (v.isNull()) if (v.isNull())
s << " " << "Null Endpoint"; s << " " << "Null Endpoint";
@@ -411,7 +411,7 @@ PICout operator<<(PICout s, const PIUSB::Endpoint & v) {
s << " " << "Max Packet Size: " << v.max_packet_size << PICoutManipulators::NewLine; s << " " << "Max Packet Size: " << v.max_packet_size << PICoutManipulators::NewLine;
} }
s << "}" << PICoutManipulators::NewLine; s << "}" << PICoutManipulators::NewLine;
s.restoreControl(); s.restoreControls();
return s; return s;
} }