PIByteArray works on binary stream
This commit is contained in:
22
main.cpp
22
main.cpp
@@ -6,22 +6,6 @@
|
||||
|
||||
using namespace PICoutManipulators;
|
||||
|
||||
class ByteArray: public PIBinaryStream<ByteArray> {
|
||||
public:
|
||||
PIByteArray data;
|
||||
bool binaryStreamAppendImp(const void * d, size_t s) {
|
||||
data.append(d, s);
|
||||
return true;
|
||||
}
|
||||
bool binaryStreamTakeImp(void * d, size_t s) {
|
||||
if (data.size() < s)
|
||||
return false;
|
||||
memcpy(d, data.data(), s);
|
||||
data.remove(0, s);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class File: public PIBinaryStream<File> {
|
||||
public:
|
||||
PIFile file;
|
||||
@@ -50,7 +34,7 @@ template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> &
|
||||
template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, TS & v) {s >> v.i; return s;}
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
ByteArray ba;
|
||||
PIByteArray ba;
|
||||
/*ProcessStatsFixed_ ps;
|
||||
ba << ps;
|
||||
piCout << "s" << ba.data;*/
|
||||
@@ -78,12 +62,12 @@ int main(int argc, char * argv[]) {
|
||||
piCout << map;
|
||||
|
||||
ba << map;
|
||||
piCout << ba.data;
|
||||
piCout << ba;
|
||||
map.clear();
|
||||
|
||||
ba >> map;
|
||||
piCout << map;
|
||||
piCout << ba.data;
|
||||
piCout << ba;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user