114 lines
2.7 KiB
C++
114 lines
2.7 KiB
C++
#include "pip.h"
|
|
#include "pibinarystream.h"
|
|
#include "pitextstream.h"
|
|
#include "piiostream.h"
|
|
//#include "stream.h"
|
|
//#include "ccm_.h"
|
|
//#include "pisystemmonitor_.h"
|
|
|
|
using namespace PICoutManipulators;
|
|
/*
|
|
class File: public PIBinaryStream<File> {
|
|
public:
|
|
PIFile file;
|
|
bool binaryStreamAppendImp(const void * d, size_t s) {
|
|
file.write(d, s);
|
|
return true;
|
|
}
|
|
bool binaryStreamTakeImp(void * d, size_t s) {
|
|
if (file.isEnd())
|
|
return false;
|
|
file.read(d, s);
|
|
return true;
|
|
}
|
|
};
|
|
|
|
|
|
struct TS {
|
|
TS(int v0 = -1, float v1 = -1, PIString v2 = "") {i = v0; f = v1;
|
|
// s = v2;
|
|
}
|
|
int i;
|
|
float f;
|
|
//PIString s;
|
|
};
|
|
PICout operator << (PICout c, const TS & v) {c << '{' << v.i << ", " << v.f << '}'; return c;}
|
|
|
|
template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const TS & v) {s << v.i; return s;}
|
|
template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, TS & v) {s >> v.i; return s;}
|
|
|
|
*/
|
|
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;
|
|
p.sms_path = "mypath";
|
|
p.time_0 = "0.05";
|
|
p.time_1 = "10e + 3";
|
|
PIByteArray ba;
|
|
ba << p;
|
|
piCout << ba;
|
|
piCout << p1.sms_path << p1.time_0 << p1.time_1;
|
|
ba >> p1;
|
|
piCout << p1.sms_path << p1.time_0 << p1.time_1;*/
|
|
|
|
/*PIFile f;
|
|
f.open("_test.h", PIIODevice::ReadOnly);
|
|
PIIOTextStream ts(&f);
|
|
ts.setEncoding(PIIOTextStream::System);
|
|
while (!ts.isEnd()) {
|
|
PIString v;
|
|
ts >> v;
|
|
piCout << v;
|
|
//piCout << ts.takeCWord();
|
|
}*/
|
|
|
|
/*PIByteArray ba;
|
|
PIIOByteArray ioba(&ba);
|
|
//PIIOBinaryStream stream(&ioba);
|
|
PISystemMonitor::ProcessStatsFixed ps;
|
|
ba << PIByteArray::RawData("123", 3);
|
|
piCout << "s" << ba;*/
|
|
|
|
|
|
|
|
//File f;
|
|
//f.file.open("_", PIIODevice::ReadWrite);
|
|
//f.file.clear();
|
|
//PIVector<TS> vi({TS(1,20), TS(3,40)});
|
|
/*PIVector<TS> vi({{'a', 10}, {'b', 20}, {'c', 30}});
|
|
ba << vi;
|
|
ba.binaryStreamAppend(&ba, sizeof(ba));
|
|
piCout << "src" << vi;
|
|
piCout << "s" << ba.data;
|
|
vi.fill(TS());
|
|
vi.clear();
|
|
//f.file.seekToBegin();
|
|
ba >> vi;
|
|
piCout << "res" << vi;
|
|
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;
|
|
|
|
stream << map;
|
|
piCout << ba;
|
|
map.clear();
|
|
|
|
ioba.seekToBegin();
|
|
stream >> map;
|
|
piCout << map;
|
|
piCout << ba;*/
|
|
|
|
return 0;
|
|
}
|