doc ru
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
/*! \file pichunkstream.h
|
||||
* \brief Binary markup serializator
|
||||
* \~\brief
|
||||
* \~english Binary markup de/serializator stream
|
||||
* \~russian Бинарный поток для де/сериализации с разметкой
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
@@ -30,20 +32,27 @@ class PIP_EXPORT PIChunkStream
|
||||
{
|
||||
public:
|
||||
|
||||
//! \~english
|
||||
//! Version of data packing. Read-access %PIChunkStream automatic detect version, but write-access
|
||||
//! %PIChunkStream by default write in new version, be careful!
|
||||
//! \~russian
|
||||
//! Версия хранения данных. %PIChunkStream на чтение автоматически определяет версию, но для записи
|
||||
//! использует по умолчанию новую, осторожно!
|
||||
enum Version {
|
||||
Version_1 /*! First, old version */,
|
||||
Version_2 /*! Second, more optimized version */ = 2,
|
||||
Version_1 /*! \~english First, old version \~russian Первая, старая версия */,
|
||||
Version_2 /*! \~english Second, more optimized version \~russian Вторая, более оптимизированная версия */ = 2,
|
||||
};
|
||||
|
||||
//! Contructs stream for read from "data"
|
||||
//! \~english Contructs stream for read from "data"
|
||||
//! \~russian Создает поток на чтение из "data"
|
||||
PIChunkStream(const PIByteArray & data): version_(Version_2) {setSource(data);}
|
||||
|
||||
//! Contructs stream for read or write to/from "data", or empty stream for write
|
||||
//! \~english Contructs stream for read or write to/from "data", or empty stream for write if "data" = 0
|
||||
//! \~russian Создает поток на чтение или запись из/в "data", или пустой поток на запись если "data" = 0
|
||||
PIChunkStream(PIByteArray * data = 0, Version v = Version_2): version_(v) {setSource(data);}
|
||||
|
||||
//! Contructs empty stream for write with version \"v\"
|
||||
//! \~english Contructs empty stream for write with version \"v\"
|
||||
//! \~russian Создает пустой поток на запись с версией \"v\"
|
||||
PIChunkStream(Version v): version_(v) {setSource(0);}
|
||||
|
||||
~PIChunkStream();
|
||||
@@ -61,48 +70,64 @@ public:
|
||||
const T & data;
|
||||
};
|
||||
|
||||
//! Returns chunk with ID "id" and value "data" for write to stream
|
||||
//! \~english Returns chunk with ID "id" and value "data" for write to stream
|
||||
//! \~russian Возвращает чанк с ID "id" и значением "data" для записи в поток
|
||||
template <typename T> static ChunkConst<T> chunk(int id, const T & data) {return ChunkConst<T>(id, data);}
|
||||
|
||||
//! Add data to this chunk strean with ID "id" and value "data"
|
||||
//! \~english Add to this stream chunk with ID "id" and value "data"
|
||||
//! \~russian Добавляет в этот поток чанк с ID "id" и значением "data"
|
||||
template <typename T> PIChunkStream & add(int id, const T & data) {*this << ChunkConst<T>(id, data); return *this;}
|
||||
|
||||
//! \~english
|
||||
//! Extract %PIByteArray from "data" and set it current stream.
|
||||
//! If "read_all" then call \a readAll() after extract.
|
||||
//! Returns if has data to read.
|
||||
//! \~russian
|
||||
//! Извлекает %PIByteArray из "data" и инициализирует им поток.
|
||||
//! Если указан "read_all", то вызывает \a readAll() после инициализации.
|
||||
//! Возвращает если ли данные для чтения.
|
||||
bool extract(PIByteArray & data, bool read_all = false);
|
||||
|
||||
void setSource(const PIByteArray & data);
|
||||
void setSource(PIByteArray * data);
|
||||
|
||||
//! Returns internal buffer with written data
|
||||
//! \~english Returns internal buffer with written data
|
||||
//! \~russian Возвращает внутренний буфер с записанными данными
|
||||
PIByteArray data() const;
|
||||
|
||||
//! Returns if there is end of stream
|
||||
//! \~english Returns if there is end of stream
|
||||
//! \~russian Возвращает достигнут ли конец потока
|
||||
bool atEnd() const {return data_->size_s() <= 1;}
|
||||
|
||||
//! Returns stream version
|
||||
//! \~english Returns stream version
|
||||
//! \~russian Возвращает версию потока
|
||||
Version version() const {return (Version)version_;}
|
||||
|
||||
|
||||
//! Read one chunk from stream and returns its ID
|
||||
//! \~english Read one chunk from stream and returns its ID
|
||||
//! \~russian Читает один чанк из потока и возвращает его ID
|
||||
int read();
|
||||
|
||||
//! Read all chunks from stream. This function just index input data
|
||||
//! \~english Read all chunks from stream. This function just index input data
|
||||
//! \~russian Читает все чанки из потока. Данный метод лишь индексирует данные
|
||||
void readAll();
|
||||
|
||||
//! Returns last readed chunk ID
|
||||
//! \~english Returns last readed chunk ID
|
||||
//! \~russian Возвращает ID последнего прочитанного чанка
|
||||
int getID() {return last_id;}
|
||||
|
||||
//! Returns value of last readed chunk
|
||||
//! \~english Returns value of last readed chunk
|
||||
//! \~russian Возвращает значение последнего прочитанного чанка
|
||||
template <typename T>
|
||||
T getData() const {T ret; PIByteArray s(last_data); s >> ret; return ret;}
|
||||
|
||||
//! Place value of last readed chunk into \"v\"
|
||||
//! \~english Place value of last readed chunk into \"v\"
|
||||
//! \~russian Записывает значение последнего прочитанного чанка в \"v\"
|
||||
template <typename T>
|
||||
void get(T & v) const {v = getData<T>();}
|
||||
|
||||
//! Place value of chunk with id \"id\" into \"v\". You should call \a readAll() before using this function!
|
||||
//! \~english Place value of chunk with ID \"id\" into \"v\". You should call \a readAll() before using this function!
|
||||
//! \~russian Записывает значение чанка с ID \"id\" в \"v\". Необходимо вызвать \a readAll() перед использованием этого метода!
|
||||
template <typename T>
|
||||
const PIChunkStream & get(int id, T & v) const {
|
||||
CacheEntry pos = data_map.value(id);
|
||||
@@ -113,7 +138,8 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Replace value of chunk with ID \"id\" to \"v\". You should call \a readAll() before using this function!
|
||||
//! \~english Replace value of chunk with ID \"id\" to \"v\". You should call \a readAll() before using this function!
|
||||
//! \~russian Заменяет значение чанка с ID \"id\" на \"v\". Необходимо вызвать \a readAll() перед использованием этого метода!
|
||||
template <typename T>
|
||||
PIChunkStream & set(int id, const T & v) {
|
||||
PIByteArray ba;
|
||||
|
||||
Reference in New Issue
Block a user