BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Default converter of SessionItemData to/from json object. More...
Public Types | |
using | accept_strategy_t = std::function< bool(int)> |
Public Member Functions | |
JsonItemDataConverter (accept_strategy_t to_json_accept={}, accept_strategy_t from_json_accept={}) | |
~JsonItemDataConverter () override | |
void | from_json (const QJsonArray &object, SessionItemData &data) override |
Updates existing data with JSON content. More... | |
QJsonArray | to_json (const SessionItemData &data) override |
Converts SessionItemData to JSON;. More... | |
Static Public Member Functions | |
static std::unique_ptr< JsonItemDataConverterInterface > | createCopyConverter () |
Creates JSON data converter intended for simple data copying. Nothing is filtered out. More... | |
static std::unique_ptr< JsonItemDataConverterInterface > | createProjectConverter () |
Creates JSON data converter intended for project saving. More... | |
Private Member Functions | |
bool | isRoleFromJson (int role) const |
Returns true if given role should be parsed from json object. More... | |
bool | isRoleToJson (int role) const |
Returns true if given role should be saved in json object. More... | |
Private Attributes | |
accept_strategy_t | m_from_json_accept |
callback to find whether to read role from json More... | |
accept_strategy_t | m_to_json_accept |
callback to find whether to write role to json More... | |
std::unique_ptr< JsonVariantConverterInterface > | m_variant_converter |
Default converter of SessionItemData to/from json object.
Definition at line 31 of file jsonitemdataconverter.h.
using ModelView::JsonItemDataConverter::accept_strategy_t = std::function<bool(int)> |
Definition at line 33 of file jsonitemdataconverter.h.
JsonItemDataConverter::JsonItemDataConverter | ( | accept_strategy_t | to_json_accept = {} , |
accept_strategy_t | from_json_accept = {} |
||
) |
Definition at line 35 of file jsonitemdataconverter.cpp.
|
overridedefault |
|
static |
Creates JSON data converter intended for simple data copying. Nothing is filtered out.
Definition at line 93 of file jsonitemdataconverter.cpp.
Referenced by TEST_F().
|
static |
Creates JSON data converter intended for project saving.
Only IDENTIFIER and DATA gous to/from JSON.
Definition at line 101 of file jsonitemdataconverter.cpp.
References ModelView::ItemDataRole::DATA, and ModelView::ItemDataRole::IDENTIFIER.
Referenced by TEST_F().
|
overridevirtual |
Updates existing data with JSON content.
Implements ModelView::JsonItemDataConverterInterface.
Definition at line 63 of file jsonitemdataconverter.cpp.
References isRoleFromJson(), ModelView::JsonItemFormatAssistant::isSessionItemData(), m_variant_converter, ModelView::JsonItemFormatAssistant::roleKey, ModelView::SessionItemData::roles(), ModelView::SessionItemData::setData(), and ModelView::JsonItemFormatAssistant::variantKey.
Referenced by TEST_F().
|
private |
Returns true if given role should be parsed from json object.
Definition at line 118 of file jsonitemdataconverter.cpp.
References m_from_json_accept.
Referenced by from_json().
|
private |
Returns true if given role should be saved in json object.
Definition at line 111 of file jsonitemdataconverter.cpp.
References m_to_json_accept.
Referenced by to_json().
|
overridevirtual |
Converts SessionItemData to JSON;.
Implements ModelView::JsonItemDataConverterInterface.
Definition at line 45 of file jsonitemdataconverter.cpp.
References isRoleToJson(), m_variant_converter, ModelView::JsonItemFormatAssistant::roleKey, and ModelView::JsonItemFormatAssistant::variantKey.
Referenced by TEST_F().
|
private |
callback to find whether to read role from json
Definition at line 53 of file jsonitemdataconverter.h.
Referenced by isRoleFromJson().
|
private |
callback to find whether to write role to json
Definition at line 52 of file jsonitemdataconverter.h.
Referenced by isRoleToJson().
|
private |
Definition at line 54 of file jsonitemdataconverter.h.
Referenced by from_json(), and to_json().