aas-core3 1.0.1
Manipulate, verify and de/serialize asset administration shells in C++.
Loading...
Searching...
No Matches
jsonization.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 aas-core3.0-cpp AUTHORS
2//
3// SPDX-License-Identifier: MIT
4
5#ifndef AAS_CORE_AAS_3_0_JSONIZATION_GUARD_
6#define AAS_CORE_AAS_3_0_JSONIZATION_GUARD_
7
8// This code has been automatically generated by aas-core-codegen.
9// Do NOT edit or append.
10
14
15#pragma warning(push, 0)
16#include <nlohmann/json.hpp>
17
18#include <memory>
19#include <string>
20#include <utility>
21#pragma warning(pop)
22
23namespace aas_core {
24namespace aas_3_0 {
25
30namespace jsonization {
31
35class ISegment {
36 public:
40 virtual std::wstring ToWstring() const = 0;
41
42 virtual std::unique_ptr<ISegment> Clone() const = 0;
43
44 virtual ~ISegment() = default;
45}; // class ISegment
46
50struct PropertySegment : public ISegment {
54 std::wstring name;
55
57 std::wstring a_name
58 );
59
60 std::wstring ToWstring() const override;
61
62 std::unique_ptr<ISegment> Clone() const override;
63
64 ~PropertySegment() override = default;
65}; // struct PropertySegment
66
70struct IndexSegment : public ISegment {
74 size_t index;
75
76 explicit IndexSegment(
77 size_t an_index
78 );
79
80 std::wstring ToWstring() const override;
81
82 std::unique_ptr<ISegment> Clone() const override;
83
84 ~IndexSegment() override = default;
85}; // struct IndexSegment
86
90struct Path {
91 std::deque<std::unique_ptr<ISegment> > segments;
92
94 Path(const Path& other);
95 Path(Path&& other);
96 Path& operator=(const Path& other);
97 Path& operator=(Path&& other);
98
99 std::wstring ToWstring() const;
100}; // struct Path
101
102// region De-serialization
103
111 std::wstring cause;
112
117
118 explicit DeserializationError(std::wstring a_cause);
119 DeserializationError(std::wstring a_cause, Path a_path);
120}; // struct DeserializationError
121
131common::expected<
132 std::shared_ptr<types::IHasSemantics>,
135 const nlohmann::json& json,
136 bool additional_properties = false
137);
138
148common::expected<
149 std::shared_ptr<types::IExtension>,
152 const nlohmann::json& json,
153 bool additional_properties = false
154);
155
165common::expected<
166 std::shared_ptr<types::IHasExtensions>,
169 const nlohmann::json& json,
170 bool additional_properties = false
171);
172
182common::expected<
183 std::shared_ptr<types::IReferable>,
186 const nlohmann::json& json,
187 bool additional_properties = false
188);
189
199common::expected<
200 std::shared_ptr<types::IIdentifiable>,
203 const nlohmann::json& json,
204 bool additional_properties = false
205);
206
216common::expected<
217 std::shared_ptr<types::IHasKind>,
220 const nlohmann::json& json,
221 bool additional_properties = false
222);
223
233common::expected<
234 std::shared_ptr<types::IHasDataSpecification>,
237 const nlohmann::json& json,
238 bool additional_properties = false
239);
240
250common::expected<
251 std::shared_ptr<types::IAdministrativeInformation>,
254 const nlohmann::json& json,
255 bool additional_properties = false
256);
257
267common::expected<
268 std::shared_ptr<types::IQualifiable>,
271 const nlohmann::json& json,
272 bool additional_properties = false
273);
274
284common::expected<
285 std::shared_ptr<types::IQualifier>,
288 const nlohmann::json& json,
289 bool additional_properties = false
290);
291
301common::expected<
302 std::shared_ptr<types::IAssetAdministrationShell>,
305 const nlohmann::json& json,
306 bool additional_properties = false
307);
308
318common::expected<
319 std::shared_ptr<types::IAssetInformation>,
322 const nlohmann::json& json,
323 bool additional_properties = false
324);
325
335common::expected<
336 std::shared_ptr<types::IResource>,
339 const nlohmann::json& json,
340 bool additional_properties = false
341);
342
352common::expected<
353 std::shared_ptr<types::ISpecificAssetId>,
356 const nlohmann::json& json,
357 bool additional_properties = false
358);
359
369common::expected<
370 std::shared_ptr<types::ISubmodel>,
373 const nlohmann::json& json,
374 bool additional_properties = false
375);
376
386common::expected<
387 std::shared_ptr<types::ISubmodelElement>,
390 const nlohmann::json& json,
391 bool additional_properties = false
392);
393
403common::expected<
404 std::shared_ptr<types::IRelationshipElement>,
407 const nlohmann::json& json,
408 bool additional_properties = false
409);
410
420common::expected<
421 std::shared_ptr<types::ISubmodelElementList>,
424 const nlohmann::json& json,
425 bool additional_properties = false
426);
427
437common::expected<
438 std::shared_ptr<types::ISubmodelElementCollection>,
441 const nlohmann::json& json,
442 bool additional_properties = false
443);
444
454common::expected<
455 std::shared_ptr<types::IDataElement>,
458 const nlohmann::json& json,
459 bool additional_properties = false
460);
461
471common::expected<
472 std::shared_ptr<types::IProperty>,
475 const nlohmann::json& json,
476 bool additional_properties = false
477);
478
488common::expected<
489 std::shared_ptr<types::IMultiLanguageProperty>,
492 const nlohmann::json& json,
493 bool additional_properties = false
494);
495
505common::expected<
506 std::shared_ptr<types::IRange>,
509 const nlohmann::json& json,
510 bool additional_properties = false
511);
512
522common::expected<
523 std::shared_ptr<types::IReferenceElement>,
526 const nlohmann::json& json,
527 bool additional_properties = false
528);
529
539common::expected<
540 std::shared_ptr<types::IBlob>,
543 const nlohmann::json& json,
544 bool additional_properties = false
545);
546
556common::expected<
557 std::shared_ptr<types::IFile>,
560 const nlohmann::json& json,
561 bool additional_properties = false
562);
563
573common::expected<
574 std::shared_ptr<types::IAnnotatedRelationshipElement>,
577 const nlohmann::json& json,
578 bool additional_properties = false
579);
580
590common::expected<
591 std::shared_ptr<types::IEntity>,
594 const nlohmann::json& json,
595 bool additional_properties = false
596);
597
607common::expected<
608 std::shared_ptr<types::IEventPayload>,
611 const nlohmann::json& json,
612 bool additional_properties = false
613);
614
624common::expected<
625 std::shared_ptr<types::IEventElement>,
628 const nlohmann::json& json,
629 bool additional_properties = false
630);
631
641common::expected<
642 std::shared_ptr<types::IBasicEventElement>,
645 const nlohmann::json& json,
646 bool additional_properties = false
647);
648
658common::expected<
659 std::shared_ptr<types::IOperation>,
662 const nlohmann::json& json,
663 bool additional_properties = false
664);
665
675common::expected<
676 std::shared_ptr<types::IOperationVariable>,
679 const nlohmann::json& json,
680 bool additional_properties = false
681);
682
692common::expected<
693 std::shared_ptr<types::ICapability>,
696 const nlohmann::json& json,
697 bool additional_properties = false
698);
699
709common::expected<
710 std::shared_ptr<types::IConceptDescription>,
713 const nlohmann::json& json,
714 bool additional_properties = false
715);
716
726common::expected<
727 std::shared_ptr<types::IReference>,
730 const nlohmann::json& json,
731 bool additional_properties = false
732);
733
743common::expected<
744 std::shared_ptr<types::IKey>,
747 const nlohmann::json& json,
748 bool additional_properties = false
749);
750
760common::expected<
761 std::shared_ptr<types::IAbstractLangString>,
764 const nlohmann::json& json,
765 bool additional_properties = false
766);
767
777common::expected<
778 std::shared_ptr<types::ILangStringNameType>,
781 const nlohmann::json& json,
782 bool additional_properties = false
783);
784
794common::expected<
795 std::shared_ptr<types::ILangStringTextType>,
798 const nlohmann::json& json,
799 bool additional_properties = false
800);
801
811common::expected<
812 std::shared_ptr<types::IEnvironment>,
815 const nlohmann::json& json,
816 bool additional_properties = false
817);
818
828common::expected<
829 std::shared_ptr<types::IDataSpecificationContent>,
832 const nlohmann::json& json,
833 bool additional_properties = false
834);
835
845common::expected<
846 std::shared_ptr<types::IEmbeddedDataSpecification>,
849 const nlohmann::json& json,
850 bool additional_properties = false
851);
852
862common::expected<
863 std::shared_ptr<types::ILevelType>,
866 const nlohmann::json& json,
867 bool additional_properties = false
868);
869
879common::expected<
880 std::shared_ptr<types::IValueReferencePair>,
883 const nlohmann::json& json,
884 bool additional_properties = false
885);
886
896common::expected<
897 std::shared_ptr<types::IValueList>,
900 const nlohmann::json& json,
901 bool additional_properties = false
902);
903
913common::expected<
914 std::shared_ptr<types::ILangStringPreferredNameTypeIec61360>,
917 const nlohmann::json& json,
918 bool additional_properties = false
919);
920
930common::expected<
931 std::shared_ptr<types::ILangStringShortNameTypeIec61360>,
934 const nlohmann::json& json,
935 bool additional_properties = false
936);
937
947common::expected<
948 std::shared_ptr<types::ILangStringDefinitionTypeIec61360>,
951 const nlohmann::json& json,
952 bool additional_properties = false
953);
954
964common::expected<
965 std::shared_ptr<types::IDataSpecificationIec61360>,
968 const nlohmann::json& json,
969 bool additional_properties = false
970);
971
972// endregion Deserialization
973
974// region Serialization
975
979class SerializationException : public std::exception {
980 public:
982 std::wstring cause,
984 );
985
986 const char* what() const noexcept override;
987
988 const std::wstring& cause() const noexcept;
989 const iteration::Path& path() const noexcept;
990
991 ~SerializationException() noexcept override = default;
992
993 private:
994 const std::wstring cause_;
995 const iteration::Path path_;
996 const std::string msg_;
997}; // class SerializationException
998
1007nlohmann::json Serialize(
1008 const types::IClass& that
1009);
1010
1011// endregion Serialization
1012
1013} // namespace jsonization
1014
1015
1016} // namespace aas_3_0
1017} // namespace aas_core
1018
1019// This code has been automatically generated by aas-core-codegen.
1020// Do NOT edit or append.
1021
1022#endif // AAS_CORE_AAS_3_0_JSONIZATION_GUARD_
Definition jsonization.hpp:35
virtual std::wstring ToWstring() const =0
Convert the segment to a string in a JSON path.
virtual std::unique_ptr< ISegment > Clone() const =0
const char * what() const noexcept override
const std::wstring & cause() const noexcept
SerializationException(std::wstring cause, iteration::Path path)
const iteration::Path & path() const noexcept
Definition iteration.hpp:27
Definition jsonization.hpp:30
common::expected< std::shared_ptr< types::ILangStringPreferredNameTypeIec61360 >, DeserializationError > LangStringPreferredNameTypeIec61360From(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ILangStringPreferredNameTypeIec61360.
common::expected< std::shared_ptr< types::IResource >, DeserializationError > ResourceFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IResource.
common::expected< std::shared_ptr< types::IHasKind >, DeserializationError > HasKindFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IHasKind.
common::expected< std::shared_ptr< types::IRange >, DeserializationError > RangeFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IRange.
common::expected< std::shared_ptr< types::IBlob >, DeserializationError > BlobFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IBlob.
common::expected< std::shared_ptr< types::IRelationshipElement >, DeserializationError > RelationshipElementFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IRelationshipElement.
common::expected< std::shared_ptr< types::IEmbeddedDataSpecification >, DeserializationError > EmbeddedDataSpecificationFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IEmbeddedDataSpecification.
common::expected< std::shared_ptr< types::IFile >, DeserializationError > FileFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IFile.
common::expected< std::shared_ptr< types::ICapability >, DeserializationError > CapabilityFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ICapability.
common::expected< std::shared_ptr< types::IEnvironment >, DeserializationError > EnvironmentFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IEnvironment.
common::expected< std::shared_ptr< types::IMultiLanguageProperty >, DeserializationError > MultiLanguagePropertyFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IMultiLanguageProperty.
common::expected< std::shared_ptr< types::ILangStringNameType >, DeserializationError > LangStringNameTypeFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ILangStringNameType.
common::expected< std::shared_ptr< types::IKey >, DeserializationError > KeyFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IKey.
nlohmann::json Serialize(const types::IClass &that)
Serialize that instance to a JSON value.
common::expected< std::shared_ptr< types::IHasExtensions >, DeserializationError > HasExtensionsFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IHasExtensions.
common::expected< std::shared_ptr< types::IReference >, DeserializationError > ReferenceFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IReference.
common::expected< std::shared_ptr< types::IAnnotatedRelationshipElement >, DeserializationError > AnnotatedRelationshipElementFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IAnnotatedRelationshipElement.
common::expected< std::shared_ptr< types::IDataSpecificationIec61360 >, DeserializationError > DataSpecificationIec61360From(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IDataSpecificationIec61360.
common::expected< std::shared_ptr< types::ISubmodel >, DeserializationError > SubmodelFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ISubmodel.
common::expected< std::shared_ptr< types::IProperty >, DeserializationError > PropertyFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IProperty.
common::expected< std::shared_ptr< types::IIdentifiable >, DeserializationError > IdentifiableFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IIdentifiable.
common::expected< std::shared_ptr< types::IAdministrativeInformation >, DeserializationError > AdministrativeInformationFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IAdministrativeInformation.
common::expected< std::shared_ptr< types::IAssetInformation >, DeserializationError > AssetInformationFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IAssetInformation.
common::expected< std::shared_ptr< types::ISubmodelElementCollection >, DeserializationError > SubmodelElementCollectionFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ISubmodelElementCollection.
common::expected< std::shared_ptr< types::IReferable >, DeserializationError > ReferableFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IReferable.
common::expected< std::shared_ptr< types::IDataSpecificationContent >, DeserializationError > DataSpecificationContentFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IDataSpecificationContent.
common::expected< std::shared_ptr< types::IDataElement >, DeserializationError > DataElementFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IDataElement.
common::expected< std::shared_ptr< types::IExtension >, DeserializationError > ExtensionFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IExtension.
common::expected< std::shared_ptr< types::IHasSemantics >, DeserializationError > HasSemanticsFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IHasSemantics.
common::expected< std::shared_ptr< types::ILangStringShortNameTypeIec61360 >, DeserializationError > LangStringShortNameTypeIec61360From(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ILangStringShortNameTypeIec61360.
common::expected< std::shared_ptr< types::IConceptDescription >, DeserializationError > ConceptDescriptionFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IConceptDescription.
common::expected< std::shared_ptr< types::IEntity >, DeserializationError > EntityFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IEntity.
common::expected< std::shared_ptr< types::IValueList >, DeserializationError > ValueListFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IValueList.
common::expected< std::shared_ptr< types::ISubmodelElementList >, DeserializationError > SubmodelElementListFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ISubmodelElementList.
common::expected< std::shared_ptr< types::IReferenceElement >, DeserializationError > ReferenceElementFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IReferenceElement.
common::expected< std::shared_ptr< types::ISpecificAssetId >, DeserializationError > SpecificAssetIdFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ISpecificAssetId.
common::expected< std::shared_ptr< types::IQualifier >, DeserializationError > QualifierFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IQualifier.
common::expected< std::shared_ptr< types::IEventPayload >, DeserializationError > EventPayloadFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IEventPayload.
common::expected< std::shared_ptr< types::ILevelType >, DeserializationError > LevelTypeFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ILevelType.
common::expected< std::shared_ptr< types::IOperation >, DeserializationError > OperationFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IOperation.
common::expected< std::shared_ptr< types::IAssetAdministrationShell >, DeserializationError > AssetAdministrationShellFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IAssetAdministrationShell.
common::expected< std::shared_ptr< types::IOperationVariable >, DeserializationError > OperationVariableFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IOperationVariable.
common::expected< std::shared_ptr< types::IBasicEventElement >, DeserializationError > BasicEventElementFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IBasicEventElement.
common::expected< std::shared_ptr< types::ILangStringDefinitionTypeIec61360 >, DeserializationError > LangStringDefinitionTypeIec61360From(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ILangStringDefinitionTypeIec61360.
common::expected< std::shared_ptr< types::IValueReferencePair >, DeserializationError > ValueReferencePairFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IValueReferencePair.
common::expected< std::shared_ptr< types::IAbstractLangString >, DeserializationError > AbstractLangStringFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IAbstractLangString.
common::expected< std::shared_ptr< types::ISubmodelElement >, DeserializationError > SubmodelElementFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ISubmodelElement.
common::expected< std::shared_ptr< types::IQualifiable >, DeserializationError > QualifiableFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IQualifiable.
common::expected< std::shared_ptr< types::IHasDataSpecification >, DeserializationError > HasDataSpecificationFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IHasDataSpecification.
common::expected< std::shared_ptr< types::ILangStringTextType >, DeserializationError > LangStringTextTypeFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::ILangStringTextType.
common::expected< std::shared_ptr< types::IEventElement >, DeserializationError > EventElementFrom(const nlohmann::json &json, bool additional_properties=false)
Deserialize json value to an instance of types::IEventElement.
Definition types.hpp:28
Definition common.hpp:51
Definition common.hpp:50
Represent a path to some value.
Definition iteration.hpp:185
DeserializationError(std::wstring a_cause, Path a_path)
Path path
Definition jsonization.hpp:116
std::wstring cause
Definition jsonization.hpp:111
std::unique_ptr< ISegment > Clone() const override
size_t index
Definition jsonization.hpp:74
std::wstring ToWstring() const override
Convert the segment to a string in a JSON path.
Definition jsonization.hpp:90
std::deque< std::unique_ptr< ISegment > > segments
Definition jsonization.hpp:91
Path & operator=(const Path &other)
std::unique_ptr< ISegment > Clone() const override
std::wstring ToWstring() const override
Convert the segment to a string in a JSON path.
std::wstring name
Definition jsonization.hpp:54