start moving to binarystream
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 39)
|
set(pip_MINOR 90)
|
||||||
set(pip_REVISION 0)
|
set(pip_REVISION 0)
|
||||||
set(pip_SUFFIX )
|
set(pip_SUFFIX )
|
||||||
set(pip_COMPANY SHS)
|
set(pip_COMPANY SHS)
|
||||||
|
|||||||
@@ -247,14 +247,18 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIKbdListener::KeyEvent & v) {s << v.key << v.modifiers; return s;}
|
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIKbdListener::MouseEvent & v) {s << v.x << v.y << (int)v.action << v.buttons << v.modifiers; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIKbdListener::MouseEvent & v) {s << v.x << v.y << (int)v.action << v.buttons << v.modifiers; return s;}
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIKbdListener::WheelEvent & v) {s << (*(PIKbdListener::MouseEvent*)&v) << (uchar)v.direction; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIKbdListener::WheelEvent & v) {s << (*(PIKbdListener::MouseEvent*)&v) << (uchar)v.direction; return s;}
|
||||||
|
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIKbdListener::KeyEvent & v) {s >> v.key >> v.modifiers; return s;}
|
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIKbdListener::MouseEvent & v) {int a(0); s >> v.x >> v.y >> a >> v.buttons >> v.modifiers; v.action = (PIKbdListener::MouseAction)a; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIKbdListener::MouseEvent & v) {int a(0); s >> v.x >> v.y >> a >> v.buttons >> v.modifiers; v.action = (PIKbdListener::MouseAction)a; return s;}
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIKbdListener::WheelEvent & v) {uchar d(0); s >> (*(PIKbdListener::MouseEvent*)&v) >> d; v.direction = d; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIKbdListener::WheelEvent & v) {uchar d(0); s >> (*(PIKbdListener::MouseEvent*)&v) >> d; v.direction = d; return s;}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE(PIKbdListener::MouseEvent) {s << v.x << v.y << v.action << v.buttons << v.modifiers; return s;}
|
||||||
|
BINARY_STREAM_RESTORE(PIKbdListener::MouseEvent) {s >> v.x >> v.y >> v.action >> v.buttons >> v.modifiers; return s;}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE(PIKbdListener::WheelEvent) {s << (*(PIKbdListener::MouseEvent*)&v) << v.direction; return s;}
|
||||||
|
BINARY_STREAM_RESTORE(PIKbdListener::WheelEvent) {s >> (*(PIKbdListener::MouseEvent*)&v) >> v.direction; return s;}
|
||||||
|
|
||||||
REGISTER_PIVARIANTSIMPLE(PIKbdListener::KeyEvent)
|
REGISTER_PIVARIANTSIMPLE(PIKbdListener::KeyEvent)
|
||||||
REGISTER_PIVARIANTSIMPLE(PIKbdListener::MouseEvent)
|
REGISTER_PIVARIANTSIMPLE(PIKbdListener::MouseEvent)
|
||||||
REGISTER_PIVARIANTSIMPLE(PIKbdListener::WheelEvent)
|
REGISTER_PIVARIANTSIMPLE(PIKbdListener::WheelEvent)
|
||||||
|
|||||||
@@ -143,12 +143,15 @@ namespace PIScreenTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIScreenTypes::Cell & v) {s << v.format.raw_format << v.symbol; return s;}
|
//inline PIByteArray & operator <<(PIByteArray & s, const PIScreenTypes::Cell & v) {s << v.format.raw_format << v.symbol; return s;}
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIScreenTypes::Cell & v) {s >> v.format.raw_format >> v.symbol; return s;}
|
//inline PIByteArray & operator >>(PIByteArray & s, PIScreenTypes::Cell & v) {s >> v.format.raw_format >> v.symbol; return s;}
|
||||||
|
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIScreenTypes::TileEvent & v) {s << v.type << v.data; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIScreenTypes::TileEvent & v) {s << v.type << v.data; return s;}
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIScreenTypes::TileEvent & v) {s >> v.type >> v.data; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIScreenTypes::TileEvent & v) {s >> v.type >> v.data; return s;}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE(PIScreenTypes::TileEvent) {s << v.type << v.data; return s;}
|
||||||
|
BINARY_STREAM_RESTORE(PIScreenTypes::TileEvent) {s >> v.type >> v.data; return s;}
|
||||||
|
|
||||||
REGISTER_PIVARIANTSIMPLE(PIScreenTypes::TileEvent)
|
REGISTER_PIVARIANTSIMPLE(PIScreenTypes::TileEvent)
|
||||||
|
|
||||||
#endif // PISCREENTYPES_H
|
#endif // PISCREENTYPES_H
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ class PIMap {
|
|||||||
template <typename Key1, typename T1> friend PIByteArray & operator >>(PIByteArray & s, PIMap<Key1, T1> & v);
|
template <typename Key1, typename T1> friend PIByteArray & operator >>(PIByteArray & s, PIMap<Key1, T1> & v);
|
||||||
template <typename Key1, typename T1> friend PIByteArray & operator <<(PIByteArray & s, const PIMap<Key1, T1> & v);
|
template <typename Key1, typename T1> friend PIByteArray & operator <<(PIByteArray & s, const PIMap<Key1, T1> & v);
|
||||||
template <typename Key1, typename T1> friend class PIMapIterator;
|
template <typename Key1, typename T1> friend class PIMapIterator;
|
||||||
|
template <typename P, typename Key1, typename T1>
|
||||||
|
friend PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMap<Key1, T1> & v);
|
||||||
|
template <typename P, typename Key1, typename T1>
|
||||||
|
friend PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIMap<Key1, T1> & v);
|
||||||
public:
|
public:
|
||||||
PIMap() {;}
|
PIMap() {;}
|
||||||
PIMap(const PIMap<Key, T> & other) {*this = other;}
|
PIMap(const PIMap<Key, T> & other) {*this = other;}
|
||||||
|
|||||||
@@ -31,6 +31,15 @@
|
|||||||
#include "pivector2d.h"
|
#include "pivector2d.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define BINARY_STREAM_FRIEND(T) \
|
||||||
|
template<typename P> friend PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const T & v); \
|
||||||
|
template<typename P> friend PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, T & v);
|
||||||
|
#define BINARY_STREAM_STORE(T) \
|
||||||
|
template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const T & v)
|
||||||
|
#define BINARY_STREAM_RESTORE(T) \
|
||||||
|
template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, T & v)
|
||||||
|
|
||||||
|
|
||||||
//! \ingroup Core
|
//! \ingroup Core
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
//! \~english Binary serialization interface.
|
//! \~english Binary serialization interface.
|
||||||
@@ -38,52 +47,52 @@
|
|||||||
template<typename P>
|
template<typename P>
|
||||||
class PIBinaryStream {
|
class PIBinaryStream {
|
||||||
public:
|
public:
|
||||||
// one should implements next methods:
|
// one should implement next methods:
|
||||||
//
|
//
|
||||||
// bool binaryStreamAppend(const void * d, size_t s);
|
// bool binaryStreamAppendImp(const void * d, size_t s);
|
||||||
// bool binaryStreamTake(void * d, size_t s);
|
// bool binaryStreamTakeImp ( void * d, size_t s);
|
||||||
|
|
||||||
bool append(const void * d, size_t s) {
|
bool binaryStreamAppend(const void * d, size_t s) {
|
||||||
if (!static_cast<P*>(this)->binaryStreamAppend(d, s)) {
|
if (!static_cast<P*>(this)->binaryStreamAppendImp(d, s)) {
|
||||||
return false;
|
return false;
|
||||||
printf("[PIBinaryStream] append() error\n");
|
printf("[PIBinaryStream] binaryStreamAppend() error\n");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool take(void * d, size_t s) {
|
bool binaryStreamTake(void * d, size_t s) {
|
||||||
if (!static_cast<P*>(this)->binaryStreamTake(d, s)) {
|
if (!static_cast<P*>(this)->binaryStreamTakeImp(d, s)) {
|
||||||
return false;
|
return false;
|
||||||
printf("[PIBinaryStream] take() error\n");
|
printf("[PIBinaryStream] binaryStreamTake() error\n");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void append(T v) {append(&v, sizeof(v));}
|
void binaryStreamAppend(T v) {binaryStreamAppend(&v, sizeof(v));}
|
||||||
uchar takeByte() {uchar r = 0; take(&r, sizeof(r)); return r;}
|
uchar binaryStreamTakeByte() {uchar r = 0; binaryStreamTake(&r, sizeof(r)); return r;}
|
||||||
int takeInt() {int r = 0; take(&r, sizeof(r)); return r;}
|
int binaryStreamTakeInt() {int r = 0; binaryStreamTake(&r, sizeof(r)); return r;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// helper class to detect default operators
|
// helper class to detect default operators
|
||||||
template<typename P>
|
template<typename P>
|
||||||
class PIBinaryStreamRef {
|
class PIBinaryStreamTrivialRef {
|
||||||
public:
|
public:
|
||||||
PIBinaryStreamRef(PIBinaryStream<P> & s): p(s) {}
|
PIBinaryStreamTrivialRef(PIBinaryStream<P> & s): p(s) {}
|
||||||
PIBinaryStream<P> & p;
|
PIBinaryStream<P> & p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<typename P, typename T> inline PIBinaryStream<P> & operator <<(PIBinaryStreamRef<P> s, const T & v) {s.p << v; return s.p;}
|
template<typename P, typename T> inline PIBinaryStream<P> & operator <<(PIBinaryStreamTrivialRef<P> s, const T & v) {s.p << v; return s.p;}
|
||||||
template<typename P, typename T> inline PIBinaryStream<P> & operator >>(PIBinaryStreamRef<P> s, T & v) {s.p >> v; return s.p;}
|
template<typename P, typename T> inline PIBinaryStream<P> & operator >>(PIBinaryStreamTrivialRef<P> s, T & v) {s.p >> v; return s.p;}
|
||||||
|
|
||||||
|
|
||||||
// small types
|
// small types
|
||||||
template<typename P> inline PIBinaryStreamRef<P> operator <<(PIBinaryStream<P> & s, const bool v) {s.append((uchar)v); return s;}
|
template<typename P> inline PIBinaryStreamTrivialRef<P> operator <<(PIBinaryStream<P> & s, const bool v) {s.binaryStreamAppend((uchar)v); return s;}
|
||||||
template<typename P> inline PIBinaryStreamRef<P> operator <<(PIBinaryStream<P> & s, const char v) {s.append((uchar)v); return s;}
|
template<typename P> inline PIBinaryStreamTrivialRef<P> operator <<(PIBinaryStream<P> & s, const char v) {s.binaryStreamAppend((uchar)v); return s;}
|
||||||
template<typename P> inline PIBinaryStreamRef<P> operator <<(PIBinaryStream<P> & s, const uchar v) {s.append((uchar)v); return s;}
|
template<typename P> inline PIBinaryStreamTrivialRef<P> operator <<(PIBinaryStream<P> & s, const uchar v) {s.binaryStreamAppend((uchar)v); return s;}
|
||||||
template<typename P> inline PIBinaryStreamRef<P> operator >>(PIBinaryStream<P> & s, bool & v) {v = s.takeByte(); return s;}
|
template<typename P> inline PIBinaryStreamTrivialRef<P> operator >>(PIBinaryStream<P> & s, bool & v) {v = s.binaryStreamTakeByte(); return s;}
|
||||||
template<typename P> inline PIBinaryStreamRef<P> operator >>(PIBinaryStream<P> & s, char & v) {v = s.takeByte(); return s;}
|
template<typename P> inline PIBinaryStreamTrivialRef<P> operator >>(PIBinaryStream<P> & s, char & v) {v = s.binaryStreamTakeByte(); return s;}
|
||||||
template<typename P> inline PIBinaryStreamRef<P> operator >>(PIBinaryStream<P> & s, uchar & v) {v = s.takeByte(); return s;}
|
template<typename P> inline PIBinaryStreamTrivialRef<P> operator >>(PIBinaryStream<P> & s, uchar & v) {v = s.binaryStreamTakeByte(); return s;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -91,9 +100,20 @@ template<typename P> inline PIBinaryStreamRef<P> operator >>(PIBinaryStream<P> &
|
|||||||
// store simple types
|
// store simple types
|
||||||
|
|
||||||
|
|
||||||
template<typename P, typename T, typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
|
template<typename P, typename T,
|
||||||
inline PIBinaryStreamRef<P> operator <<(PIBinaryStream<P> & s, const T & v) {
|
typename std::enable_if<std::is_enum<T>::value, int>::type = 0>
|
||||||
s.append(&v, sizeof(v));
|
inline PIBinaryStreamTrivialRef<P> operator <<(PIBinaryStream<P> & s, const T & v) {
|
||||||
|
//piCout << "<< enum";
|
||||||
|
s.binaryStreamAppend((int)v);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename P, typename T,
|
||||||
|
typename std::enable_if<!std::is_enum<T>::value, int>::type = 0,
|
||||||
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||||
|
inline PIBinaryStreamTrivialRef<P> operator <<(PIBinaryStream<P> & s, const T & v) {
|
||||||
|
s.binaryStreamAppend(&v, sizeof(v));
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,19 +122,19 @@ inline PIBinaryStreamRef<P> operator <<(PIBinaryStream<P> & s, const T & v) {
|
|||||||
//! \~russian Оператор сохранения для PIVector тривиальных типов
|
//! \~russian Оператор сохранения для PIVector тривиальных типов
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector<T> & v) {
|
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector<T> & v) {
|
||||||
piCout << "<< vector trivial default";
|
//piCout << "<< vector trivial default";
|
||||||
s.append((int)v.size());
|
s.binaryStreamAppend((int)v.size());
|
||||||
s.append(v.data(), v.size() * sizeof(T));
|
s.binaryStreamAppend(v.data(), v.size() * sizeof(T));
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector<T> & v) {
|
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector<T> & v) {
|
||||||
piCout << "<< vector trivial custom";
|
//piCout << "<< vector trivial custom";
|
||||||
s.append((int)v.size());
|
s.binaryStreamAppend((int)v.size());
|
||||||
for (size_t i = 0; i < v.size(); ++i) s << v[i];
|
for (size_t i = 0; i < v.size(); ++i) s << v[i];
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -124,19 +144,19 @@ inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector<T>
|
|||||||
//! \~russian Оператор сохранения для PIDeque тривиальных типов
|
//! \~russian Оператор сохранения для PIDeque тривиальных типов
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<T> & v) {
|
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<T> & v) {
|
||||||
piCout << "<< deque trivial default";
|
//piCout << "<< deque trivial default";
|
||||||
s.append((int)v.size());
|
s.binaryStreamAppend((int)v.size());
|
||||||
s.append(v.data(), v.size() * sizeof(T));
|
s.binaryStreamAppend(v.data(), v.size() * sizeof(T));
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<T> & v) {
|
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<T> & v) {
|
||||||
piCout << "<< deque trivial custom";
|
//piCout << "<< deque trivial custom";
|
||||||
s.append((int)v.size());
|
s.binaryStreamAppend((int)v.size());
|
||||||
for (size_t i = 0; i < v.size(); ++i) s << v[i];
|
for (size_t i = 0; i < v.size(); ++i) s << v[i];
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -146,21 +166,21 @@ inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<T> &
|
|||||||
//! \~russian Оператор сохранения для PIVector2D тривиальных типов
|
//! \~russian Оператор сохранения для PIVector2D тривиальных типов
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector2D<T> & v) {
|
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector2D<T> & v) {
|
||||||
piCout << "<< vector2d trivial default";
|
//piCout << "<< vector2d trivial default";
|
||||||
s.append((int)v.rows());
|
s.binaryStreamAppend((int)v.rows());
|
||||||
s.append((int)v.cols());
|
s.binaryStreamAppend((int)v.cols());
|
||||||
s.append(v.data(), v.size() * sizeof(T));
|
s.binaryStreamAppend(v.data(), v.size() * sizeof(T));
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() << std::declval<const T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector2D<T> & v) {
|
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector2D<T> & v) {
|
||||||
piCout << "<< vector2d trivial custom";
|
//piCout << "<< vector2d trivial custom";
|
||||||
s.append((int)v.rows());
|
s.binaryStreamAppend((int)v.rows());
|
||||||
s.append((int)v.cols());
|
s.binaryStreamAppend((int)v.cols());
|
||||||
s << v.toPlainVector();
|
s << v.toPlainVector();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -183,9 +203,20 @@ inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIPair<Type0
|
|||||||
// restore simple types
|
// restore simple types
|
||||||
|
|
||||||
|
|
||||||
template<typename P, typename T, typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
|
template<typename P, typename T,
|
||||||
inline PIBinaryStreamRef<P> operator >>(PIBinaryStream<P> & s, T & v) {
|
typename std::enable_if<std::is_enum<T>::value, int>::type = 0>
|
||||||
if (!s.take(&v, sizeof(v))) {
|
inline PIBinaryStreamTrivialRef<P> operator >>(PIBinaryStream<P> & s, T & v) {
|
||||||
|
//piCout << ">> enum";
|
||||||
|
v = (T)s.binaryStreamTakeInt();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename P, typename T,
|
||||||
|
typename std::enable_if<!std::is_enum<T>::value, int>::type = 0,
|
||||||
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||||
|
inline PIBinaryStreamTrivialRef<P> operator >>(PIBinaryStream<P> & s, T & v) {
|
||||||
|
if (!s.binaryStreamTake(&v, sizeof(v))) {
|
||||||
printf("error with %s\n", __PIP_TYPENAME__(T));
|
printf("error with %s\n", __PIP_TYPENAME__(T));
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@@ -197,12 +228,12 @@ inline PIBinaryStreamRef<P> operator >>(PIBinaryStream<P> & s, T & v) {
|
|||||||
//! \~russian Оператор извлечения для PIVector тривиальных типов
|
//! \~russian Оператор извлечения для PIVector тривиальных типов
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
||||||
piCout << ">> vector trivial default";
|
//piCout << ">> vector trivial default";
|
||||||
int sz = s.takeInt();
|
int sz = s.binaryStreamTakeInt();
|
||||||
v._resizeRaw(sz);
|
v._resizeRaw(sz);
|
||||||
if (!s.take(v.data(), sz * sizeof(T))) {
|
if (!s.binaryStreamTake(v.data(), sz * sizeof(T))) {
|
||||||
printf("error with PIVector<%s>\n", __PIP_TYPENAME__(T));
|
printf("error with PIVector<%s>\n", __PIP_TYPENAME__(T));
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@@ -210,10 +241,10 @@ inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
|||||||
}
|
}
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
||||||
piCout << ">> vector trivial custom";
|
//piCout << ">> vector trivial custom";
|
||||||
int sz = s.takeInt();
|
int sz = s.binaryStreamTakeInt();
|
||||||
v._resizeRaw(sz);
|
v._resizeRaw(sz);
|
||||||
for (int i = 0; i < sz; ++i) s >> v[i];
|
for (int i = 0; i < sz; ++i) s >> v[i];
|
||||||
return s;
|
return s;
|
||||||
@@ -224,12 +255,12 @@ inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
|||||||
//! \~russian Оператор извлечения для PIDeque тривиальных типов
|
//! \~russian Оператор извлечения для PIDeque тривиальных типов
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
||||||
piCout << ">> deque trivial default";
|
//piCout << ">> deque trivial default";
|
||||||
int sz = s.takeInt();
|
int sz = s.binaryStreamTakeInt();
|
||||||
v._resizeRaw(sz);
|
v._resizeRaw(sz);
|
||||||
if (!s.take(v.data(), sz * sizeof(T))) {
|
if (!s.binaryStreamTake(v.data(), sz * sizeof(T))) {
|
||||||
printf("error with PIDeque<%s>\n", __PIP_TYPENAME__(T));
|
printf("error with PIDeque<%s>\n", __PIP_TYPENAME__(T));
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@@ -237,10 +268,10 @@ inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
|||||||
}
|
}
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
||||||
piCout << ">> deque trivial custom";
|
//piCout << ">> deque trivial custom";
|
||||||
int sz = s.takeInt();
|
int sz = s.binaryStreamTakeInt();
|
||||||
v._resizeRaw(sz);
|
v._resizeRaw(sz);
|
||||||
for (int i = 0; i < sz; ++i) s >> v[i];
|
for (int i = 0; i < sz; ++i) s >> v[i];
|
||||||
return s;
|
return s;
|
||||||
@@ -251,14 +282,14 @@ inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
|||||||
//! \~russian Оператор извлечения для PIVector2D тривиальных типов
|
//! \~russian Оператор извлечения для PIVector2D тривиальных типов
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if< std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector2D<T> & v) {
|
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector2D<T> & v) {
|
||||||
piCout << ">> vector2d trivial default";
|
//piCout << ">> vector2d trivial default";
|
||||||
int r, c;
|
int r, c;
|
||||||
r = s.takeInt();
|
r = s.binaryStreamTakeInt();
|
||||||
c = s.takeInt();
|
c = s.binaryStreamTakeInt();
|
||||||
v._resizeRaw(r, c);
|
v._resizeRaw(r, c);
|
||||||
if (!s.take(v.data(), v.size() * sizeof(T))) {
|
if (!s.binaryStreamTake(v.data(), v.size() * sizeof(T))) {
|
||||||
printf("error with PIVector2D<%s>\n", __PIP_TYPENAME__(T));
|
printf("error with PIVector2D<%s>\n", __PIP_TYPENAME__(T));
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@@ -266,13 +297,13 @@ inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector2D<T> & v)
|
|||||||
}
|
}
|
||||||
template<typename P, typename T,
|
template<typename P, typename T,
|
||||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||||
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamRef<P>>::value, int>::type = 0>
|
typename std::enable_if<!std::is_same<decltype(std::declval<PIBinaryStream<P>&>() >> std::declval<T &>()), PIBinaryStreamTrivialRef<P>>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector2D<T> & v) {
|
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector2D<T> & v) {
|
||||||
piCout << ">> vector2d trivial custom";
|
//piCout << ">> vector2d trivial custom";
|
||||||
int r, c;
|
int r, c;
|
||||||
PIVector<T> tmp;
|
PIVector<T> tmp;
|
||||||
r = s.takeInt();
|
r = s.binaryStreamTakeInt();
|
||||||
c = s.takeInt();
|
c = s.binaryStreamTakeInt();
|
||||||
s >> tmp;
|
s >> tmp;
|
||||||
v = PIVector2D<T>(r, c, tmp);
|
v = PIVector2D<T>(r, c, tmp);
|
||||||
return s;
|
return s;
|
||||||
@@ -289,8 +320,8 @@ inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector2D<T> & v)
|
|||||||
//! \~russian Оператор сохранения для PIVector сложных типов
|
//! \~russian Оператор сохранения для PIVector сложных типов
|
||||||
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector<T> & v) {
|
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector<T> & v) {
|
||||||
piCout << "<< vector complex";
|
//piCout << "<< vector complex";
|
||||||
s.append(int(v.size_s()));
|
s.binaryStreamAppend(int(v.size_s()));
|
||||||
for (size_t i = 0; i < v.size(); ++i) s << v[i];
|
for (size_t i = 0; i < v.size(); ++i) s << v[i];
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -300,8 +331,8 @@ inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector<T>
|
|||||||
//! \~russian Оператор сохранения для PIDeque сложных типов
|
//! \~russian Оператор сохранения для PIDeque сложных типов
|
||||||
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<T> & v) {
|
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<T> & v) {
|
||||||
piCout << "<< deque complex";
|
//piCout << "<< deque complex";
|
||||||
s.append(int(v.size_s()));
|
s.binaryStreamAppend(int(v.size_s()));
|
||||||
for (size_t i = 0; i < v.size(); ++i) s << v[i];
|
for (size_t i = 0; i < v.size(); ++i) s << v[i];
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -311,9 +342,9 @@ inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<T> &
|
|||||||
//! \~russian Оператор сохранения для PIVector2D сложных типов
|
//! \~russian Оператор сохранения для PIVector2D сложных типов
|
||||||
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector2D<T> & v) {
|
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector2D<T> & v) {
|
||||||
piCout << "<< vector2d complex";
|
//piCout << "<< vector2d complex";
|
||||||
s.append(int(v.rows()));
|
s.binaryStreamAppend(int(v.rows()));
|
||||||
s.append(int(v.cols()));
|
s.binaryStreamAppend(int(v.cols()));
|
||||||
s << v.toPlainVector();
|
s << v.toPlainVector();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -328,12 +359,12 @@ inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVector2D<T
|
|||||||
//! \~russian Оператор извлечения для PIVector сложных типов
|
//! \~russian Оператор извлечения для PIVector сложных типов
|
||||||
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
||||||
piCout << ">> vector complex";
|
//piCout << ">> vector complex";
|
||||||
/*if (s.size_s() < 4) {
|
/*if (s.size_s() < 4) {
|
||||||
printf("error with PIVector<%s>\n", __PIP_TYPENAME__(T));
|
printf("error with PIVector<%s>\n", __PIP_TYPENAME__(T));
|
||||||
assert(s.size_s() >= 4);
|
assert(s.size_s() >= 4);
|
||||||
}*/
|
}*/
|
||||||
v.resize(s.takeInt());
|
v.resize(s.binaryStreamTakeInt());
|
||||||
for (size_t i = 0; i < v.size(); ++i) s >> v[i];
|
for (size_t i = 0; i < v.size(); ++i) s >> v[i];
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -343,12 +374,12 @@ inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector<T> & v) {
|
|||||||
//! \~russian Оператор извлечения для PIDeque сложных типов
|
//! \~russian Оператор извлечения для PIDeque сложных типов
|
||||||
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
||||||
piCout << ">> deque complex";
|
//piCout << ">> deque complex";
|
||||||
/*if (s.size_s() < 4) {
|
/*if (s.size_s() < 4) {
|
||||||
printf("error with PIDeque<%s>\n", __PIP_TYPENAME__(T));
|
printf("error with PIDeque<%s>\n", __PIP_TYPENAME__(T));
|
||||||
assert(s.size_s() >= 4);
|
assert(s.size_s() >= 4);
|
||||||
}*/
|
}*/
|
||||||
v.resize(s.takeInt());
|
v.resize(s.binaryStreamTakeInt());
|
||||||
for (size_t i = 0; i < v.size(); ++i) s >> v[i];
|
for (size_t i = 0; i < v.size(); ++i) s >> v[i];
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -358,15 +389,15 @@ inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIDeque<T> & v) {
|
|||||||
//! \~russian Оператор извлечения для PIVector2D сложных типов
|
//! \~russian Оператор извлечения для PIVector2D сложных типов
|
||||||
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
template<typename P, typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector2D<T> & v) {
|
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector2D<T> & v) {
|
||||||
piCout << ">> vector2d complex";
|
//piCout << ">> vector2d complex";
|
||||||
/*if (s.size_s() < 8) {
|
/*if (s.size_s() < 8) {
|
||||||
printf("error with PIVecto2Dr<%s>\n", __PIP_TYPENAME__(T));
|
printf("error with PIVecto2Dr<%s>\n", __PIP_TYPENAME__(T));
|
||||||
assert(s.size_s() >= 8);
|
assert(s.size_s() >= 8);
|
||||||
}*/
|
}*/
|
||||||
int r, c;
|
int r, c;
|
||||||
PIVector<T> tmp;
|
PIVector<T> tmp;
|
||||||
r = s.takeInt();
|
r = s.binaryStreamTakeInt();
|
||||||
c = s.takeInt();
|
c = s.binaryStreamTakeInt();
|
||||||
s >> tmp;
|
s >> tmp;
|
||||||
v = PIVector2D<T>(r, c, tmp);
|
v = PIVector2D<T>(r, c, tmp);
|
||||||
return s;
|
return s;
|
||||||
@@ -382,9 +413,9 @@ inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVector2D<T> & v)
|
|||||||
//! \~russian Оператор сохранения
|
//! \~russian Оператор сохранения
|
||||||
template <typename P, typename Key, typename T>
|
template <typename P, typename Key, typename T>
|
||||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMap<Key, T> & v) {
|
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMap<Key, T> & v) {
|
||||||
s.append((int)v.pim_index.size_s());
|
s.binaryStreamAppend((int)v.pim_index.size_s());
|
||||||
for (uint i = 0; i < v.size(); ++i) {
|
for (uint i = 0; i < v.size(); ++i) {
|
||||||
s.append((int)v.pim_index[i].index);
|
s.binaryStreamAppend((int)v.pim_index[i].index);
|
||||||
s << v.pim_index[i].key;
|
s << v.pim_index[i].key;
|
||||||
}
|
}
|
||||||
s << v.pim_content;
|
s << v.pim_content;
|
||||||
@@ -400,10 +431,10 @@ inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIMap<Key, T> & v)
|
|||||||
printf("error with PIMap<%s, %s>\n", __PIP_TYPENAME__(Key), __PIP_TYPENAME__(T));
|
printf("error with PIMap<%s, %s>\n", __PIP_TYPENAME__(Key), __PIP_TYPENAME__(T));
|
||||||
assert(s.size_s() >= 4);
|
assert(s.size_s() >= 4);
|
||||||
}*/
|
}*/
|
||||||
int sz = s.takeInt(); v.pim_index.resize(sz);
|
int sz = s.binaryStreamTakeInt(); v.pim_index.resize(sz);
|
||||||
int ind = 0;
|
int ind = 0;
|
||||||
for (int i = 0; i < sz; ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
ind = s.takeInt();
|
ind = s.binaryStreamTakeInt();
|
||||||
s >> v.pim_index[i].key;
|
s >> v.pim_index[i].key;
|
||||||
v.pim_index[i].index = ind;
|
v.pim_index[i].index = ind;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,7 @@
|
|||||||
#define PIBYTEARRAY_H
|
#define PIBYTEARRAY_H
|
||||||
|
|
||||||
#include "pichar.h"
|
#include "pichar.h"
|
||||||
#include "pibitarray.h"
|
#include "pibinarystream.h"
|
||||||
#include "pimap.h"
|
|
||||||
#include "pivector2d.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
class PIString;
|
class PIString;
|
||||||
@@ -79,12 +77,15 @@ public:
|
|||||||
public:
|
public:
|
||||||
//! \~english Constructs data block
|
//! \~english Constructs data block
|
||||||
//! \~russian Создает блок данных
|
//! \~russian Создает блок данных
|
||||||
RawData(void * data = 0, int size = 0) {d = data; s = size;}
|
RawData(void * data_ = 0, int size_ = 0) {d = data_; s = size_;}
|
||||||
RawData(const RawData & o) {d = o.d; s = o.s;}
|
RawData(const RawData & o) {d = o.d; s = o.s;}
|
||||||
//! \~english Constructs data block
|
//! \~english Constructs data block
|
||||||
//! \~russian Создает блок данных
|
//! \~russian Создает блок данных
|
||||||
RawData(const void * data, const int size) {d = const_cast<void * >(data); s = size;}
|
RawData(const void * data_, const int size_) {d = const_cast<void * >(data_); s = size_;}
|
||||||
RawData & operator =(const RawData & o) {d = o.d; s = o.s; return *this;}
|
RawData & operator =(const RawData & o) {d = o.d; s = o.s; return *this;}
|
||||||
|
void * data() {return d;}
|
||||||
|
const void * data() const {return d;}
|
||||||
|
int size() const {return s;}
|
||||||
private:
|
private:
|
||||||
void * d;
|
void * d;
|
||||||
int s;
|
int s;
|
||||||
@@ -676,6 +677,30 @@ inline PIByteArray & operator >>(PIByteArray & s, T & ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE(PIByteArray::RawData) {
|
||||||
|
s.binaryStreamAppend(v.data(), v.size());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
BINARY_STREAM_RESTORE(PIByteArray::RawData) {
|
||||||
|
s.binaryStreamTake(v.data(), v.size());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE(PIByteArray) {
|
||||||
|
s.binaryStreamAppend((int)v.size_s());
|
||||||
|
s.binaryStreamAppend(v.data(), v.size());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
BINARY_STREAM_RESTORE(PIByteArray) {
|
||||||
|
v.resize(s.binaryStreamTakeInt());
|
||||||
|
s.binaryStreamTake(v.data(), v.size());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! \relatesalso PIByteArray
|
//! \relatesalso PIByteArray
|
||||||
//! \~english Returns PIByteArray::hash() of "ba"
|
//! \~english Returns PIByteArray::hash() of "ba"
|
||||||
//! \~russian Возвращает PIByteArray::hash() от "ba"
|
//! \~russian Возвращает PIByteArray::hash() от "ba"
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class PIMutexLocker;
|
|||||||
class PIObject;
|
class PIObject;
|
||||||
class PIString;
|
class PIString;
|
||||||
class PIByteArray;
|
class PIByteArray;
|
||||||
|
template <typename P> class PIBinaryStream;
|
||||||
#ifndef MICRO_PIP
|
#ifndef MICRO_PIP
|
||||||
class PIInit;
|
class PIInit;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -273,8 +273,12 @@ protected:
|
|||||||
|
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIPropertyStorage::Property & v) {s << v.name << v.value << v.comment << v.flags; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIPropertyStorage::Property & v) {s << v.name << v.value << v.comment << v.flags; return s;}
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIPropertyStorage::Property & v) {s >> v.name >> v.value >> v.comment >> v.flags; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIPropertyStorage::Property & v) {s >> v.name >> v.value >> v.comment >> v.flags; return s;}
|
||||||
|
template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIPropertyStorage::Property & v) {s << v.name << v.value << v.comment << v.flags; return s;}
|
||||||
|
template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIPropertyStorage::Property & v) {s >> v.name >> v.value >> v.comment >> v.flags; return s;}
|
||||||
|
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIPropertyStorage & v) {s << v.properties(); return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIPropertyStorage & v) {s << v.properties(); return s;}
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIPropertyStorage & v) {s >> v.properties(); return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIPropertyStorage & v) {s >> v.properties(); return s;}
|
||||||
|
template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIPropertyStorage & v) {s << v.properties(); return s;}
|
||||||
|
template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIPropertyStorage & v) {s >> v.properties(); return s;}
|
||||||
|
|
||||||
#endif // PIPROPERTYSTORAGE_H
|
#endif // PIPROPERTYSTORAGE_H
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class PIP_EXPORT PIString
|
|||||||
{
|
{
|
||||||
friend PIByteArray & operator >>(PIByteArray & s, PIString & v);
|
friend PIByteArray & operator >>(PIByteArray & s, PIString & v);
|
||||||
friend PIByteArray & operator <<(PIByteArray & s, const PIString & v);
|
friend PIByteArray & operator <<(PIByteArray & s, const PIString & v);
|
||||||
|
BINARY_STREAM_FRIEND(PIString);
|
||||||
public:
|
public:
|
||||||
typedef PIDeque<PIChar>::iterator iterator;
|
typedef PIDeque<PIChar>::iterator iterator;
|
||||||
typedef PIDeque<PIChar>::const_iterator const_iterator;
|
typedef PIDeque<PIChar>::const_iterator const_iterator;
|
||||||
@@ -1584,11 +1585,13 @@ PIP_EXPORT PICout operator <<(PICout s, const PIString & v);
|
|||||||
//! \~english Store operator.
|
//! \~english Store operator.
|
||||||
//! \~russian Оператор сохранения.
|
//! \~russian Оператор сохранения.
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIString & v) {s << v.d; return s;}
|
inline PIByteArray & operator <<(PIByteArray & s, const PIString & v) {s << v.d; return s;}
|
||||||
|
BINARY_STREAM_STORE(PIString) {s << v.d; return s;}
|
||||||
|
|
||||||
//! \relatesalso PIByteArray
|
//! \relatesalso PIByteArray
|
||||||
//! \~english Restore operator.
|
//! \~english Restore operator.
|
||||||
//! \~russian Оператор извлечения.
|
//! \~russian Оператор извлечения.
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIString & v) {v.d.clear(); s >> v.d; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIString & v) {v.d.clear(); s >> v.d; return s;}
|
||||||
|
BINARY_STREAM_RESTORE(PIString) {v.d.clear(); s >> v.d; return s;}
|
||||||
|
|
||||||
|
|
||||||
//! \~english Returns concatenated string.
|
//! \~english Returns concatenated string.
|
||||||
|
|||||||
@@ -136,6 +136,21 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIStringList & v) {s <<
|
|||||||
//! \~russian Оператор извлечения
|
//! \~russian Оператор извлечения
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIStringList & v) {int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIStringList & v) {int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
|
||||||
|
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE(PIStringList) {
|
||||||
|
s.binaryStreamAppend(v.size());
|
||||||
|
for (int i = 0; i < v.size_s(); ++i)
|
||||||
|
s << v[i];
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
BINARY_STREAM_RESTORE(PIStringList) {
|
||||||
|
v.resize(s.binaryStreamTakeInt());
|
||||||
|
for (int i = 0; i < v.size_s(); ++i)
|
||||||
|
s >> v[i];
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! \relatesalso PICout
|
//! \relatesalso PICout
|
||||||
//! \~english Output operator to \a PICout
|
//! \~english Output operator to \a PICout
|
||||||
//! \~russian Оператор вывода в \a PICout
|
//! \~russian Оператор вывода в \a PICout
|
||||||
|
|||||||
@@ -803,6 +803,36 @@ inline PIByteArray & operator >>(PIByteArray & s, PIVariant & v) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVariant & v) {
|
||||||
|
s << v._content << int(v._type);
|
||||||
|
if (v._type == PIVariant::pivCustom) {
|
||||||
|
#ifdef CUSTOM_PIVARIANT
|
||||||
|
if (v._info) {
|
||||||
|
s << v._info->typeName;
|
||||||
|
} else {
|
||||||
|
s << PIStringAscii("");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
s << PIStringAscii("");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVariant & v) {
|
||||||
|
int t(0);
|
||||||
|
s >> v._content >> t;
|
||||||
|
v._type = (PIVariant::Type)t;
|
||||||
|
if (v._type == PIVariant::pivCustom) {
|
||||||
|
PIString tn;
|
||||||
|
s >> tn;
|
||||||
|
#ifdef CUSTOM_PIVARIANT
|
||||||
|
PIByteArray vc = v._content;
|
||||||
|
v = PIVariant::fromValue(vc, tn);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
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.setControl(0, true);
|
||||||
s << "PIVariant(" << v.typeName();
|
s << "PIVariant(" << v.typeName();
|
||||||
|
|||||||
@@ -188,4 +188,22 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIVariantTypes::IODevice
|
|||||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::IODevice & v) {s >> v.prefix >> v.mode >> v.options >> v.props; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::IODevice & v) {s >> v.prefix >> v.mode >> v.options >> v.props; 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;}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE (PIVariantTypes::Enumerator) {s << v.value << v.name; return s;}
|
||||||
|
BINARY_STREAM_RESTORE(PIVariantTypes::Enumerator) {s >> v.value >> v.name; return s;}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE (PIVariantTypes::Enum) {s << v.enum_name << v.selected << v.enum_list; return s;}
|
||||||
|
BINARY_STREAM_RESTORE(PIVariantTypes::Enum) {s >> v.enum_name >> v.selected >> v.enum_list; return s;}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE (PIVariantTypes::File) {s << v.file << v.filter << uchar((v.is_abs ? 1 : 0) + (v.is_save ? 2 : 0)); return s;}
|
||||||
|
BINARY_STREAM_RESTORE(PIVariantTypes::File) {uchar f(0); s >> v.file >> v.filter >> f; v.is_abs = ((f & 1) == 1); v.is_save = ((f & 2) == 2); return s;}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE (PIVariantTypes::Dir) {s << v.dir << v.is_abs; return s;}
|
||||||
|
BINARY_STREAM_RESTORE(PIVariantTypes::Dir) {s >> v.dir >> v.is_abs; return s;}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE (PIVariantTypes::Color) {s << v.rgba; return s;}
|
||||||
|
BINARY_STREAM_RESTORE(PIVariantTypes::Color) {s >> v.rgba; return s;}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE (PIVariantTypes::IODevice) {s << v.prefix << v.mode << v.options << v.props; return s;}
|
||||||
|
BINARY_STREAM_RESTORE(PIVariantTypes::IODevice) {s >> v.prefix >> v.mode >> v.options >> v.props; return s;}
|
||||||
|
|
||||||
#endif // PIVARIANTYPES_H
|
#endif // PIVARIANTYPES_H
|
||||||
|
|||||||
@@ -68,4 +68,13 @@ public:
|
|||||||
PIP_EXPORT PIByteArray & operator <<(PIByteArray & s, const PIIntrospectionContainers::TypeInfo & v);
|
PIP_EXPORT PIByteArray & operator <<(PIByteArray & s, const PIIntrospectionContainers::TypeInfo & v);
|
||||||
PIP_EXPORT PIByteArray & operator >>(PIByteArray & s, PIIntrospectionContainers::TypeInfo & v);
|
PIP_EXPORT PIByteArray & operator >>(PIByteArray & s, PIIntrospectionContainers::TypeInfo & v);
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE (PIIntrospectionContainers::TypeInfo) {
|
||||||
|
s << PIByteArray::RawData(&v, sizeof(PIIntrospectionContainers::_Type)) << v.name;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
BINARY_STREAM_RESTORE(PIIntrospectionContainers::TypeInfo) {
|
||||||
|
s >> PIByteArray::RawData(&v, sizeof(PIIntrospectionContainers::_Type)) >> v.name;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PIINTROSPECTION_CONTAINERS_P_H
|
#endif // PIINTROSPECTION_CONTAINERS_P_H
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "piintrospection_containers_p.h"
|
#include "piintrospection_containers_p.h"
|
||||||
#include "piintrospection_threads.h"
|
#include "piintrospection_threads.h"
|
||||||
#include "piintrospection_threads_p.h"
|
#include "piintrospection_threads_p.h"
|
||||||
|
#include "pichunkstream.h"
|
||||||
#include "pisystemmonitor.h"
|
#include "pisystemmonitor.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -100,4 +101,72 @@ PIP_EXPORT PIByteArray & operator >>(PIByteArray & b, PIIntrospection::ProcessIn
|
|||||||
PIP_EXPORT PIByteArray & operator <<(PIByteArray & b, const PIIntrospection::ObjectInfo & v);
|
PIP_EXPORT PIByteArray & operator <<(PIByteArray & b, const PIIntrospection::ObjectInfo & v);
|
||||||
PIP_EXPORT PIByteArray & operator >>(PIByteArray & b, PIIntrospection::ObjectInfo & v);
|
PIP_EXPORT PIByteArray & operator >>(PIByteArray & b, PIIntrospection::ObjectInfo & v);
|
||||||
|
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE (PIIntrospection::RequiredInfo) {
|
||||||
|
PIChunkStream cs;
|
||||||
|
cs.add(1, v.types);
|
||||||
|
s << cs.data();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
BINARY_STREAM_RESTORE(PIIntrospection::RequiredInfo) {
|
||||||
|
PIByteArray csba; s >> csba;
|
||||||
|
PIChunkStream cs(csba);
|
||||||
|
while (!cs.atEnd()) {
|
||||||
|
switch (cs.read()) {
|
||||||
|
case 1: cs.get(v.types); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE (PIIntrospection::ProcessInfo) {
|
||||||
|
PIChunkStream cs;
|
||||||
|
cs.add(1, v.architecture).add(2, v.execCommand).add(3, v.execDateTime).add(4, v.hostname).add(5, v.OS_name)
|
||||||
|
.add(6, v.OS_version).add(7, v.processorsCount).add(8, v.user).add(9, v.build_options);
|
||||||
|
s << cs.data();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
BINARY_STREAM_RESTORE(PIIntrospection::ProcessInfo) {
|
||||||
|
PIByteArray csba; s >> csba;
|
||||||
|
PIChunkStream cs(csba);
|
||||||
|
while (!cs.atEnd()) {
|
||||||
|
switch (cs.read()) {
|
||||||
|
case 1: cs.get(v.architecture); break;
|
||||||
|
case 2: cs.get(v.execCommand); break;
|
||||||
|
case 3: cs.get(v.execDateTime); break;
|
||||||
|
case 4: cs.get(v.hostname); break;
|
||||||
|
case 5: cs.get(v.OS_name); break;
|
||||||
|
case 6: cs.get(v.OS_version); break;
|
||||||
|
case 7: cs.get(v.processorsCount); break;
|
||||||
|
case 8: cs.get(v.user); break;
|
||||||
|
case 9: cs.get(v.build_options); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE (PIIntrospection::ObjectInfo) {
|
||||||
|
PIChunkStream cs;
|
||||||
|
cs.add(1, v.classname).add(2, v.name).add(3, v.parents).add(4, v.properties).add(5, v.queued_events);
|
||||||
|
s << cs.data();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
BINARY_STREAM_RESTORE(PIIntrospection::ObjectInfo) {
|
||||||
|
PIByteArray csba; s >> csba;
|
||||||
|
PIChunkStream cs(csba);
|
||||||
|
while (!cs.atEnd()) {
|
||||||
|
switch (cs.read()) {
|
||||||
|
case 1: cs.get(v.classname); break;
|
||||||
|
case 2: cs.get(v.name); break;
|
||||||
|
case 3: cs.get(v.parents); break;
|
||||||
|
case 4: cs.get(v.properties); break;
|
||||||
|
case 5: cs.get(v.queued_events); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PIINTROSPECTION_SERVER_P_H
|
#endif // PIINTROSPECTION_SERVER_P_H
|
||||||
|
|||||||
@@ -60,4 +60,13 @@ public:
|
|||||||
PIP_EXPORT PIByteArray & operator <<(PIByteArray & b, const PIIntrospectionThreads::ThreadInfo & v);
|
PIP_EXPORT PIByteArray & operator <<(PIByteArray & b, const PIIntrospectionThreads::ThreadInfo & v);
|
||||||
PIP_EXPORT PIByteArray & operator >>(PIByteArray & b, PIIntrospectionThreads::ThreadInfo & v);
|
PIP_EXPORT PIByteArray & operator >>(PIByteArray & b, PIIntrospectionThreads::ThreadInfo & v);
|
||||||
|
|
||||||
|
BINARY_STREAM_STORE(PIIntrospectionThreads::ThreadInfo) {
|
||||||
|
s << v.classname << v.name << v.id << v.state << v.priority << v.delay << v.run_us << v.run_count;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
BINARY_STREAM_RESTORE(PIIntrospectionThreads::ThreadInfo) {
|
||||||
|
s >> v.classname >> v.name >> v.id >> v.state >> v.priority >> v.delay >> v.run_us >> v.run_count;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PIINTROSPECTION_THREADS_P_H
|
#endif // PIINTROSPECTION_THREADS_P_H
|
||||||
|
|||||||
29
main.cpp
29
main.cpp
@@ -9,11 +9,11 @@ using namespace PICoutManipulators;
|
|||||||
class ByteArray: public PIBinaryStream<ByteArray> {
|
class ByteArray: public PIBinaryStream<ByteArray> {
|
||||||
public:
|
public:
|
||||||
PIByteArray data;
|
PIByteArray data;
|
||||||
bool binaryStreamAppend(const void * d, size_t s) {
|
bool binaryStreamAppendImp(const void * d, size_t s) {
|
||||||
data.append(d, s);
|
data.append(d, s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool binaryStreamTake(void * d, size_t s) {
|
bool binaryStreamTakeImp(void * d, size_t s) {
|
||||||
if (data.size() < s)
|
if (data.size() < s)
|
||||||
return false;
|
return false;
|
||||||
memcpy(d, data.data(), s);
|
memcpy(d, data.data(), s);
|
||||||
@@ -25,11 +25,11 @@ public:
|
|||||||
class File: public PIBinaryStream<File> {
|
class File: public PIBinaryStream<File> {
|
||||||
public:
|
public:
|
||||||
PIFile file;
|
PIFile file;
|
||||||
bool binaryStreamAppend(const void * d, size_t s) {
|
bool binaryStreamAppendImp(const void * d, size_t s) {
|
||||||
file.write(d, s);
|
file.write(d, s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool binaryStreamTake(void * d, size_t s) {
|
bool binaryStreamTakeImp(void * d, size_t s) {
|
||||||
if (file.isEnd())
|
if (file.isEnd())
|
||||||
return false;
|
return false;
|
||||||
file.read(d, s);
|
file.read(d, s);
|
||||||
@@ -58,8 +58,9 @@ int main(int argc, char * argv[]) {
|
|||||||
//f.file.open("_", PIIODevice::ReadWrite);
|
//f.file.open("_", PIIODevice::ReadWrite);
|
||||||
//f.file.clear();
|
//f.file.clear();
|
||||||
//PIVector<TS> vi({TS(1,20), TS(3,40)});
|
//PIVector<TS> vi({TS(1,20), TS(3,40)});
|
||||||
PIVector<TS> vi({{'a', 10}, {'b', 20}, {'c', 30}});
|
/*PIVector<TS> vi({{'a', 10}, {'b', 20}, {'c', 30}});
|
||||||
ba << vi;
|
ba << vi;
|
||||||
|
ba.binaryStreamAppend(&ba, sizeof(ba));
|
||||||
piCout << "src" << vi;
|
piCout << "src" << vi;
|
||||||
piCout << "s" << ba.data;
|
piCout << "s" << ba.data;
|
||||||
vi.fill(TS());
|
vi.fill(TS());
|
||||||
@@ -67,6 +68,22 @@ int main(int argc, char * argv[]) {
|
|||||||
//f.file.seekToBegin();
|
//f.file.seekToBegin();
|
||||||
ba >> vi;
|
ba >> vi;
|
||||||
piCout << "res" << vi;
|
piCout << "res" << vi;
|
||||||
piCout << "r" << ba.data;
|
piCout << "r" << ba.data;*/
|
||||||
|
PIMap<PIIODevice::DeviceMode, PIStringList> map;
|
||||||
|
map[PIIODevice::ReadOnly] = {"str0", PIString::fromUTF8("русский!")};
|
||||||
|
piMSleep(100);
|
||||||
|
map[PIIODevice::ReadWrite] = {""};
|
||||||
|
piMSleep(100);
|
||||||
|
map[PIIODevice::WriteOnly] = {PIString::fromUTF8("русский!"), "", "1234567890", "qwertyuiop[]"};
|
||||||
|
piCout << map;
|
||||||
|
|
||||||
|
ba << map;
|
||||||
|
piCout << ba.data;
|
||||||
|
map.clear();
|
||||||
|
|
||||||
|
ba >> map;
|
||||||
|
piCout << map;
|
||||||
|
piCout << ba.data;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user