text stream ...
This commit is contained in:
@@ -132,6 +132,10 @@ template< class T1, class T2 >
|
|||||||
PIPair<T1,T2> createPIPair(const T1 & f, const T2 & s) {
|
PIPair<T1,T2> createPIPair(const T1 & f, const T2 & s) {
|
||||||
return PIPair<T1,T2>(f, s);
|
return PIPair<T1,T2>(f, s);
|
||||||
}
|
}
|
||||||
|
template< class T1, class T2 >
|
||||||
|
PIPair<T1,T2> makePIPair(const T1 & f, const T2 & s) {
|
||||||
|
return PIPair<T1,T2>(f, s);
|
||||||
|
}
|
||||||
|
|
||||||
//! \~english Creates \a PIPair object, deducing the target type from the types of arguments.
|
//! \~english Creates \a PIPair object, deducing the target type from the types of arguments.
|
||||||
//! \~russian Создает \a PIPair выводя типы из аргументов.
|
//! \~russian Создает \a PIPair выводя типы из аргументов.
|
||||||
@@ -140,5 +144,9 @@ template< class T1, class T2 >
|
|||||||
PIPair<T1,T2> createPIPair(T1 && f, T2 && s) {
|
PIPair<T1,T2> createPIPair(T1 && f, T2 && s) {
|
||||||
return PIPair<T1,T2>(std::move(f), std::move(s));
|
return PIPair<T1,T2>(std::move(f), std::move(s));
|
||||||
}
|
}
|
||||||
|
template< class T1, class T2 >
|
||||||
|
PIPair<T1,T2> makePIPair(T1 && f, T2 && s) {
|
||||||
|
return PIPair<T1,T2>(std::move(f), std::move(s));
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PIPAIR_H
|
#endif // PIPAIR_H
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/*! \file pitextstream.h
|
/*! \file pitextstream.h
|
||||||
* \ingroup Core
|
* \ingroup Core
|
||||||
* \~\brief
|
* \~\brief
|
||||||
* \~english Text serialization interface
|
* \~english Text serialization functionality over PIBinaryStream
|
||||||
* \~russian Интерфейс текстовой сериализации
|
* \~russian Функциональность текстовой сериализации поверх PIBinaryStream
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
PIP - Platform Independent Primitives
|
PIP - Platform Independent Primitives
|
||||||
Text serialization interface
|
Text serialization functionality over PIBinaryStream
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@@ -31,8 +31,8 @@
|
|||||||
|
|
||||||
//! \ingroup Core
|
//! \ingroup Core
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
//! \~english Text serialization interface.
|
//! \~english Text serialization functionality over PIBinaryStream.
|
||||||
//! \~russian Интерфейс текстовой сериализации.
|
//! \~russian Функциональность текстовой сериализации поверх PIBinaryStream.
|
||||||
template<typename P>
|
template<typename P>
|
||||||
class PITextStream {
|
class PITextStream {
|
||||||
public:
|
public:
|
||||||
@@ -56,14 +56,22 @@ public:
|
|||||||
|
|
||||||
char takeChar(bool * ok) {return (char)s->binaryStreamTakeByte(ok);}
|
char takeChar(bool * ok) {return (char)s->binaryStreamTakeByte(ok);}
|
||||||
|
|
||||||
bool textStreamSkipSpaces() {
|
bool skipSpaces() {
|
||||||
|
|
||||||
//if ()
|
//if ()
|
||||||
}
|
}
|
||||||
PIString textStreamTakeLine() {
|
PIString takeLine() {
|
||||||
|
PIByteArray line;
|
||||||
|
bool ok = true;
|
||||||
|
for (;;) {
|
||||||
|
char b = takeChar(&ok);
|
||||||
|
if (!ok || b == '\n') break;
|
||||||
|
if (b != '\r')
|
||||||
|
line.append((uchar)b);
|
||||||
}
|
}
|
||||||
PIString textStreamTakeWord();
|
return PIString::fromUTF8(line);
|
||||||
|
}
|
||||||
|
PIString takeWord();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PIBinaryStream<P> * s;
|
PIBinaryStream<P> * s;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#define PIIOSTREAM_H
|
#define PIIOSTREAM_H
|
||||||
|
|
||||||
#include "piiodevice.h"
|
#include "piiodevice.h"
|
||||||
|
#include "pitextstream.h"
|
||||||
|
|
||||||
|
|
||||||
//! \ingroup IO
|
//! \ingroup IO
|
||||||
@@ -56,4 +57,21 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! \ingroup IO
|
||||||
|
//! \~\brief
|
||||||
|
//! \~english PITextStream functionality for PIIODevice.
|
||||||
|
//! \~russian Функциональность PITextStream для PIIODevice.
|
||||||
|
class PIP_EXPORT PIIOTextStream: public PITextStream<PIIOBinaryStream> {
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! \~english Contructs %PIIOTextStream for "device" device
|
||||||
|
//! \~russian Создает %PIIOTextStream для устройства "device"
|
||||||
|
PIIOTextStream(PIIODevice * device): PITextStream<PIIOBinaryStream>(&bin_stream), bin_stream(device){}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PIIOBinaryStream bin_stream;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // PIIOSTREAM_H
|
#endif // PIIOSTREAM_H
|
||||||
|
|||||||
15
main.cpp
15
main.cpp
@@ -37,19 +37,12 @@ template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> &
|
|||||||
|
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
PIByteArray ba;
|
|
||||||
PIFile f;
|
PIFile f;
|
||||||
f.open("_", PIIODevice::ReadWrite);
|
f.open("_test.h", PIIODevice::ReadOnly);
|
||||||
f.clear();
|
PIIOTextStream ts(&f);
|
||||||
PIIOBinaryStream ios(&f);
|
while (!f.isEnd())
|
||||||
auto ts = createPITextStream(&ios);
|
piCout << ts.takeLine();
|
||||||
|
|
||||||
ts << "hello" << uchar('1');
|
|
||||||
ts.space();
|
|
||||||
(ts << PIString::fromUTF8("№") << 123).space() << -0.1f;
|
|
||||||
ts.newLine();
|
|
||||||
|
|
||||||
piCout << PIString(ba);
|
|
||||||
//PIIOByteArray ioba(&ba);
|
//PIIOByteArray ioba(&ba);
|
||||||
//PIIOBinaryStream stream(&ioba);
|
//PIIOBinaryStream stream(&ioba);
|
||||||
/*ProcessStatsFixed_ ps;
|
/*ProcessStatsFixed_ ps;
|
||||||
|
|||||||
Reference in New Issue
Block a user