104 lines
4.6 KiB
C++
104 lines
4.6 KiB
C++
/*! \file pivaluetree_conversions.h
|
||
* \addtogroup Serialization
|
||
* \brief
|
||
* \~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
|
||
PIValueTree conversions
|
||
Ivan Pelipenko peri4ko@yandex.ru
|
||
|
||
This program is free software: you can redistribute it and/or modify
|
||
it under the terms of the GNU Lesser General Public License as published by
|
||
the Free Software Foundation, either version 3 of the License, or
|
||
(at your option) any later version.
|
||
|
||
This program is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
GNU Lesser General Public License for more details.
|
||
|
||
You should have received a copy of the GNU Lesser General Public License
|
||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
*/
|
||
|
||
#ifndef pivaluetree_conversions_H
|
||
#define pivaluetree_conversions_H
|
||
|
||
#include "pivaluetree.h"
|
||
|
||
class PIPropertyStorage;
|
||
class PIJSON;
|
||
class PIIODevice;
|
||
|
||
//! \~english PIValueTree conversion namespace.
|
||
//! \~russian Пространство имён преобразований PIValueTree.
|
||
namespace PIValueTreeConversions {
|
||
|
||
//! \~english Conversion options. \~russian Параметры преобразования.
|
||
enum Option {
|
||
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
|
||
|
||
#endif
|