more ai generated doc with human review
This commit is contained in:
@@ -34,17 +34,17 @@
|
||||
|
||||
#define PIP_BINARY_STREAM
|
||||
|
||||
#define BINARY_STREAM_FRIEND(T) \
|
||||
template<typename P> \
|
||||
friend PIBinaryStream<P> & operator<<(PIBinaryStream<P> & s, const T & v); \
|
||||
template<typename P> \
|
||||
friend PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, T & v);
|
||||
#define BINARY_STREAM_FRIEND(T) \
|
||||
template<typename P> \
|
||||
friend PIBinaryStream<P> & operator<<(PIBinaryStream<P> & s, const T & v); \
|
||||
template<typename P> \
|
||||
friend PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, T & v);
|
||||
#define BINARY_STREAM_WRITE(T) \
|
||||
template<typename P> \
|
||||
inline PIBinaryStream<P> & operator<<(PIBinaryStream<P> & s, const T & v)
|
||||
template<typename P> \
|
||||
inline PIBinaryStream<P> & operator<<(PIBinaryStream<P> & s, const T & v)
|
||||
#define BINARY_STREAM_READ(T) \
|
||||
template<typename P> \
|
||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, T & v)
|
||||
template<typename P> \
|
||||
inline PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, T & v)
|
||||
|
||||
|
||||
//! \ingroup Serialization
|
||||
|
||||
@@ -106,7 +106,12 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//! \~english Set source buffer for read from "data"
|
||||
//! \~russian Устанавливает исходный буфер для чтения из "data"
|
||||
void setSource(const PIByteArray & data);
|
||||
|
||||
//! \~english Set source buffer for read or write to/from "data", or empty stream for write if "data" = 0
|
||||
//! \~russian Устанавливает исходный буфер для чтения или записи из/в "data", или пустой поток на запись если "data" = 0
|
||||
void setSource(PIByteArray * data);
|
||||
|
||||
//! \~english Returns internal buffer with written data
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
/*! \file pijson.h
|
||||
* \ingroup Serialization
|
||||
/*! \file pijsonserialization.h
|
||||
* \addtogroup Serialization
|
||||
* \brief
|
||||
* \~english JSON serialization
|
||||
* \~russian Сериализация JSON
|
||||
* \~english JSON serialization and deserialization template functions
|
||||
* \~russian Шаблонные функции сериализации и десериализации JSON
|
||||
* \details
|
||||
* \~english This file provides template functions for serializing and deserializing
|
||||
* various types to and from PIJSON format.
|
||||
* \~russian Этот файл предоставляет шаблонные функции для сериализации и десериализации
|
||||
* различных типов в формат PIJSON и из него.
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
@@ -38,14 +43,14 @@
|
||||
|
||||
template<typename T, typename std::enable_if<std::is_enum<T>::value, int>::type = 0>
|
||||
inline PIJSON piSerializeJSON(const T & v) {
|
||||
return PIJSON() = (int)v;
|
||||
return PIJSON() = (int)v;
|
||||
}
|
||||
|
||||
template<typename T,
|
||||
typename std::enable_if<!std::is_enum<T>::value, int>::type = 0,
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
inline PIJSON piSerializeJSON(const T & v) {
|
||||
return PIJSON() = v;
|
||||
return PIJSON() = v;
|
||||
}
|
||||
|
||||
template<typename T,
|
||||
@@ -53,7 +58,7 @@ template<typename T,
|
||||
typename std::enable_if<!std::is_arithmetic<T>::value, int>::type = 0>
|
||||
inline PIJSON piSerializeJSON(const T & v) {
|
||||
static_assert(std::is_enum<T>::value || std::is_arithmetic<T>::value,
|
||||
"[piSerializeJSON] Error: using undeclared piSerializeJSON() for complex type!");
|
||||
"[piSerializeJSON] Error: using undeclared piSerializeJSON() for complex type!");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -229,14 +234,14 @@ inline PIJSON piSerializeJSON(const PIMap<K, T> & v) {
|
||||
|
||||
template<typename T, typename std::enable_if<std::is_enum<T>::value, int>::type = 0>
|
||||
inline void piDeserializeJSON(T & v, const PIJSON & js) {
|
||||
v = (T)js.toInt();
|
||||
v = (T)js.toInt();
|
||||
}
|
||||
|
||||
template<typename T,
|
||||
typename std::enable_if<!std::is_enum<T>::value, int>::type = 0,
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
inline void piDeserializeJSON(T & v, const PIJSON & js) {
|
||||
v = js.value().value<T>();
|
||||
v = js.value().value<T>();
|
||||
}
|
||||
|
||||
template<typename T,
|
||||
@@ -244,7 +249,7 @@ template<typename T,
|
||||
typename std::enable_if<!std::is_arithmetic<T>::value, int>::type = 0>
|
||||
inline void piDeserializeJSON(T & v, const PIJSON & js) {
|
||||
static_assert(std::is_enum<T>::value || std::is_arithmetic<T>::value,
|
||||
"[piDeserializeJSON] Error: using undeclared piDeserializeJSON() for complex type!");
|
||||
"[piDeserializeJSON] Error: using undeclared piDeserializeJSON() for complex type!");
|
||||
v = {};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
/*! \file pivaluetree_conversions.h
|
||||
* \ingroup Serialization
|
||||
* \addtogroup Serialization
|
||||
* \brief
|
||||
* \~english PIValueTree conversions
|
||||
* \~russian Преобразования PIValueTree
|
||||
* \~english PIValueTree conversion functions
|
||||
* \~russian Функции преобразования PIValueTree
|
||||
* \details
|
||||
* \~english This file provides functions for converting PIValueTree to and from
|
||||
* various formats (JSON, text, property storage).
|
||||
* \~russian Этот файл предоставляет функции для преобразования PIValueTree в различные
|
||||
* форматы (JSON, текст, хранилище свойств) и из них.
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
@@ -32,31 +37,65 @@ class PIPropertyStorage;
|
||||
class PIJSON;
|
||||
class PIIODevice;
|
||||
|
||||
//! \~english PIValueTree conversion namespace.
|
||||
//! \~russian Пространство имён преобразований PIValueTree.
|
||||
namespace PIValueTreeConversions {
|
||||
|
||||
//! \~english Conversion options. \~russian Параметры преобразования.
|
||||
enum Option {
|
||||
WithAttributes = 0x1,
|
||||
WithComment = 0x2,
|
||||
WithType = 0x4,
|
||||
WithAll = 0xFFF,
|
||||
IncludeRoot = 0x1000,
|
||||
Default = WithAll
|
||||
WithAttributes = 0x1, //!< \~english Include attributes \~russian Включить атрибуты
|
||||
WithComment = 0x2, //!< \~english Include comments \~russian Включить комментарии
|
||||
WithType = 0x4, //!< \~english Include type information \~russian Включить информацию о типе
|
||||
WithAll = 0xFFF, //!< \~english Include everything \~russian Включить всё
|
||||
IncludeRoot = 0x1000, //!< \~english Include root node \~russian Включить корневой узел
|
||||
Default = WithAll //!< \~english Default options \~russian Параметры по умолчанию
|
||||
};
|
||||
//! \~english Options flags type.
|
||||
//! \~russian Тип флагов параметров.
|
||||
typedef PIFlags<Option> Options;
|
||||
|
||||
//! \~english Convert PIPropertyStorage to PIValueTree.
|
||||
//! \~russian Преобразование PIPropertyStorage в PIValueTree.
|
||||
PIP_EXPORT PIValueTree fromPropertyStorage(const PIPropertyStorage & ps);
|
||||
|
||||
//! \~english Convert PIVariantMap to PIValueTree.
|
||||
//! \~russian Преобразование PIVariantMap в PIValueTree.
|
||||
PIP_EXPORT PIValueTree fromVariantMap(const PIVariantMap & vm);
|
||||
|
||||
//! \~english Convert PIJSON to PIValueTree.
|
||||
//! \~russian Преобразование PIJSON в PIValueTree.
|
||||
PIP_EXPORT PIValueTree fromJSON(const PIJSON & json);
|
||||
|
||||
//! \~english Read PIValueTree from IODevice as text.
|
||||
//! \~russian Чтение PIValueTree из IODevice как текст.
|
||||
PIP_EXPORT PIValueTree fromText(PIIODevice * device);
|
||||
|
||||
//! \~english Parse PIValueTree from text string.
|
||||
//! \~russian Разбор PIValueTree из текстовой строки.
|
||||
PIP_EXPORT PIValueTree fromText(const PIString & str);
|
||||
|
||||
//! \~english Load PIValueTree from JSON file.
|
||||
//! \~russian Загрузка PIValueTree из JSON файла.
|
||||
PIP_EXPORT PIValueTree fromJSONFile(const PIString & path);
|
||||
|
||||
//! \~english Load PIValueTree from text file.
|
||||
//! \~russian Загрузка PIValueTree из текстового файла.
|
||||
PIP_EXPORT PIValueTree fromTextFile(const PIString & path);
|
||||
|
||||
//! \~english Convert PIValueTree to JSON.
|
||||
//! \~russian Преобразование PIValueTree в JSON.
|
||||
PIP_EXPORT PIJSON toJSON(const PIValueTree & root, Options options = Default);
|
||||
|
||||
//! \~english Convert PIValueTree to text.
|
||||
//! \~russian Преобразование PIValueTree в текст.
|
||||
PIP_EXPORT PIString toText(const PIValueTree & root, Options options = Default);
|
||||
|
||||
//! \~english Save PIValueTree to JSON file.
|
||||
//! \~russian Сохранение PIValueTree в JSON файл.
|
||||
PIP_EXPORT bool toJSONFile(const PIString & path, const PIValueTree & root, Options options = Default);
|
||||
|
||||
//! \~english Save PIValueTree to text file.
|
||||
//! \~russian Сохранение PIValueTree в текстовый файл.
|
||||
PIP_EXPORT bool toTextFile(const PIString & path, const PIValueTree & root, Options options = Default);
|
||||
|
||||
} // namespace PIValueTreeConversions
|
||||
|
||||
Reference in New Issue
Block a user