git-svn-id: svn://db.shs.com.ru/pip@179 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2016-02-10 08:50:59 +00:00
parent dc7048d100
commit 697b39124c
5 changed files with 60 additions and 41 deletions

View File

@@ -1,42 +1,19 @@
#include "pikbdlistener.h"
#include "piconnection.h"
#include "piconfig.h"
#include "pichunkstream.h"
#include "piscreentiles.h"
#include "piscreen.h"
struct S {
int i;
float f;
PIString s;
};
PIByteArray & operator <<(PIByteArray & b, const S & s) {b << s.i << s.f << s.s; return b;}
PIByteArray & operator >>(PIByteArray & b, S & s) {b >> s.i >> s.f >> s.s; return b;}
int main (int argc, char * argv[]) {
PIChunkStream cs;
S s;
s.i = 99; s.f = 0.01; s.s = "SSS";
PIVector<float> f;
f << -1. << 2.5 << 11.;
cs << cs.chunk(1, 10) << cs.chunk(2, PIString("text")) << cs.chunk(4, f) << cs.chunk(3, s);
f.clear();
PIByteArray ba(cs.data());
piCout << ba;
PIChunkStream cs2(ba);
s.i = 0; s.f = 0; s.s = "";
int i(0);
PIString str;
piCout << i << str << f << s.i << s.f << s.s;
while (!cs2.atEnd()) {
switch (cs2.read()) {
case 1: i = cs2.getData<int>(); break;
case 2: str = cs2.getData<PIString>(); break;
case 3: s = cs2.getData<S>(); break;
case 4: f = cs2.getData<PIVector<float> >(); break;
}
}
piCout << i << str << f << s.i << s.f << s.s;
PIScreen screen;
TileSimple window;
window.back_format.color_back = PIScreenTypes::Red;
window.content << TileSimple::Row("label", PIScreenTypes::CellFormat(PIScreenTypes::Black, PIScreenTypes::Transparent));
screen.rootTile()->addTile(&window);
screen.enableExitCapture(PIKbdListener::F10);
screen.start();
screen.waitForFinish();
return 0;
}