aas-core3 1.0.1
Manipulate, verify and de/serialize asset administration shells in C++.
Loading...
Searching...
No Matches
verification.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_VERIFICATION_GUARD_
6#define AAS_CORE_AAS_3_0_VERIFICATION_GUARD_
7
8// This code has been automatically generated by aas-core-codegen.
9// Do NOT edit or append.
10
15
16#pragma warning(push, 0)
17#include <set>
18#pragma warning(pop)
19
20namespace aas_core {
21namespace aas_3_0 {
22
27namespace verification {
28
29// region Forward declarations
30class Iterator;
31class IVerification;
32
33namespace impl {
34class IVerificator;
35} // namespace impl
36// endregion Forward declarations
37
41struct Error {
45 std::wstring cause;
46
51
52 explicit Error(std::wstring a_cause);
53 Error(std::wstring a_cause, iteration::Path a_path);
54}; // struct Error
55
80class Iterator {
81 using iterator_category = std::forward_iterator_tag;
83 using difference_type = std::ptrdiff_t;
84 using value_type = Error;
85 using pointer = const Error*;
86 using reference = const Error&;
87
88 public:
89 explicit Iterator(
90 std::unique_ptr<impl::IVerificator> verificator
91 ) :
92 verificator_(std::move(verificator)) {
93 // Intentionally empty.
94 }
95
96 Iterator(const Iterator& other);
98
99 Iterator& operator=(const Iterator& other);
101
102 reference operator*() const;
103 pointer operator->() const;
104
105 // Prefix increment
107
108 // Postfix increment
110
111 friend bool operator==(const Iterator& a, const Iterator& b);
112 friend bool operator!=(const Iterator& a, const Iterator& b);
113
114 private:
115 std::unique_ptr<impl::IVerificator> verificator_;
116};
117
118bool operator==(const Iterator& a, const Iterator& b);
119
120bool operator!=(const Iterator& a, const Iterator& b);
121
123namespace impl {
124class IVerificator {
125 public:
126 virtual void Start() = 0;
127 virtual void Next() = 0;
128 virtual bool Done() const = 0;
129
130 virtual const Error& Get() const = 0;
131 virtual Error& GetMutable() = 0;
132 virtual long Index() const = 0;
133
134 virtual std::unique_ptr<IVerificator> Clone() const = 0;
135
136 virtual ~IVerificator() = default;
137}; // class IVerificator
138} // namespace impl
140
142 public:
143 virtual Iterator begin() const = 0;
144 virtual const Iterator& end() const = 0;
145 virtual ~IVerification() = default;
146}; // class IVerification
147
171 public:
173 const std::shared_ptr<types::IClass>& instance
174 );
175
176 Iterator begin() const override;
177 const Iterator& end() const override;
178
179 ~NonRecursiveVerification() override = default;
180 private:
181 const std::shared_ptr<types::IClass>& instance_;
182}; // class NonRecursiveVerification
183
207 public:
209 const std::shared_ptr<types::IClass>& instance
210 );
211
212 Iterator begin() const override;
213 const Iterator& end() const override;
214
215 ~RecursiveVerification() override = default;
216 private:
217 const std::shared_ptr<types::IClass>& instance_;
218}; // class RecursiveVerification
219
220// region Verification functions
221
224 const std::wstring& text
225);
226
229 const std::wstring& text
230);
231
234 const std::wstring& text
235);
236
245 const std::wstring& text
246);
247
258 const std::wstring& text
259);
260
268 const std::wstring& text
269);
270
280 const std::wstring& text
281);
282
287 const std::wstring& text
288);
289
292template<
293 typename LangStringT,
294 typename std::enable_if<
295 std::is_base_of<types::IAbstractLangString, LangStringT>::value
296 >::type* = nullptr
297>
299 const std::vector<
300 std::shared_ptr<LangStringT>
301 >& lang_strings
302) {
303 // NOTE (mristin):
304 // See: https://stackoverflow.com/questions/1349734/why-would-anyone-use-set-instead-of-unordered-set
305 // For small sets, std::set is often faster than std::unordered_set.
306 std::set<std::wstring> language_set;
307
308 for (const std::shared_ptr<LangStringT>& lang_string : lang_strings) {
309 const std::wstring& language = lang_string->language();
310
311 if (language_set.find(language) != language_set.end()) {
312 return false;
313 }
314 language_set.insert(language);
315 }
316
317 return true;
318}
319
322 const std::vector<
323 std::shared_ptr<types::IQualifier>
324 >& qualifiers
325);
326
332 const std::wstring& text
333);
334
340 const std::wstring& text
341);
342
347 const std::wstring& text
348);
349
354 const std::wstring& text
355);
356
361 const std::wstring& text
362);
363
368 const std::wstring& text
369);
370
379 const std::wstring& text
380);
381
386 const std::wstring& text
387);
388
393 const std::wstring& text
394);
395
400 const std::wstring& text
401);
402
407 const std::wstring& text
408);
409
414 const std::wstring& text
415);
416
421 const std::wstring& text
422);
423
428 const std::wstring& text
429);
430
435 const std::wstring& text
436);
437
442 const std::wstring& text
443);
444
449 const std::wstring& text
450);
451
456 const std::wstring& text
457);
458
463 const std::wstring& text
464);
465
470 const std::wstring& text
471);
472
477 const std::wstring& text
478);
479
484 const std::wstring& text
485);
486
491 const std::wstring& text
492);
493
498 const std::wstring& text
499);
500
505 const std::wstring& text
506);
507
512 const std::wstring& text
513);
514
519 const std::wstring& text
520);
521
526 const std::wstring& text
527);
528
533 const std::wstring& text
534);
535
540 const std::wstring& text
541);
542
547 const std::wstring& text
548);
549
554 const std::wstring& text
555);
556
559 const std::wstring& value,
560 types::DataTypeDefXsd value_type
561);
562
572bool IsXsDate(const std::wstring& text);
573
580bool IsXsDouble(const std::wstring& value);
581
588bool IsXsFloat(const std::wstring& value);
589
596bool IsXsGMonthDay(const std::wstring& value);
597
604bool IsXsLong(const std::wstring& value);
605
612bool IsXsInt(const std::wstring& value);
613
620bool IsXsShort(const std::wstring& value);
621
628bool IsXsByte(const std::wstring& value);
629
636bool IsXsUnsignedLong(const std::wstring& value);
637
644bool IsXsUnsignedInt(const std::wstring& value);
645
652bool IsXsUnsignedShort(const std::wstring& value);
653
660bool IsXsUnsignedByte(const std::wstring& value);
661
664 const std::shared_ptr<types::IReference>& reference,
665 types::KeyTypes expected_type
666);
667
670 const std::shared_ptr<types::IReference>& reference
671);
672
675template<
676 typename ReferableT,
677 typename std::enable_if<
678 std::is_base_of<types::IReferable, ReferableT>::value
679 >::type* = nullptr
681 const std::vector<
682 std::shared_ptr<ReferableT>
683 >& referables
684) {
685 std::set<std::wstring> id_short_set;
686
687 for (const std::shared_ptr<types::IReferable> referable : referables) {
688 const common::optional<std::wstring>& id_short = referable->id_short();
689
690 if (id_short.has_value()) {
691 if (id_short_set.find(*id_short) != id_short_set.end()) {
692 return false;
693 }
694
695 id_short_set.insert(*id_short);
696 }
697 }
698
699 return true;
700}
701
706 const common::optional<
707 std::vector<
708 std::shared_ptr<types::IOperationVariable>
709 >
710 >& input_variables,
711 const common::optional<
712 std::vector<
713 std::shared_ptr<types::IOperationVariable>
714 >
715 >& output_variables,
716 const common::optional<
717 std::vector<
718 std::shared_ptr<types::IOperationVariable>
719 >
720 >& inoutput_variables
721);
722
725 const std::vector<
726 std::shared_ptr<types::IExtension>
727 >& extensions
728);
729
732 const std::vector<
733 std::shared_ptr<types::ISubmodelElement>
734 >& elements
735);
736
740 const std::shared_ptr<types::ISubmodelElement>& element,
741 types::AasSubmodelElements element_type
742);
743
746 const std::vector<
747 std::shared_ptr<types::ISubmodelElement>
748 >& elements,
749 types::DataTypeDefXsd value_type
750);
751
754 const std::shared_ptr<types::IReference>& that,
755 const std::shared_ptr<types::IReference>& other
756);
757
761 const std::vector<
762 std::shared_ptr<types::IEmbeddedDataSpecification>
763 >& embedded_data_specifications
764);
765
769 const std::vector<
770 std::shared_ptr<types::IEmbeddedDataSpecification>
771 >& embedded_data_specifications
772);
773
777 const std::vector<
778 std::shared_ptr<types::IEmbeddedDataSpecification>
779 >& embedded_data_specifications
780);
781
785 const std::vector<
786 std::shared_ptr<types::IEmbeddedDataSpecification>
787 >& embedded_data_specifications
788);
789
793 const std::vector<
794 std::shared_ptr<types::IEmbeddedDataSpecification>
795 >& embedded_data_specifications
796);
797
801 const std::vector<
802 std::shared_ptr<types::IEmbeddedDataSpecification>
803 >& embedded_data_specifications
804);
805
808 const std::wstring& text
809);
810
811// endregion Verification functions
812
813// region Verification of constrained primitives
814
823std::unique_ptr<IVerification> VerifyXmlSerializableString(
824 const std::wstring& that
825);
826
835std::unique_ptr<IVerification> VerifyNonEmptyXmlSerializableString(
836 const std::wstring& that
837);
838
847std::unique_ptr<IVerification> VerifyDateTimeUtc(
848 const std::wstring& that
849);
850
859std::unique_ptr<IVerification> VerifyDuration(
860 const std::wstring& that
861);
862
871std::unique_ptr<IVerification> VerifyBlobType(
872 const std::vector<std::uint8_t>& that
873);
874
883std::unique_ptr<IVerification> VerifyIdentifier(
884 const std::wstring& that
885);
886
895std::unique_ptr<IVerification> VerifyValueTypeIec61360(
896 const std::wstring& that
897);
898
907std::unique_ptr<IVerification> VerifyNameType(
908 const std::wstring& that
909);
910
919std::unique_ptr<IVerification> VerifyVersionType(
920 const std::wstring& that
921);
922
931std::unique_ptr<IVerification> VerifyRevisionType(
932 const std::wstring& that
933);
934
943std::unique_ptr<IVerification> VerifyLabelType(
944 const std::wstring& that
945);
946
955std::unique_ptr<IVerification> VerifyMessageTopicType(
956 const std::wstring& that
957);
958
967std::unique_ptr<IVerification> VerifyBcp47LanguageTag(
968 const std::wstring& that
969);
970
979std::unique_ptr<IVerification> VerifyContentType(
980 const std::wstring& that
981);
982
991std::unique_ptr<IVerification> VerifyPathType(
992 const std::wstring& that
993);
994
1003std::unique_ptr<IVerification> VerifyQualifierType(
1004 const std::wstring& that
1005);
1006
1015std::unique_ptr<IVerification> VerifyValueDataType(
1016 const std::wstring& that
1017);
1018
1027std::unique_ptr<IVerification> VerifyIdShortType(
1028 const std::wstring& that
1029);
1030
1031// endregion Verification of constrained primitives
1032
1033} // namespace verification
1034
1035
1036} // namespace aas_3_0
1037} // namespace aas_core
1038
1039// This code has been automatically generated by aas-core-codegen.
1040// Do NOT edit or append.
1041
1042#endif // AAS_CORE_AAS_3_0_VERIFICATION_GUARD_
Definition verification.hpp:141
virtual const Iterator & end() const =0
Iterate over the verification errors.
Definition verification.hpp:80
Iterator(std::unique_ptr< impl::IVerificator > verificator)
Definition verification.hpp:89
friend bool operator!=(const Iterator &a, const Iterator &b)
Iterator & operator=(Iterator &&other)
Iterator & operator=(const Iterator &other)
friend bool operator==(const Iterator &a, const Iterator &b)
NonRecursiveVerification(const std::shared_ptr< types::IClass > &instance)
RecursiveVerification(const std::shared_ptr< types::IClass > &instance)
AasSubmodelElements
Enumeration of all possible elements of a ISubmodelElementList.
Definition types.hpp:119
DataTypeDefXsd
Enumeration listing all XSD anySimpleTypes.
Definition types.hpp:234
KeyTypes
Enumeration of different key value types within a key.
Definition types.hpp:183
Definition verification.hpp:33
Definition verification.hpp:27
bool IsXsUnsignedShort(const std::wstring &value)
Check that value is a valid xs:unsignedShort.
bool MatchesXsUnsignedShort(const std::wstring &text)
Check that text conforms to the pattern of an xs:unsignedShort.
bool IsXsUnsignedByte(const std::wstring &value)
Check that value is a valid xs:unsignedByte.
std::unique_ptr< IVerification > VerifyBcp47LanguageTag(const std::wstring &that)
Verify that the invariants hold for that value.
std::unique_ptr< IVerification > VerifyValueDataType(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsShort(const std::wstring &text)
Check that text conforms to the pattern of an xs:short.
bool operator!=(const Iterator &a, const Iterator &b)
bool MatchesXsByte(const std::wstring &text)
Check that text conforms to the pattern of an xs:byte.
bool MatchesXsTime(const std::wstring &text)
Check that text conforms to the pattern of an xs:time.
bool IdShortsOfVariablesAreUnique(const common::optional< std::vector< std::shared_ptr< types::IOperationVariable > > > &input_variables, const common::optional< std::vector< std::shared_ptr< types::IOperationVariable > > > &output_variables, const common::optional< std::vector< std::shared_ptr< types::IOperationVariable > > > &inoutput_variables)
Check that the types::IReferable::id_short's among all the input_variables, output_variables and inou...
std::unique_ptr< IVerification > VerifyIdentifier(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsGYearMonth(const std::wstring &text)
Check that text conforms to the pattern of an xs:gYearMonth.
std::unique_ptr< IVerification > VerifyNameType(const std::wstring &that)
Verify that the invariants hold for that value.
std::unique_ptr< IVerification > VerifyBlobType(const std::vector< std::uint8_t > &that)
Verify that the invariants hold for that value.
bool MatchesXsGDay(const std::wstring &text)
Check that text conforms to the pattern of an xs:gDay.
bool IsXsLong(const std::wstring &value)
Check that value is a valid xs:long.
bool MatchesRevisionType(const std::wstring &text)
Check that text is a valid revision string.
bool MatchesXsUnsignedLong(const std::wstring &text)
Check that text conforms to the pattern of an xs:unsignedLong.
std::unique_ptr< IVerification > VerifyVersionType(const std::wstring &that)
Verify that the invariants hold for that value.
bool IsXsDate(const std::wstring &text)
Check that value is a valid xs:date.
bool MatchesXsInt(const std::wstring &text)
Check that text conforms to the pattern of an xs:int.
bool MatchesXsDate(const std::wstring &text)
Check that text conforms to the pattern of an xs:date.
bool IsXsByte(const std::wstring &value)
Check that value is a valid xs:byte.
bool IsModelReferenceToReferable(const std::shared_ptr< types::IReference > &reference)
Check that the target of the reference matches a constants::kAasReferables.
bool MatchesXsInteger(const std::wstring &text)
Check that text conforms to the pattern of an xs:integer.
bool QualifierTypesAreUnique(const std::vector< std::shared_ptr< types::IQualifier > > &qualifiers)
Check that types::IQualifier::type's of qualifiers are unique.
bool MatchesXsGMonthDay(const std::wstring &text)
Check that text conforms to the pattern of an xs:gMonthDay.
bool MatchesIdShort(const std::wstring &text)
Check that text is a valid short ID.
bool MatchesXsDateTime(const std::wstring &text)
Check that text conforms to the pattern of an xs:dateTime.
bool MatchesXsNonNegativeInteger(const std::wstring &text)
Check that text conforms to the pattern of an xs:nonNegativeInteger.
std::unique_ptr< IVerification > VerifyRevisionType(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsDuration(const std::wstring &text)
Check that text conforms to the pattern of an xs:duration.
bool IsXsUnsignedLong(const std::wstring &value)
Check that value is a valid xs:unsignedLong.
std::unique_ptr< IVerification > VerifyContentType(const std::wstring &that)
Verify that the invariants hold for that value.
std::unique_ptr< IVerification > VerifyDuration(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsDouble(const std::wstring &text)
Check that text conforms to the pattern of an xs:double.
bool MatchesVersionType(const std::wstring &text)
Check that text is a valid version string.
bool IsXsDateTime(const std::wstring &text)
Check that text is a xs:dateTime with time zone set to UTC.
bool IsXsUnsignedInt(const std::wstring &value)
Check that value is a valid xs:unsignedInt.
std::unique_ptr< IVerification > VerifyXmlSerializableString(const std::wstring &that)
Verify that the invariants hold for that value.
std::unique_ptr< IVerification > VerifyLabelType(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsGYear(const std::wstring &text)
Check that text conforms to the pattern of an xs:gYear.
bool MatchesXsDateTimeUtc(const std::wstring &text)
Check that text conforms to the pattern of an xs:dateTime.
bool DataSpecificationIec61360sForPropertyOrValueHaveAppropriateDataType(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::data_type is defined appropriately for all data spe...
bool SubmodelElementsHaveIdenticalSemanticIds(const std::vector< std::shared_ptr< types::ISubmodelElement > > &elements)
Check that all semantic IDs are identical, if specified.
std::unique_ptr< IVerification > VerifyNonEmptyXmlSerializableString(const std::wstring &that)
Verify that the invariants hold for that value.
bool ValueConsistentWithXsdType(const std::wstring &value, types::DataTypeDefXsd value_type)
Check that the value conforms to its value_type.
bool MatchesXsAnyUri(const std::wstring &text)
Check that text conforms to the pattern of an xs:anyURI.
bool MatchesXsFloat(const std::wstring &text)
Check that text conforms to the pattern of an xs:float.
bool IsXsDouble(const std::wstring &value)
Check that value is a valid xs:double.
bool IdShortsAreUnique(const std::vector< std::shared_ptr< ReferableT > > &referables)
Check that the types::IReferable::id_short's among the referables are unique.
Definition verification.hpp:680
std::unique_ptr< IVerification > VerifyQualifierType(const std::wstring &that)
Verify that the invariants hold for that value.
bool IsModelReferenceTo(const std::shared_ptr< types::IReference > &reference, types::KeyTypes expected_type)
Check that the target of the model reference matches the expected_type.
std::unique_ptr< IVerification > VerifyValueTypeIec61360(const std::wstring &that)
Verify that the invariants hold for that value.
std::unique_ptr< IVerification > VerifyDateTimeUtc(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesMimeType(const std::wstring &text)
Check that text conforms to the pattern of MIME type.
bool MatchesRfc2396(const std::wstring &text)
Check that text matches to the URI pattern defined in RFC 2396.
bool MatchesXsString(const std::wstring &text)
Check that text conforms to the pattern of an xs:string.
std::unique_ptr< IVerification > VerifyPathType(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsBase64Binary(const std::wstring &text)
Check that text conforms to the pattern of an xs:base64Binary.
bool DataSpecificationIec61360sHaveValue(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::value is defined for all data specifications whose ...
bool MatchesXsLong(const std::wstring &text)
Check that text conforms to the pattern of an xs:long.
bool MatchesXsPositiveInteger(const std::wstring &text)
Check that text conforms to the pattern of an xs:positiveInteger.
bool IsBcp47ForEnglish(const std::wstring &text)
Check that the text corresponds to a BCP47 code for english.
bool MatchesXsUnsignedByte(const std::wstring &text)
Check that text conforms to the pattern of an xs:unsignedByte.
bool DataSpecificationIec61360sForReferenceHaveAppropriateDataType(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::data_type is defined appropriately for all data spe...
bool MatchesXmlSerializableString(const std::wstring &text)
Check that text conforms to the pattern of the Constraint AASd-130.
bool DataSpecificationIec61360sHaveDataType(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::data_type is defined for all data specifications wh...
bool ExtensionNamesAreUnique(const std::vector< std::shared_ptr< types::IExtension > > &extensions)
Check that the extension names are unique.
bool PropertiesOrRangesHaveValueType(const std::vector< std::shared_ptr< types::ISubmodelElement > > &elements, types::DataTypeDefXsd value_type)
Check that all the elements have the value_type.
bool DataSpecificationIec61360sForDocumentHaveAppropriateDataType(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::data_type is defined appropriately for all data spe...
std::unique_ptr< IVerification > VerifyMessageTopicType(const std::wstring &that)
Verify that the invariants hold for that value.
bool LangStringsHaveUniqueLanguages(const std::vector< std::shared_ptr< LangStringT > > &lang_strings)
Check that the lang_strings do not have overlapping types::IAbstractLangString::language's.
Definition verification.hpp:298
bool MatchesXsBoolean(const std::wstring &text)
Check that text conforms to the pattern of an xs:boolean.
bool IsXsDateTimeUtc(const std::wstring &text)
Check that text is a xs:dateTime with time zone set to UTC.
bool MatchesBcp47(const std::wstring &text)
Check that text is a valid BCP 47 language tag.
bool IsXsShort(const std::wstring &value)
Check that value is a valid xs:short.
bool IsXsInt(const std::wstring &value)
Check that value is a valid xs:int.
bool MatchesXsDecimal(const std::wstring &text)
Check that text conforms to the pattern of an xs:decimal.
bool MatchesXsNonPositiveInteger(const std::wstring &text)
Check that text conforms to the pattern of an xs:nonPositiveInteger.
bool MatchesXsHexBinary(const std::wstring &text)
Check that text conforms to the pattern of an xs:hexBinary.
bool MatchesXsGMonth(const std::wstring &text)
Check that text conforms to the pattern of an xs:gMonth.
bool DataSpecificationIec61360sHaveDefinitionAtLeastInEnglish(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::definition is defined for all data specifications w...
bool MatchesXsUnsignedInt(const std::wstring &text)
Check that text conforms to the pattern of an xs:unsignedInt.
bool operator==(const Iterator &a, const Iterator &b)
bool SubmodelElementIsOfType(const std::shared_ptr< types::ISubmodelElement > &element, types::AasSubmodelElements element_type)
Check that the run-time type of the element coincides with element_type.
bool ReferenceKeyValuesEqual(const std::shared_ptr< types::IReference > &that, const std::shared_ptr< types::IReference > &other)
Check that the two references are equal by comparing their key values.
bool MatchesXsNegativeInteger(const std::wstring &text)
Check that text conforms to the pattern of an xs:negativeInteger.
bool IsXsGMonthDay(const std::wstring &value)
Check that value is a valid xs:gMonthDay.
bool IsXsFloat(const std::wstring &value)
Check that value is a valid xs:float.
std::unique_ptr< IVerification > VerifyIdShortType(const std::wstring &that)
Verify that the invariants hold for that value.
Definition common.hpp:51
Definition common.hpp:50
Represent a path to some value.
Definition iteration.hpp:185
Definition verification.hpp:41
iteration::Path path
Definition verification.hpp:50
Error(std::wstring a_cause, iteration::Path a_path)
std::wstring cause
Definition verification.hpp:45