version 2.93 ready to master
remove PIString << operators
This commit is contained in:
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
|
|||||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||||
project(pip)
|
project(pip)
|
||||||
set(pip_MAJOR 2)
|
set(pip_MAJOR 2)
|
||||||
set(pip_MINOR 92)
|
set(pip_MINOR 93)
|
||||||
set(pip_REVISION 0)
|
set(pip_REVISION 0)
|
||||||
set(pip_SUFFIX )
|
set(pip_SUFFIX )
|
||||||
set(pip_COMPANY SHS)
|
set(pip_COMPANY SHS)
|
||||||
|
|||||||
@@ -1050,7 +1050,7 @@ PIString PICodeParser::procMacros(PIString fc) {
|
|||||||
if (ifcnt > 0) ifcnt--;
|
if (ifcnt > 0) ifcnt--;
|
||||||
else {
|
else {
|
||||||
//piCout << "main endif" << skip << grab;
|
//piCout << "main endif" << skip << grab;
|
||||||
if (grab) pfc << procMacros(nfc);
|
if (grab) pfc += procMacros(nfc);
|
||||||
skip = grab = false;
|
skip = grab = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1059,7 +1059,7 @@ PIString PICodeParser::procMacros(PIString fc) {
|
|||||||
//piCout << "main elif" << skip << grab << cond_ok;
|
//piCout << "main elif" << skip << grab << cond_ok;
|
||||||
if (cond_ok) {
|
if (cond_ok) {
|
||||||
if (grab) {
|
if (grab) {
|
||||||
pfc << procMacros(nfc);
|
pfc += procMacros(nfc);
|
||||||
skip = true; grab = false;
|
skip = true; grab = false;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -1075,12 +1075,12 @@ PIString PICodeParser::procMacros(PIString fc) {
|
|||||||
}
|
}
|
||||||
if (mif.left(4) == s_else && ifcnt == 0) {
|
if (mif.left(4) == s_else && ifcnt == 0) {
|
||||||
//piCout << "main else" << skip << grab;
|
//piCout << "main else" << skip << grab;
|
||||||
if (grab) pfc << procMacros(nfc);
|
if (grab) pfc += procMacros(nfc);
|
||||||
if (skip && !cond_ok) {skip = false; grab = true;}
|
if (skip && !cond_ok) {skip = false; grab = true;}
|
||||||
else {skip = true; grab = false;}
|
else {skip = true; grab = false;}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (grab) nfc << line << '\n';
|
if (grab) nfc += line + '\n';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mif.left(2) == s_if) {
|
if (mif.left(2) == s_if) {
|
||||||
@@ -1095,8 +1095,8 @@ PIString PICodeParser::procMacros(PIString fc) {
|
|||||||
//return false; /// WARNING: now skip errors
|
//return false; /// WARNING: now skip errors
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (grab) nfc << line << '\n';
|
if (grab) nfc += line + '\n';
|
||||||
else if (!skip) pfc << line << '\n';
|
else if (!skip) pfc += line + '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pfc;
|
return pfc;
|
||||||
|
|||||||
@@ -320,10 +320,10 @@ PICout PICout::operator <<(const PIFlags<PICoutManipulators::PICoutFormat> & v)
|
|||||||
|
|
||||||
#define PICOUTTOTARGET(v) { \
|
#define PICOUTTOTARGET(v) { \
|
||||||
if (buffer_) {\
|
if (buffer_) {\
|
||||||
(*buffer_) << (v);\
|
(*buffer_) += (v);\
|
||||||
} else {\
|
} else {\
|
||||||
if (PICout::isOutputDeviceActive(PICout::StdOut)) std::cout << (v);\
|
if (PICout::isOutputDeviceActive(PICout::StdOut)) std::cout << (v);\
|
||||||
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() << (v);\
|
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() += (v);\
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,52 +386,52 @@ PICout PICout::operator <<(const PICoutSpecialChar v) {
|
|||||||
switch (v) {
|
switch (v) {
|
||||||
case Null:
|
case Null:
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
(*buffer_) << PIChar();
|
(*buffer_) += PIChar();
|
||||||
} else {
|
} else {
|
||||||
if (isOutputDeviceActive(StdOut)) std::cout << char(0);
|
if (isOutputDeviceActive(StdOut)) std::cout << char(0);
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() << PIChar();
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += PIChar();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NewLine:
|
case NewLine:
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
(*buffer_) << "\n";
|
(*buffer_) += "\n";
|
||||||
} else {
|
} else {
|
||||||
if (isOutputDeviceActive(StdOut)) std::cout << '\n';
|
if (isOutputDeviceActive(StdOut)) std::cout << '\n';
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() << "\n";
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += "\n";
|
||||||
}
|
}
|
||||||
fo_ = true;
|
fo_ = true;
|
||||||
break;
|
break;
|
||||||
case Tab:
|
case Tab:
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
(*buffer_) << "\t";
|
(*buffer_) += "\t";
|
||||||
} else {
|
} else {
|
||||||
if (isOutputDeviceActive(StdOut)) std::cout << '\t';
|
if (isOutputDeviceActive(StdOut)) std::cout << '\t';
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() << "\t";
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += "\t";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Esc:
|
case Esc:
|
||||||
#ifdef CC_VC
|
#ifdef CC_VC
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
(*buffer_) << PIChar(27);
|
(*buffer_) += PIChar(27);
|
||||||
} else {
|
} else {
|
||||||
if (isOutputDeviceActive(StdOut)) std::cout << char(27);
|
if (isOutputDeviceActive(StdOut)) std::cout << char(27);
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() << PIChar(27);
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += PIChar(27);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
(*buffer_) << "\e";
|
(*buffer_) += "\e";
|
||||||
} else {
|
} else {
|
||||||
if (isOutputDeviceActive(StdOut)) std::cout << '\e';
|
if (isOutputDeviceActive(StdOut)) std::cout << '\e';
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() << "\e";
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += "\e";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case Quote:
|
case Quote:
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
(*buffer_) << "\"";
|
(*buffer_) += "\"";
|
||||||
} else {
|
} else {
|
||||||
if (isOutputDeviceActive(StdOut)) std::cout << '"';
|
if (isOutputDeviceActive(StdOut)) std::cout << '"';
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() << "\"";
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += "\"";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@@ -469,10 +469,10 @@ PICout & PICout::space() {
|
|||||||
if (!act_) return *this;
|
if (!act_) return *this;
|
||||||
if (!fo_ && co_[AddSpaces]) {
|
if (!fo_ && co_[AddSpaces]) {
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
(*buffer_) << " ";
|
(*buffer_) += " ";
|
||||||
} else {
|
} else {
|
||||||
if (isOutputDeviceActive(StdOut)) std::cout << ' ';
|
if (isOutputDeviceActive(StdOut)) std::cout << ' ';
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() << " ";
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fo_ = false;
|
fo_ = false;
|
||||||
@@ -489,10 +489,10 @@ PICout & PICout::quote() {
|
|||||||
if (!act_) return *this;
|
if (!act_) return *this;
|
||||||
if (co_[AddQuotes]) {
|
if (co_[AddQuotes]) {
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
(*buffer_) << "\"";
|
(*buffer_) += "\"";
|
||||||
} else {
|
} else {
|
||||||
if (isOutputDeviceActive(StdOut)) std::cout << '"';
|
if (isOutputDeviceActive(StdOut)) std::cout << '"';
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() << "\"";
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += "\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fo_ = false;
|
fo_ = false;
|
||||||
@@ -509,10 +509,10 @@ PICout & PICout::newLine() {
|
|||||||
if (!act_) return *this;
|
if (!act_) return *this;
|
||||||
if (co_[AddNewLine]) {
|
if (co_[AddNewLine]) {
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
(*buffer_) << "\n";
|
(*buffer_) += "\n";
|
||||||
} else {
|
} else {
|
||||||
if (isOutputDeviceActive(StdOut)) std::cout << std::endl;
|
if (isOutputDeviceActive(StdOut)) std::cout << std::endl;
|
||||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() << "\n";
|
if (isOutputDeviceActive(Buffer)) PICout::__string__() += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fo_ = false;
|
fo_ = false;
|
||||||
|
|||||||
@@ -241,94 +241,6 @@ public:
|
|||||||
//! \~russian Оператор сравнения.
|
//! \~russian Оператор сравнения.
|
||||||
bool operator >=(const char * str) const {return *this >= PIString(str);}
|
bool operator >=(const char * str) const {return *this >= PIString(str);}
|
||||||
|
|
||||||
//! \~english Append string "str" at the end of string.
|
|
||||||
//! \~russian Добавляет в конец строку "str".
|
|
||||||
//! \~\details
|
|
||||||
//! \~\code
|
|
||||||
//! PIString s("this"), s1(" is"), s2(" string");
|
|
||||||
//! s << s1 << s2; // s = "this is string"
|
|
||||||
//! \endcode
|
|
||||||
PIString & operator <<(const PIString & str) {*this += str; return *this;}
|
|
||||||
|
|
||||||
//! \~english Append character "c" at the end of string.
|
|
||||||
//! \~russian Добавляет в конец символ "c".
|
|
||||||
//! \~\details
|
|
||||||
//! \~\code
|
|
||||||
//! PIString s("stri");
|
|
||||||
//! s << PIChar('n') << PIChar('g'); // s = "string"
|
|
||||||
//! \endcode
|
|
||||||
PIString & operator <<(const PIChar c) {d.append(c); return *this;}
|
|
||||||
|
|
||||||
//! \~english Append character `c` at the end of string.
|
|
||||||
//! \~russian Добавляет в конец символ `c`.
|
|
||||||
//! \~\details
|
|
||||||
//! \~\code
|
|
||||||
//! PIString s("stri");
|
|
||||||
//! s << 'n' << 'g'; // s = "string"
|
|
||||||
//! \endcode
|
|
||||||
PIString & operator <<(const char c) {d.append(PIChar(c)); return *this;}
|
|
||||||
|
|
||||||
//! \~english Append С-string "str" at the end of string.
|
|
||||||
//! \~russian Добавляет в конец C-строку "str".
|
|
||||||
//! \~\details
|
|
||||||
//! \~\code
|
|
||||||
//! PIString s("this");
|
|
||||||
//! s << " is" << " string"; // s = "this is string"
|
|
||||||
//! \endcode
|
|
||||||
PIString & operator <<(const char * str) {*this += str; return *this;}
|
|
||||||
|
|
||||||
//! \~english Append \c wchar_t C-string "str" at the end of string.
|
|
||||||
//! \~russian Добавляет в конец \c wchar_t C-строку "str".
|
|
||||||
//! \~\details
|
|
||||||
//! \~\code
|
|
||||||
//! PIString s;
|
|
||||||
//! s << L"№ -" << " number"; // s = "№ - number"
|
|
||||||
//! \endcode
|
|
||||||
PIString & operator <<(const wchar_t * str) {*this += str; return *this;}
|
|
||||||
|
|
||||||
PIString & operator <<(const PIConstChars & str) {*this += str; return *this;}
|
|
||||||
|
|
||||||
//! \~english Append string representation of "num" at the end of string.
|
|
||||||
//! \~russian Добавляет в конец строковое представление "num".
|
|
||||||
//! \~\details
|
|
||||||
//! \~\code
|
|
||||||
//! PIString s("ten - ");
|
|
||||||
//! s << 10; // s = "ten - 10"
|
|
||||||
//! \endcode
|
|
||||||
PIString & operator <<(const int & num) {*this += PIString::fromNumber(num); return *this;}
|
|
||||||
PIString & operator <<(const uint & num) {*this += PIString::fromNumber(num); return *this;}
|
|
||||||
|
|
||||||
//! \~english Append string representation of "num" at the end of string.
|
|
||||||
//! \~russian Добавляет в конец строковое представление "num".
|
|
||||||
//! \~\details
|
|
||||||
//! \~\code
|
|
||||||
//! PIString s("ten - ");
|
|
||||||
//! s << 10; // s = "ten - 10"
|
|
||||||
//! \endcode
|
|
||||||
PIString & operator <<(const long & num) {*this += PIString::fromNumber(num); return *this;}
|
|
||||||
PIString & operator <<(const ulong & num) {*this += PIString::fromNumber(num); return *this;}
|
|
||||||
|
|
||||||
PIString & operator <<(const llong & num) {*this += PIString::fromNumber(num); return *this;}
|
|
||||||
PIString & operator <<(const ullong & num) {*this += PIString::fromNumber(num); return *this;}
|
|
||||||
|
|
||||||
//! \~english Append string representation of "num" at the end of string.
|
|
||||||
//! \~russian Добавляет в конец строковое представление "num".
|
|
||||||
//! \~\details
|
|
||||||
//! \~\code
|
|
||||||
//! PIString s("1/10 - ");
|
|
||||||
//! s << 0.1; // s = "1/10 - 0.1"
|
|
||||||
//! \endcode
|
|
||||||
PIString & operator <<(const float & num) {*this += PIString::fromNumber(num); return *this;}
|
|
||||||
|
|
||||||
//! \~english Append string representation of "num" at the end of string.
|
|
||||||
//! \~russian Добавляет в конец строковое представление "num".
|
|
||||||
//! \~\details
|
|
||||||
//! \~\code
|
|
||||||
//! PIString s("1/10 - ");
|
|
||||||
//! s << 0.1; // s = "1/10 - 0.1"
|
|
||||||
//! \endcode
|
|
||||||
PIString & operator <<(const double & num) {*this += PIString::fromNumber(num); return *this;}
|
|
||||||
|
|
||||||
//! \~english Iterator to the first element.
|
//! \~english Iterator to the first element.
|
||||||
//! \~russian Итератор на первый элемент.
|
//! \~russian Итератор на первый элемент.
|
||||||
//! \~\details
|
//! \~\details
|
||||||
|
|||||||
@@ -110,25 +110,25 @@ PIPropertyStorage PIVariantTypes::IODevice::get() const {
|
|||||||
|
|
||||||
PIString PIVariantTypes::IODevice::toPICout() const {
|
PIString PIVariantTypes::IODevice::toPICout() const {
|
||||||
PIString s;
|
PIString s;
|
||||||
s << "IODevice(" << prefix << ", mode=";
|
s += "IODevice(" + prefix + ", mode=";
|
||||||
int rwc = 0;
|
int rwc = 0;
|
||||||
if (mode & 1) {s << "r"; ++rwc;}
|
if (mode & 1) {s += "r"; ++rwc;}
|
||||||
if (mode & 2) {s << "w"; ++rwc;}
|
if (mode & 2) {s += "w"; ++rwc;}
|
||||||
if (rwc == 1) s << "o";
|
if (rwc == 1) s += "o";
|
||||||
s << ", flags=";
|
s += ", flags=";
|
||||||
#ifndef MICRO_PIP // TODO: PIIODevice for MICRO PIP
|
#ifndef MICRO_PIP // TODO: PIIODevice for MICRO PIP
|
||||||
if (options != 0) {
|
if (options != 0) {
|
||||||
if (((PIIODevice::DeviceOptions)options)[PIIODevice::BlockingRead])
|
if (((PIIODevice::DeviceOptions)options)[PIIODevice::BlockingRead])
|
||||||
s << " br";
|
s += " br";
|
||||||
if (((PIIODevice::DeviceOptions)options)[PIIODevice::BlockingWrite])
|
if (((PIIODevice::DeviceOptions)options)[PIIODevice::BlockingWrite])
|
||||||
s << " bw";
|
s += " bw";
|
||||||
}
|
}
|
||||||
#endif // MICRO_PIP
|
#endif // MICRO_PIP
|
||||||
PIPropertyStorage ps = get();
|
PIPropertyStorage ps = get();
|
||||||
piForeachC (PIPropertyStorage::Property & p, ps) {
|
piForeachC (PIPropertyStorage::Property & p, ps) {
|
||||||
s << ", " << p.name << "=\"" << p.value.toString() << "\"";
|
s += ", " + p.name + "=\"" + p.value.toString() + "\"";
|
||||||
}
|
}
|
||||||
s << ")";
|
s += ")";
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -728,19 +728,19 @@ bool PIBinaryLog::seek(llong filepos) {
|
|||||||
|
|
||||||
PIString PIBinaryLog::constructFullPathDevice() const {
|
PIString PIBinaryLog::constructFullPathDevice() const {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
ret << logDir() << ":" << filePrefix() << ":" << defaultID() << ":";
|
ret += logDir() + ":" + filePrefix() + ":" + defaultID() + ":";
|
||||||
switch (play_mode) {
|
switch (play_mode) {
|
||||||
case PlayRealTime:
|
case PlayRealTime:
|
||||||
ret << "RT";
|
ret += "RT";
|
||||||
break;
|
break;
|
||||||
case PlayVariableSpeed:
|
case PlayVariableSpeed:
|
||||||
ret << PIString::fromNumber(playSpeed()) << "X";
|
ret += PIString::fromNumber(playSpeed()) + "X";
|
||||||
break;
|
break;
|
||||||
case PlayStaticDelay:
|
case PlayStaticDelay:
|
||||||
ret << PIString::fromNumber(playDelay().toMilliseconds()) << "M";
|
ret += PIString::fromNumber(playDelay().toMilliseconds()) + "M";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret << "RT";
|
ret += "RT";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ int PICAN::readedCANID() const {
|
|||||||
|
|
||||||
PIString PICAN::constructFullPathDevice() const {
|
PIString PICAN::constructFullPathDevice() const {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
ret << path() << ":" << PIString::fromNumber(CANID(),16);
|
ret += path() + ":" + PIString::fromNumber(CANID(), 16);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,9 +116,9 @@ PIEthernet::Address::Address(const PIString & _ip, ushort _port) {
|
|||||||
|
|
||||||
PIString PIEthernet::Address::ipString() const {
|
PIString PIEthernet::Address::ipString() const {
|
||||||
PIString ret = PIString::fromNumber(ip_b[0]);
|
PIString ret = PIString::fromNumber(ip_b[0]);
|
||||||
ret << "." << PIString::fromNumber(ip_b[1]);
|
ret += "." + PIString::fromNumber(ip_b[1]);
|
||||||
ret << "." << PIString::fromNumber(ip_b[2]);
|
ret += "." + PIString::fromNumber(ip_b[2]);
|
||||||
ret << "." << PIString::fromNumber(ip_b[3]);
|
ret += "." + PIString::fromNumber(ip_b[3]);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -930,11 +930,12 @@ void PIEthernet::propertyChanged(const char * name) {
|
|||||||
|
|
||||||
PIString PIEthernet::constructFullPathDevice() const {
|
PIString PIEthernet::constructFullPathDevice() const {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
ret << (type() == PIEthernet::UDP ? "UDP" : "TCP") << ":" << readIP() << ":" << readPort();
|
ret += (type() == PIEthernet::UDP ? "UDP" : "TCP");
|
||||||
|
ret += ":" + readIP() + ":" + PIString::fromNumber(readPort());
|
||||||
if (type() == PIEthernet::UDP) {
|
if (type() == PIEthernet::UDP) {
|
||||||
ret << ":" << sendIP() << ":" << sendPort();
|
ret += ":" + sendIP() + ":" + PIString::fromNumber(sendPort());
|
||||||
piForeachC (PIString & m, multicastGroups())
|
piForeachC (PIString & m, multicastGroups())
|
||||||
ret << ":mcast:" << m;
|
ret += ":mcast:" + m;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#ifndef PIIOSTREAM_H
|
#ifndef PIIOSTREAM_H
|
||||||
#define PIIOSTREAM_H
|
#define PIIOSTREAM_H
|
||||||
|
|
||||||
#include "piiodevice.h"
|
#include "piiostring.h"
|
||||||
#include "pitextstream.h"
|
#include "pitextstream.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -39,8 +39,10 @@ public:
|
|||||||
|
|
||||||
//! \~english Contructs %PIIOBinaryStream for "device" device
|
//! \~english Contructs %PIIOBinaryStream for "device" device
|
||||||
//! \~russian Создает %PIIOBinaryStream для устройства "device"
|
//! \~russian Создает %PIIOBinaryStream для устройства "device"
|
||||||
PIIOBinaryStream(PIIODevice * device): dev(device) {}
|
PIIOBinaryStream(PIIODevice * device = nullptr): dev(device) {}
|
||||||
|
|
||||||
|
//! \~english Assign "device" device
|
||||||
|
//! \~russian Назначает устройство "device"
|
||||||
void setDevice(PIIODevice * device) {dev = device;}
|
void setDevice(PIIODevice * device) {dev = device;}
|
||||||
|
|
||||||
bool binaryStreamAppendImp(const void * d, size_t s) {
|
bool binaryStreamAppendImp(const void * d, size_t s) {
|
||||||
@@ -70,12 +72,25 @@ public:
|
|||||||
//! \~russian Создает %PIIOTextStream для устройства "device"
|
//! \~russian Создает %PIIOTextStream для устройства "device"
|
||||||
PIIOTextStream(PIIODevice * device): PITextStream<PIIOBinaryStream>(&bin_stream), bin_stream(device) {}
|
PIIOTextStream(PIIODevice * device): PITextStream<PIIOBinaryStream>(&bin_stream), bin_stream(device) {}
|
||||||
|
|
||||||
|
//! \~english Contructs %PIIOTextStream for "string" string
|
||||||
|
//! \~russian Создает %PIIOTextStream для строки "string"
|
||||||
|
PIIOTextStream(PIString * string): PITextStream<PIIOBinaryStream>(&bin_stream) {
|
||||||
|
io_string = new PIIOString(string);
|
||||||
|
bin_stream.setDevice(io_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
~PIIOTextStream() {
|
||||||
|
if (io_string)
|
||||||
|
delete io_string;
|
||||||
|
}
|
||||||
|
|
||||||
void setDevice(PIIODevice * device) {
|
void setDevice(PIIODevice * device) {
|
||||||
bin_stream = PIIOBinaryStream(device);
|
bin_stream = PIIOBinaryStream(device);
|
||||||
setStream(&bin_stream);
|
setStream(&bin_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
PIIOString * io_string = nullptr;
|
||||||
PIIOBinaryStream bin_stream;
|
PIIOBinaryStream bin_stream;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -968,7 +968,7 @@ void PIPeer::newTcpClient(PIEthernet *client) {
|
|||||||
|
|
||||||
PIString PIPeer::constructFullPathDevice() const {
|
PIString PIPeer::constructFullPathDevice() const {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
ret << self_info.name << ":" << trustPeerName();
|
ret += self_info.name + ":" + trustPeerName();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -516,14 +516,14 @@ PIString PISerial::readString(int size, double timeout_ms) {
|
|||||||
while (tm_.elapsed_m() < timeout_ms) {
|
while (tm_.elapsed_m() < timeout_ms) {
|
||||||
ret = readDevice(td, 1024);
|
ret = readDevice(td, 1024);
|
||||||
if (ret <= 0) piMinSleep();
|
if (ret <= 0) piMinSleep();
|
||||||
else str << PIString((char*)td, ret);
|
else str += PIString((char*)td, ret);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (all < size && tm_.elapsed_m() < timeout_ms) {
|
while (all < size && tm_.elapsed_m() < timeout_ms) {
|
||||||
ret = readDevice(td, size - all);
|
ret = readDevice(td, size - all);
|
||||||
if (ret <= 0) piMinSleep();
|
if (ret <= 0) piMinSleep();
|
||||||
else {
|
else {
|
||||||
str << PIString((char*)td, ret);
|
str += PIString((char*)td, ret);
|
||||||
all += ret;
|
all += ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -532,12 +532,12 @@ PIString PISerial::readString(int size, double timeout_ms) {
|
|||||||
} else {
|
} else {
|
||||||
bool br = setOption(BlockingRead, true);
|
bool br = setOption(BlockingRead, true);
|
||||||
all = readDevice(td, 1);
|
all = readDevice(td, 1);
|
||||||
str << PIString((char*)td, all);
|
str += PIString((char*)td, all);
|
||||||
while (all < size) {
|
while (all < size) {
|
||||||
ret = readDevice(td, size - all);
|
ret = readDevice(td, size - all);
|
||||||
if (ret <= 0) piMinSleep();
|
if (ret <= 0) piMinSleep();
|
||||||
else {
|
else {
|
||||||
str << PIString((char*)td, ret);
|
str += PIString((char*)td, ret);
|
||||||
all += ret;
|
all += ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -857,13 +857,13 @@ bool PISerial::configureDevice(const void * e_main, const void * e_parent) {
|
|||||||
|
|
||||||
PIString PISerial::constructFullPathDevice() const {
|
PIString PISerial::constructFullPathDevice() const {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
ret << path() << ":" << int(inSpeed()) << ":" << dataBitsCount();
|
ret += path() + ":" + PIString::fromNumber(int(inSpeed())) + ":" + PIString::fromNumber(dataBitsCount());
|
||||||
if (parameters()[ParityControl]) {
|
if (parameters()[ParityControl]) {
|
||||||
if (parameters()[ParityOdd]) ret << ":O";
|
if (parameters()[ParityOdd]) ret += ":O";
|
||||||
else ret << ":E";
|
else ret += ":E";
|
||||||
} else ret << ":N";
|
} else ret += ":N";
|
||||||
if (parameters()[TwoStopBits]) ret << ":2";
|
if (parameters()[TwoStopBits]) ret += ":2";
|
||||||
else ret << ":1";
|
else ret += ":1";
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ bool PISharedMemory::closeDevice() {
|
|||||||
|
|
||||||
PIString PISharedMemory::constructFullPathDevice() const {
|
PIString PISharedMemory::constructFullPathDevice() const {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
ret << path() << ":" << dsize;
|
ret += path() + ":" + PIString::fromNumber(dsize);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ int PISPI::writeDevice(const void * data, int max_size) {
|
|||||||
|
|
||||||
PIString PISPI::constructFullPathDevice() const {
|
PIString PISPI::constructFullPathDevice() const {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
ret << path() << ":" << int(speed()) << ":" << int(bits()) << ":" << (int)parameters();
|
ret += path() + ":" + PIString::fromNumber((int)speed()) + ":" + PIString::fromNumber((int)bits()) + ":" + PIString::fromNumber((int)parameters());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "piconnection.h"
|
#include "piconnection.h"
|
||||||
#include "piconfig.h"
|
#include "piconfig.h"
|
||||||
|
#include "piiostream.h"
|
||||||
|
|
||||||
/** \class PIConnection
|
/** \class PIConnection
|
||||||
* \brief Complex Input/Output point
|
* \brief Complex Input/Output point
|
||||||
@@ -259,18 +260,19 @@ bool PIConnection::configure(PIConfig & conf, const PIString & name_) {
|
|||||||
|
|
||||||
PIString PIConnection::makeConfig() const {
|
PIString PIConnection::makeConfig() const {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
ret << "[" << name() << "]\n";
|
PIIOTextStream ts(&ret);
|
||||||
|
ts << "[" << name() << "]\n";
|
||||||
PIVector<PIIODevice * > devs(boundedDevices());
|
PIVector<PIIODevice * > devs(boundedDevices());
|
||||||
int dn(-1);
|
int dn(-1);
|
||||||
piForeachC (PIIODevice * d, devs) {
|
piForeachC (PIIODevice * d, devs) {
|
||||||
PIStringList dnl(deviceNames(d));
|
PIStringList dnl(deviceNames(d));
|
||||||
if (dnl.isEmpty()) dnl << PIString::fromNumber(++dn);
|
if (dnl.isEmpty()) dnl << PIString::fromNumber(++dn);
|
||||||
piForeachC (PIString & dname, dnl) {
|
piForeachC (PIString & dname, dnl) {
|
||||||
ret << "device." << dname << " = " << d->constructFullPath() << " #s\n";
|
ts << "device." << dname << " = " << d->constructFullPath() << " #s\n";
|
||||||
ret << "device." << dname << ".bufferSize = " << d->threadedReadBufferSize() << " #n\n";
|
ts << "device." << dname << ".bufferSize = " << d->threadedReadBufferSize() << " #n\n";
|
||||||
PIDiagnostics * diag = diags_.value(const_cast<PIIODevice * >(d), 0);
|
PIDiagnostics * diag = diags_.value(const_cast<PIIODevice * >(d), 0);
|
||||||
if (diag != 0)
|
if (diag != 0)
|
||||||
ret << "device." << dname << ".disconnectTimeout = " << diag->disconnectTimeout() << " #f\n";
|
ts << "device." << dname << ".disconnectTimeout = " << diag->disconnectTimeout() << " #f\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
piForeachC (PEPair & f, extractors) {
|
piForeachC (PEPair & f, extractors) {
|
||||||
@@ -280,27 +282,27 @@ PIString PIConnection::makeConfig() const {
|
|||||||
for (int i = 0; i < f.second->devices.size_s(); ++i) {
|
for (int i = 0; i < f.second->devices.size_s(); ++i) {
|
||||||
PIString dname = device_names.key(f.second->devices[i]);
|
PIString dname = device_names.key(f.second->devices[i]);
|
||||||
if (dname.isEmpty()) dname = devPath(f.second->devices[i]);
|
if (dname.isEmpty()) dname = devPath(f.second->devices[i]);
|
||||||
ret << prefix << ".device." << i << " = " << dname << " #s\n";
|
ts << prefix << ".device." << i << " = " << dname << " #s\n";
|
||||||
}
|
}
|
||||||
PIDiagnostics * diag = diags_.value(f.second->extractor, 0);
|
PIDiagnostics * diag = diags_.value(f.second->extractor, 0);
|
||||||
ret << prefix << ".bufferSize = " << f.second->extractor->bufferSize() << " #n\n";
|
ts << prefix << ".bufferSize = " << f.second->extractor->bufferSize() << " #n\n";
|
||||||
if (diag != 0)
|
if (diag != 0)
|
||||||
ret << prefix << ".disconnectTimeout = " << diag->disconnectTimeout() << " #f\n";
|
ts << prefix << ".disconnectTimeout = " << diag->disconnectTimeout() << " #f\n";
|
||||||
ret << prefix << ".splitMode = ";
|
ts << prefix << ".splitMode = ";
|
||||||
switch (f.second->extractor->splitMode()) {
|
switch (f.second->extractor->splitMode()) {
|
||||||
case PIPacketExtractor::None: ret << "none"; break;
|
case PIPacketExtractor::None: ts << "none"; break;
|
||||||
case PIPacketExtractor::Header: ret << "header"; break;
|
case PIPacketExtractor::Header: ts << "header"; break;
|
||||||
case PIPacketExtractor::Footer: ret << "footer"; break;
|
case PIPacketExtractor::Footer: ts << "footer"; break;
|
||||||
case PIPacketExtractor::HeaderAndFooter: ret << "header & footer"; break;
|
case PIPacketExtractor::HeaderAndFooter: ts << "header & footer"; break;
|
||||||
case PIPacketExtractor::Size: ret << "size"; break;
|
case PIPacketExtractor::Size: ts << "size"; break;
|
||||||
case PIPacketExtractor::Timeout: ret << "timeout"; break;
|
case PIPacketExtractor::Timeout: ts << "timeout"; break;
|
||||||
}
|
}
|
||||||
ret << " #s\n";
|
ts << " #s\n";
|
||||||
ret << prefix << ".payloadSize = " << f.second->extractor->payloadSize() << " #n\n";
|
ts << prefix << ".payloadSize = " << f.second->extractor->payloadSize() << " #n\n";
|
||||||
ret << prefix << ".packetSize = " << f.second->extractor->packetSize() << " #n\n";
|
ts << prefix << ".packetSize = " << f.second->extractor->packetSize() << " #n\n";
|
||||||
ret << prefix << ".timeout = " << f.second->extractor->timeout() << " #f\n";
|
ts << prefix << ".timeout = " << f.second->extractor->timeout() << " #f\n";
|
||||||
ret << prefix << ".header = " << f.second->extractor->header().toString() << " #s\n";
|
ts << prefix << ".header = " << f.second->extractor->header().toString() << " #s\n";
|
||||||
ret << prefix << ".footer = " << f.second->extractor->footer().toString() << " #s\n";
|
ts << prefix << ".footer = " << f.second->extractor->footer().toString() << " #s\n";
|
||||||
}
|
}
|
||||||
dn = 0;
|
dn = 0;
|
||||||
piForeachC (CPair & c, channels_) {
|
piForeachC (CPair & c, channels_) {
|
||||||
@@ -308,10 +310,10 @@ PIString PIConnection::makeConfig() const {
|
|||||||
PIString prefix = "channel." + PIString::fromNumber(dn); ++dn;
|
PIString prefix = "channel." + PIString::fromNumber(dn); ++dn;
|
||||||
PIString dname = device_names.key(c.first);
|
PIString dname = device_names.key(c.first);
|
||||||
if (dname.isEmpty()) dname = devPath(c.first);
|
if (dname.isEmpty()) dname = devPath(c.first);
|
||||||
ret << prefix << ".from = " << dname << " #s\n";
|
ts << prefix << ".from = " << dname << " #s\n";
|
||||||
dname = device_names.key(const_cast<PIIODevice *>(d));
|
dname = device_names.key(const_cast<PIIODevice *>(d));
|
||||||
if (dname.isEmpty()) dname = devPath(d);
|
if (dname.isEmpty()) dname = devPath(d);
|
||||||
ret << prefix << ".to = " << dname << " #s\n";
|
ts << prefix << ".to = " << dname << " #s\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
piForeachC (SPair & s, senders) {
|
piForeachC (SPair & s, senders) {
|
||||||
@@ -320,15 +322,15 @@ PIString PIConnection::makeConfig() const {
|
|||||||
for (int i = 0; i < s.second->devices.size_s(); ++i) {
|
for (int i = 0; i < s.second->devices.size_s(); ++i) {
|
||||||
PIString dname = device_names.key(s.second->devices[i]);
|
PIString dname = device_names.key(s.second->devices[i]);
|
||||||
if (dname.isEmpty()) dname = devPath(s.second->devices[i]);
|
if (dname.isEmpty()) dname = devPath(s.second->devices[i]);
|
||||||
ret << prefix << ".device." << i << " = " << dname << " #s\n";
|
ts << prefix << ".device." << i << " = " << dname << " #s\n";
|
||||||
}
|
}
|
||||||
double int_ = s.second->int_;
|
double int_ = s.second->int_;
|
||||||
if (int_ > 0.)
|
if (int_ > 0.)
|
||||||
ret << prefix << ".frequency = " << (1000. / int_) << " #f\n";
|
ts << prefix << ".frequency = " << (1000. / int_) << " #f\n";
|
||||||
if (!s.second->sdata.isEmpty())
|
if (!s.second->sdata.isEmpty())
|
||||||
ret << prefix << ".fixedData = " << s.second->sdata.toString() << " #s\n";
|
ts << prefix << ".fixedData = " << s.second->sdata.toString() << " #s\n";
|
||||||
}
|
}
|
||||||
ret << "[]\n";
|
ts << "[]\n";
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void PIResources::dump() {
|
|||||||
auto fi = si.value()->entries.makeIterator();
|
auto fi = si.value()->entries.makeIterator();
|
||||||
while (fi.next()) {
|
while (fi.next()) {
|
||||||
PIString s = fi.key() + ": ";
|
PIString s = fi.key() + ": ";
|
||||||
s << (fi.value() ? fi.value()->size_s() : 0) << " b";
|
s += PIString::fromNumber(fi.value() ? fi.value()->size_s() : 0) + " b";
|
||||||
piCout << " " << s;
|
piCout << " " << s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ PIStringList PIPluginLoader::pluginsDirectories(const PIString & name) {
|
|||||||
piForeachC (PIString d, dl) {
|
piForeachC (PIString d, dl) {
|
||||||
PIString dp = d + "/" + name;
|
PIString dp = d + "/" + name;
|
||||||
if (PIDir::isExists(dp))
|
if (PIDir::isExists(dp))
|
||||||
ret << dp;
|
ret += dp;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ PIOpenCL::Program * PIOpenCL::Context::createProgram(const PIString & source, co
|
|||||||
cl_program prog = clCreateProgramWithSource(PRIVATE->context, 1, &csrc, &src_size, &ret);
|
cl_program prog = clCreateProgramWithSource(PRIVATE->context, 1, &csrc, &src_size, &ret);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
piCout << "[PIOpenCL::Context]" << "clCreateProgramWithSource error" << ret;
|
piCout << "[PIOpenCL::Context]" << "clCreateProgramWithSource error" << ret;
|
||||||
if (error) (*error) << "clCreateProgramWithSource error " << ret;
|
if (error) (*error) += "clCreateProgramWithSource error " + PIString::fromNumber(ret);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PIString carg = (PIStringList(args) << "-cl-kernel-arg-info").join(' ');
|
PIString carg = (PIStringList(args) << "-cl-kernel-arg-info").join(' ');
|
||||||
@@ -286,7 +286,7 @@ PIOpenCL::Program * PIOpenCL::Context::createProgram(const PIString & source, co
|
|||||||
cl_kernel kern = clCreateKernel(prog, k.dataAscii(), &ret);
|
cl_kernel kern = clCreateKernel(prog, k.dataAscii(), &ret);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
piCout << "[PIOpenCL::Context]" << "clCreateKernel" << k << "error" << ret;
|
piCout << "[PIOpenCL::Context]" << "clCreateKernel" << k << "error" << ret;
|
||||||
if (error) (*error) << "clCreateKernel(\"" << k << "\") error " << ret;
|
if (error) (*error) += "clCreateKernel(\"" + k + "\") error " + ret;
|
||||||
piForeach (void* _k, kerns)
|
piForeach (void* _k, kerns)
|
||||||
clReleaseKernel((cl_kernel)_k);
|
clReleaseKernel((cl_kernel)_k);
|
||||||
clReleaseProgram(prog);
|
clReleaseProgram(prog);
|
||||||
|
|||||||
6
main.cpp
6
main.cpp
@@ -39,6 +39,12 @@ template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> &
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
|
PIString s = "str 1 2";
|
||||||
|
PIIOTextStream ts(&s);
|
||||||
|
PIString ss; int i, j;
|
||||||
|
ts >> ss >> i >> j;
|
||||||
|
piCout << s;
|
||||||
|
piCout << ss << i << j;
|
||||||
/*KMM::NS::Project p, p1;
|
/*KMM::NS::Project p, p1;
|
||||||
p.sms_path = "mypath";
|
p.sms_path = "mypath";
|
||||||
p.time_0 = "0.05";
|
p.time_0 = "0.05";
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ bool writeModel(PICodeParser & parser, PICLI & cli, const PIString out, bool met
|
|||||||
PIVector<PIString> incf = inc_files.toVector();
|
PIVector<PIString> incf = inc_files.toVector();
|
||||||
piForeachC (PIString & i, incf) {
|
piForeachC (PIString & i, incf) {
|
||||||
if ((i != parser.mainFile()) && (streams || texts || getters))
|
if ((i != parser.mainFile()) && (streams || texts || getters))
|
||||||
inc_string << "\n#include \"" << i << "\"";
|
inc_string += "\n#include \"" + i + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
PIFile f(out + ".cpp");
|
PIFile f(out + ".cpp");
|
||||||
|
|||||||
Reference in New Issue
Block a user