ready to integrate

This commit is contained in:
2022-05-09 23:57:47 +03:00
parent 0243f588bc
commit cf4f58ed95
2 changed files with 48 additions and 16 deletions

View File

@@ -9,32 +9,40 @@ using namespace PICoutManipulators;
class ByteArray: public PIBinaryStream<ByteArray> {
public:
PIByteArray data;
void appendImp(const void * d, size_t s) {
bool binaryStreamAppend(const void * d, size_t s) {
data.append(d, s);
return true;
}
void takeImp(void * d, size_t s) {
bool binaryStreamTake(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;
void appendImp(const void * d, size_t s) {
bool binaryStreamAppend(const void * d, size_t s) {
file.write(d, s);
return true;
}
void takeImp(void * d, size_t s) {
bool binaryStreamTake(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;}
TS(int v0 = -1, float v1 = -1, PIString v2 = "") {i = v0; f = v1;/* s = v2;*/}
int i;
float f;
PIString s;
//PIString s;
};
PICout operator << (PICout c, const TS & v) {c << '{' << v.i << ", " << v.f << '}'; return c;}
@@ -50,11 +58,11 @@ int main(int argc, char * argv[]) {
//f.file.open("_", PIIODevice::ReadWrite);
//f.file.clear();
//PIVector<TS> vi({TS(1,20), TS(3,40)});
PIVector<PIChar> vi({'a', 'b', 'c'});
PIVector<TS> vi({{'a', 10}, {'b', 20}, {'c', 30}});
ba << vi;
piCout << "src" << vi;
piCout << "s" << ba.data;
vi.fill(' ');
vi.fill(TS());
vi.clear();
//f.file.seekToBegin();
ba >> vi;