aas-core3 1.0.0
Manipulate, verify and de/serialize asset administration shells in C++.
Loading...
Searching...
No Matches
verification.hpp
Go to the documentation of this file.
1#ifndef AAS_CORE_AAS_3_0_VERIFICATION_GUARD_
2#define AAS_CORE_AAS_3_0_VERIFICATION_GUARD_
3
4// This code has been automatically generated by aas-core-codegen.
5// Do NOT edit or append.
6
11
12#pragma warning(push, 0)
13#include <set>
14#pragma warning(pop)
15
16namespace aas_core {
17namespace aas_3_0 {
18
23namespace verification {
24
25// region Forward declarations
26class Iterator;
27class IVerification;
28
29namespace impl {
30class IVerificator;
31} // namespace impl
32// endregion Forward declarations
33
37struct Error {
41 std::wstring cause;
42
47
48 explicit Error(std::wstring a_cause);
49 Error(std::wstring a_cause, iteration::Path a_path);
50}; // struct Error
51
76class Iterator {
77 using iterator_category = std::forward_iterator_tag;
79 using difference_type = std::ptrdiff_t;
80 using value_type = Error;
81 using pointer = const Error*;
82 using reference = const Error&;
83
84 public:
85 explicit Iterator(
86 std::unique_ptr<impl::IVerificator> verificator
87 ) :
88 verificator_(std::move(verificator)) {
89 // Intentionally empty.
90 }
91
92 Iterator(const Iterator& other);
94
95 Iterator& operator=(const Iterator& other);
97
98 reference operator*() const;
99 pointer operator->() const;
100
101 // Prefix increment
103
104 // Postfix increment
106
107 friend bool operator==(const Iterator& a, const Iterator& b);
108 friend bool operator!=(const Iterator& a, const Iterator& b);
109
110 private:
111 std::unique_ptr<impl::IVerificator> verificator_;
112};
113
114bool operator==(const Iterator& a, const Iterator& b);
115
116bool operator!=(const Iterator& a, const Iterator& b);
117
119namespace impl {
120class IVerificator {
121 public:
122 virtual void Start() = 0;
123 virtual void Next() = 0;
124 virtual bool Done() const = 0;
125
126 virtual const Error& Get() const = 0;
127 virtual Error& GetMutable() = 0;
128 virtual long Index() const = 0;
129
130 virtual std::unique_ptr<IVerificator> Clone() const = 0;
131
132 virtual ~IVerificator() = default;
133}; // class IVerificator
134} // namespace impl
136
138 public:
139 virtual Iterator begin() const = 0;
140 virtual const Iterator& end() const = 0;
141 virtual ~IVerification() = default;
142}; // class IVerification
143
167 public:
169 const std::shared_ptr<types::IClass>& instance
170 );
171
172 Iterator begin() const override;
173 const Iterator& end() const override;
174
175 ~NonRecursiveVerification() override = default;
176 private:
177 const std::shared_ptr<types::IClass>& instance_;
178}; // class NonRecursiveVerification
179
203 public:
205 const std::shared_ptr<types::IClass>& instance
206 );
207
208 Iterator begin() const override;
209 const Iterator& end() const override;
210
211 ~RecursiveVerification() override = default;
212 private:
213 const std::shared_ptr<types::IClass>& instance_;
214}; // class RecursiveVerification
215
216// region Verification functions
217
220 const std::wstring& text
221);
222
225 const std::wstring& text
226);
227
230 const std::wstring& text
231);
232
241 const std::wstring& text
242);
243
254 const std::wstring& text
255);
256
264 const std::wstring& text
265);
266
272 const std::wstring& text
273);
274
279 const std::wstring& text
280);
281
284template<
285 typename LangStringT,
286 typename std::enable_if<
287 std::is_base_of<types::IAbstractLangString, LangStringT>::value
288 >::type* = nullptr
289>
291 const std::vector<
292 std::shared_ptr<LangStringT>
293 >& lang_strings
294) {
295 // NOTE (mristin):
296 // See: https://stackoverflow.com/questions/1349734/why-would-anyone-use-set-instead-of-unordered-set
297 // For small sets, std::set is often faster than std::unordered_set.
298 std::set<std::wstring> language_set;
299
300 for (const std::shared_ptr<LangStringT>& lang_string : lang_strings) {
301 const std::wstring& language = lang_string->language();
302
303 if (language_set.find(language) != language_set.end()) {
304 return false;
305 }
306 language_set.insert(language);
307 }
308
309 return true;
310}
311
314 const std::vector<
315 std::shared_ptr<types::IQualifier>
316 >& qualifiers
317);
318
324 const std::wstring& text
325);
326
332 const std::wstring& text
333);
334
339 const std::wstring& text
340);
341
346 const std::wstring& text
347);
348
353 const std::wstring& text
354);
355
360 const std::wstring& text
361);
362
371 const std::wstring& text
372);
373
378 const std::wstring& text
379);
380
385 const std::wstring& text
386);
387
392 const std::wstring& text
393);
394
399 const std::wstring& text
400);
401
406 const std::wstring& text
407);
408
413 const std::wstring& text
414);
415
420 const std::wstring& text
421);
422
427 const std::wstring& text
428);
429
434 const std::wstring& text
435);
436
441 const std::wstring& text
442);
443
448 const std::wstring& text
449);
450
455 const std::wstring& text
456);
457
462 const std::wstring& text
463);
464
469 const std::wstring& text
470);
471
476 const std::wstring& text
477);
478
483 const std::wstring& text
484);
485
490 const std::wstring& text
491);
492
497 const std::wstring& text
498);
499
504 const std::wstring& text
505);
506
511 const std::wstring& text
512);
513
518 const std::wstring& text
519);
520
525 const std::wstring& text
526);
527
532 const std::wstring& text
533);
534
539 const std::wstring& text
540);
541
546 const std::wstring& text
547);
548
551 const std::wstring& value,
552 types::DataTypeDefXsd value_type
553);
554
564bool IsXsDate(const std::wstring& text);
565
572bool IsXsDouble(const std::wstring& value);
573
580bool IsXsFloat(const std::wstring& value);
581
588bool IsXsGMonthDay(const std::wstring& value);
589
596bool IsXsLong(const std::wstring& value);
597
604bool IsXsInt(const std::wstring& value);
605
612bool IsXsShort(const std::wstring& value);
613
620bool IsXsByte(const std::wstring& value);
621
628bool IsXsUnsignedLong(const std::wstring& value);
629
636bool IsXsUnsignedInt(const std::wstring& value);
637
644bool IsXsUnsignedShort(const std::wstring& value);
645
652bool IsXsUnsignedByte(const std::wstring& value);
653
656 const std::shared_ptr<types::IReference>& reference,
657 types::KeyTypes expected_type
658);
659
662 const std::shared_ptr<types::IReference>& reference
663);
664
667template<
668 typename ReferableT,
669 typename std::enable_if<
670 std::is_base_of<types::IReferable, ReferableT>::value
671 >::type* = nullptr
673 const std::vector<
674 std::shared_ptr<ReferableT>
675 >& referables
676) {
677 std::set<std::wstring> id_short_set;
678
679 for (const std::shared_ptr<types::IReferable> referable : referables) {
680 const common::optional<std::wstring>& id_short = referable->id_short();
681
682 if (id_short.has_value()) {
683 if (id_short_set.find(*id_short) != id_short_set.end()) {
684 return false;
685 }
686
687 id_short_set.insert(*id_short);
688 }
689 }
690
691 return true;
692}
693
698 const common::optional<
699 std::vector<
700 std::shared_ptr<types::IOperationVariable>
701 >
702 >& input_variables,
703 const common::optional<
704 std::vector<
705 std::shared_ptr<types::IOperationVariable>
706 >
707 >& output_variables,
708 const common::optional<
709 std::vector<
710 std::shared_ptr<types::IOperationVariable>
711 >
712 >& inoutput_variables
713);
714
717 const std::vector<
718 std::shared_ptr<types::IExtension>
719 >& extensions
720);
721
724 const std::vector<
725 std::shared_ptr<types::ISubmodelElement>
726 >& elements
727);
728
732 const std::shared_ptr<types::ISubmodelElement>& element,
733 types::AasSubmodelElements element_type
734);
735
738 const std::vector<
739 std::shared_ptr<types::ISubmodelElement>
740 >& elements,
741 types::DataTypeDefXsd value_type
742);
743
746 const std::shared_ptr<types::IReference>& that,
747 const std::shared_ptr<types::IReference>& other
748);
749
753 const std::vector<
754 std::shared_ptr<types::IEmbeddedDataSpecification>
755 >& embedded_data_specifications
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
800 const std::wstring& text
801);
802
803// endregion Verification functions
804
805// region Verification of constrained primitives
806
815std::unique_ptr<IVerification> VerifyXmlSerializableString(
816 const std::wstring& that
817);
818
827std::unique_ptr<IVerification> VerifyNonEmptyXmlSerializableString(
828 const std::wstring& that
829);
830
839std::unique_ptr<IVerification> VerifyDateTimeUtc(
840 const std::wstring& that
841);
842
851std::unique_ptr<IVerification> VerifyDuration(
852 const std::wstring& that
853);
854
863std::unique_ptr<IVerification> VerifyBlobType(
864 const std::vector<std::uint8_t>& that
865);
866
875std::unique_ptr<IVerification> VerifyIdentifier(
876 const std::wstring& that
877);
878
887std::unique_ptr<IVerification> VerifyValueTypeIec61360(
888 const std::wstring& that
889);
890
899std::unique_ptr<IVerification> VerifyNameType(
900 const std::wstring& that
901);
902
911std::unique_ptr<IVerification> VerifyVersionType(
912 const std::wstring& that
913);
914
923std::unique_ptr<IVerification> VerifyRevisionType(
924 const std::wstring& that
925);
926
935std::unique_ptr<IVerification> VerifyLabelType(
936 const std::wstring& that
937);
938
947std::unique_ptr<IVerification> VerifyMessageTopicType(
948 const std::wstring& that
949);
950
959std::unique_ptr<IVerification> VerifyBcp47LanguageTag(
960 const std::wstring& that
961);
962
971std::unique_ptr<IVerification> VerifyContentType(
972 const std::wstring& that
973);
974
983std::unique_ptr<IVerification> VerifyPathType(
984 const std::wstring& that
985);
986
995std::unique_ptr<IVerification> VerifyQualifierType(
996 const std::wstring& that
997);
998
1007std::unique_ptr<IVerification> VerifyValueDataType(
1008 const std::wstring& that
1009);
1010
1019std::unique_ptr<IVerification> VerifyIdShortType(
1020 const std::wstring& that
1021);
1022
1023// endregion Verification of constrained primitives
1024
1025} // namespace verification
1026
1027
1028} // namespace aas_3_0
1029} // namespace aas_core
1030
1031// This code has been automatically generated by aas-core-codegen.
1032// Do NOT edit or append.
1033
1034#endif // AAS_CORE_AAS_3_0_VERIFICATION_GUARD_
Definition verification.hpp:137
virtual const Iterator & end() const =0
Iterate over the verification errors.
Definition verification.hpp:76
Iterator(std::unique_ptr< impl::IVerificator > verificator)
Definition verification.hpp:85
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:115
DataTypeDefXsd
Enumeration listing all XSD anySimpleTypes.
Definition types.hpp:230
KeyTypes
Enumeration of different key value types within a key.
Definition types.hpp:179
Definition verification.hpp:29
Definition verification.hpp:23
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:672
std::unique_ptr< IVerification > VerifyQualifierType(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesRfc8089Path(const std::wstring &text)
Check that text is a path conforming to the pattern of RFC 8089.
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 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:290
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:47
Definition common.hpp:46
Represent a path to some value.
Definition iteration.hpp:181
Definition verification.hpp:37
iteration::Path path
Definition verification.hpp:46
Error(std::wstring a_cause, iteration::Path a_path)
std::wstring cause
Definition verification.hpp:41