COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
OptionsParser.h
1//
2// Copyright 2015 - 2024 (C). Alex Robenko. All rights reserved.
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8#pragma once
9
10#include <limits>
11#include <ratio>
12#include <tuple>
13
14#include "comms/options.h"
17#include "comms/field/tag.h"
18#include "comms/field/details/adapters.h"
19#include "comms/field/details/MembersVersionDependency.h"
20
21namespace comms
22{
23
24namespace field
25{
26
27namespace details
28{
29
30template <typename... TOptions>
31class OptionsParser;
32
33template <>
34class OptionsParser<>
35{
36public:
37 static constexpr bool HasInvalidByDefault = false;
38 static constexpr bool HasVersionStorage = false;
39 static constexpr bool HasSerOffset = false;
40 static constexpr bool HasVersionsRange = false;
41 static constexpr bool HasFixedLengthLimit = false;
42 static constexpr bool HasFixedBitLengthLimit = false;
43 static constexpr bool HasVarLengthLimits = false;
44 static constexpr bool HasAvailableLengthLimit = false;
45 static constexpr bool HasSequenceElemLengthForcing = false;
46 static constexpr bool HasSequenceElemSerLengthFieldPrefix = false;
47 static constexpr bool HasSequenceElemFixedSerLengthFieldPrefix = false;
48 static constexpr bool HasSequenceSizeForcing = false;
49 static constexpr bool HasSequenceLengthForcing = false;
50 static constexpr bool HasSequenceFixedSize = false;
51 static constexpr bool HasSequenceSizeFieldPrefix = false;
52 static constexpr bool HasSequenceSerLengthFieldPrefix = false;
53 static constexpr bool HasSequenceTrailingFieldSuffix = false;
54 static constexpr bool HasSequenceTerminationFieldSuffix = false;
55 static constexpr bool HasRemLengthMemberField = false;
56 static constexpr bool HasDefaultValueInitialiser = false;
57 static constexpr bool HasMultiRangeValidation = false;
58 static constexpr bool HasCustomValidator = false;
59 static constexpr bool HasFailOnInvalid = false;
60 static constexpr bool HasIgnoreInvalid = false;
61 static constexpr bool HasEmptySerialization = false;
62 static constexpr bool HasCustomRead = false;
63 static constexpr bool HasCustomRefresh = false;
64 static constexpr bool HasCustomWrite = false;
65 static constexpr bool HasSequenceFixedSizeUseFixedSizeStorage = false;
66 static constexpr bool HasFixedSizeStorage = false;
67 static constexpr bool HasCustomStorageType = false;
68 static constexpr bool HasScalingRatio = false;
69 static constexpr bool HasUnits = false;
70 static constexpr bool HasOrigDataView = false;
71 static constexpr bool HasCustomVersionUpdate = false;
72 static constexpr bool HasFieldType = false;
73 static constexpr bool HasMissingOnReadFail = false;
74 static constexpr bool HasMissingOnInvalid = false;
75 static constexpr bool HasVariantCustomResetOnDestruct = false;
76 static constexpr bool HasVersionDependentMembersForced = false;
77
78 using UnitsType = void;
79 using ScalingRatio = std::ratio<1, 1>;
80 using UnitsRatio = std::ratio<1, 1>;
81 using FieldType = void;
82 using SequenceSizeFieldPrefix = void;
85 using SequenceTrailingFieldSuffix = void;
88
89 static constexpr std::size_t SequenceFixedSize = std::numeric_limits<std::size_t>::max();
90 static constexpr MembersVersionDependency ForcedMembersVersionDependency = MembersVersionDependency_NotSpecified;
91
92 template <typename TField>
93 using AdaptInvalidByDefault = TField;
94
95 template <typename TField>
96 using AdaptVersionStorage = TField;
97
98 template <typename TField>
99 using AdaptSerOffset = TField;
100
101 template <typename TField>
102 using AdaptVersionsRange = TField;
103
104 template <typename TField>
105 using AdaptFixedLengthLimit = TField;
106
107 template <typename TField>
108 using AdaptFixedBitLengthLimit = TField;
109
110 template <typename TField>
111 using AdaptVarLengthLimits = TField;
112
113 template <typename TField>
114 using AdaptAvailableLengthLimit = TField;
115
116 template <typename TField>
117 using AdaptSequenceElemLengthForcing = TField;
118
119 template <typename TField>
120 using AdaptSequenceElemSerLengthFieldPrefix = TField;
121
122 template <typename TField>
123 using AdaptSequenceElemFixedSerLengthFieldPrefix = TField;
124
125 template <typename TField>
126 using AdaptSequenceSizeForcing = TField;
127
128 template <typename TField>
129 using AdaptSequenceLengthForcing = TField;
130
131 template <typename TField>
132 using AdaptSequenceFixedSize = TField;
133
134 template <typename TField>
135 using AdaptSequenceSizeFieldPrefix = TField;
136
137 template <typename TField>
138 using AdaptSequenceSerLengthFieldPrefix = TField;
139
140 template <typename TField>
141 using AdaptSequenceTrailingFieldSuffix = TField;
142
143 template <typename TField>
144 using AdaptSequenceTerminationFieldSuffix = TField;
145
146 template <typename TField>
147 using AdaptRemLengthMemberField = TField;
148
149 template <typename TField>
150 using AdaptDefaultValueInitialiser = TField;
151
152 template <typename TField>
153 using AdaptMultiRangeValidation = TField;
154
155 template <typename TField>
156 using AdaptCustomValidator = TField;
157
158 template <typename TField>
159 using AdaptFailOnInvalid = TField;
160
161 template <typename TField>
162 using AdaptIgnoreInvalid = TField;
163
164 template <typename TField>
165 using AdaptEmptySerialization = TField;
166
167 template <typename TField>
168 using AdaptCustomRead = TField;
169
170 template <typename TField>
171 using AdaptCustomRefresh = TField;
172
173 template <typename TField>
174 using AdaptCustomWrite = TField;
175
176 template <typename TField>
177 using AdaptFieldType = TField;
178
179 template <typename TField>
180 using AdaptMissingOnReadFail = TField;
181
182 template <typename TField>
183 using AdaptMissingOnInvalid = TField;
184
185 template <typename TField>
186 using AdaptVariantResetOnDestruct =
188 std::is_same<typename TField::CommsTag, comms::field::tag::Variant>::value
189 >::template Type<
190 comms::field::adapter::VariantResetOnDestruct<TField>,
191 TField
192 >;
193};
194
195template <typename... TOptions>
196class OptionsParser<
197 comms::option::def::HasCustomRead,
198 TOptions...> : public OptionsParser<TOptions...>
199{
200public:
201 static constexpr bool HasCustomRead = true;
202
203 template <typename TField>
204 using AdaptCustomRead = comms::field::adapter::CustomReadWrap<TField>;
205};
206
207template <std::intmax_t TOffset, typename... TOptions>
208class OptionsParser<
209 comms::option::def::NumValueSerOffset<TOffset>,
210 TOptions...> : public OptionsParser<TOptions...>
211{
212public:
213 static constexpr bool HasSerOffset = true;
214 static const std::intmax_t SerOffset = TOffset;
215
216 template <typename TField>
217 using AdaptSerOffset = comms::field::adapter::SerOffset<SerOffset, TField>;
218};
219
220template <std::size_t TLen, bool TSignExtend, typename... TOptions>
221class OptionsParser<
222 comms::option::def::FixedLength<TLen, TSignExtend>,
223 TOptions...> : public OptionsParser<TOptions...>
224{
225public:
226 static constexpr bool HasFixedLengthLimit = true;
227 static constexpr std::size_t FixedLength = TLen;
228 static constexpr bool FixedLengthSignExtend = TSignExtend;
229
230 template <typename TField>
231 using AdaptFixedLengthLimit =
232 comms::field::adapter::FixedLength<
234 FixedLengthSignExtend,
235 TField
236 >;
237};
238
239template <std::size_t TLen, bool TSignExtend, typename... TOptions>
240class OptionsParser<
241 comms::option::def::FixedBitLength<TLen, TSignExtend>,
242 TOptions...> : public OptionsParser<TOptions...>
243{
244public:
245 static constexpr bool HasFixedBitLengthLimit = true;
246 static constexpr std::size_t FixedBitLength = TLen;
247 static constexpr bool FixedBitLengthSignExtend = TSignExtend;
248
249 template <typename TField>
250 using AdaptFixedBitLengthLimit =
251 comms::field::adapter::FixedBitLength<
253 FixedBitLengthSignExtend,
254 TField>;
255};
256
257template <std::size_t TMinLen, std::size_t TMaxLen, typename... TOptions>
258class OptionsParser<
259 comms::option::def::VarLength<TMinLen, TMaxLen>,
260 TOptions...> : public OptionsParser<TOptions...>
261{
262public:
263 static constexpr bool HasVarLengthLimits = true;
264 static constexpr std::size_t MinVarLength = TMinLen;
265 static constexpr std::size_t MaxVarLength = TMaxLen;
266
267 template <typename TField>
268 using AdaptVarLengthLimits =
269 comms::field::adapter::VarLength<MinVarLength, MaxVarLength, TField>;
270};
271
272template <typename... TOptions>
273class OptionsParser<
274 comms::option::def::AvailableLengthLimit,
275 TOptions...> : public OptionsParser<TOptions...>
276{
277public:
278 static constexpr bool HasAvailableLengthLimit = true;
279
280 template <typename TField>
281 using AdaptAvailableLengthLimit =
282 comms::field::adapter::AvailableLength<TField>;
283};
284
285template <typename... TOptions>
286class OptionsParser<
287 comms::option::def::SequenceSizeForcingEnabled,
288 TOptions...> : public OptionsParser<TOptions...>
289{
290public:
291 static constexpr bool HasSequenceSizeForcing = true;
292
293 template <typename TField>
294 using AdaptSequenceSizeForcing = comms::field::adapter::SequenceSizeForcing<TField>;
295};
296
297template <typename... TOptions>
298class OptionsParser<
299 comms::option::def::SequenceLengthForcingEnabled,
300 TOptions...> : public OptionsParser<TOptions...>
301{
302public:
303 static constexpr bool HasSequenceLengthForcing = true;
304
305 template <typename TField>
306 using AdaptSequenceLengthForcing = comms::field::adapter::SequenceLengthForcing<TField>;
307};
308
309template <typename... TOptions>
310class OptionsParser<
311 comms::option::def::SequenceElemLengthForcingEnabled,
312 TOptions...> : public OptionsParser<TOptions...>
313{
314public:
315 static constexpr bool HasSequenceElemLengthForcing = true;
316
317 template <typename TField>
318 using AdaptSequenceElemLengthForcing = comms::field::adapter::SequenceElemLengthForcing<TField>;
319};
320
321template <std::size_t TSize, typename... TOptions>
322class OptionsParser<
323 comms::option::def::SequenceFixedSize<TSize>,
324 TOptions...> : public OptionsParser<TOptions...>
325{
326public:
327 static constexpr bool HasSequenceFixedSize = true;
328 static constexpr std::size_t SequenceFixedSize = TSize;
329
330 template <typename TField>
331 using AdaptSequenceFixedSize = comms::field::adapter::SequenceFixedSize<SequenceFixedSize, TField>;
332};
333
334template <typename... TOptions>
335class OptionsParser<
336 comms::option::app::SequenceFixedSizeUseFixedSizeStorage,
337 TOptions...> : public OptionsParser<TOptions...>
338{
339public:
340 static constexpr bool HasSequenceFixedSizeUseFixedSizeStorage = true;
341};
342
343template <typename TSizeField, typename... TOptions>
344class OptionsParser<
345 comms::option::def::SequenceSizeFieldPrefix<TSizeField>,
346 TOptions...> : public OptionsParser<TOptions...>
347{
348public:
349 static constexpr bool HasSequenceSizeFieldPrefix = true;
350 using SequenceSizeFieldPrefix = TSizeField;
351
352 template <typename TField>
353 using AdaptSequenceSizeFieldPrefix = comms::field::adapter::SequenceSizeFieldPrefix<SequenceSizeFieldPrefix, TField>;
354};
355
356template <typename TField, comms::ErrorStatus TReadErrorStatus, typename... TOptions>
357class OptionsParser<
358 comms::option::def::SequenceSerLengthFieldPrefix<TField, TReadErrorStatus>,
359 TOptions...> : public OptionsParser<TOptions...>
360{
361public:
362 static constexpr bool HasSequenceSerLengthFieldPrefix = true;
363 using SequenceSerLengthFieldPrefix = TField;
364 static constexpr comms::ErrorStatus SequenceSerLengthFieldReadErrorStatus = TReadErrorStatus;
365
366 template <typename TWrappedField>
367 using AdaptSequenceSerLengthFieldPrefix =
368 comms::field::adapter::SequenceSerLengthFieldPrefix<
370 SequenceSerLengthFieldReadErrorStatus,
371 TWrappedField
372 >;
373};
374
375template <typename TField, comms::ErrorStatus TReadErrorStatus, typename... TOptions>
376class OptionsParser<
377 comms::option::def::SequenceElemSerLengthFieldPrefix<TField, TReadErrorStatus>,
378 TOptions...> : public OptionsParser<TOptions...>
379{
380public:
381 static constexpr bool HasSequenceElemSerLengthFieldPrefix = true;
383 static constexpr comms::ErrorStatus SequenceElemSerLengthFieldReadErrorStatus = TReadErrorStatus;
384
385 template <typename TWrappedField>
386 using AdaptSequenceElemSerLengthFieldPrefix =
387 comms::field::adapter::SequenceElemSerLengthFieldPrefix<
389 SequenceElemSerLengthFieldReadErrorStatus,
390 TWrappedField
391 >;
392};
393
394template <typename TField, comms::ErrorStatus TReadErrorStatus, typename... TOptions>
395class OptionsParser<
396 comms::option::def::SequenceElemFixedSerLengthFieldPrefix<TField, TReadErrorStatus>,
397 TOptions...> : public OptionsParser<TOptions...>
398{
399public:
400 static constexpr bool HasSequenceElemFixedSerLengthFieldPrefix = true;
402 static constexpr comms::ErrorStatus SequenceElemFixedSerLengthFieldReadErrorStatus = TReadErrorStatus;
403
404 template <typename TWrappedField>
405 using AdaptSequenceElemFixedSerLengthFieldPrefix =
406 comms::field::adapter::SequenceElemFixedSerLengthFieldPrefix<
408 SequenceElemFixedSerLengthFieldReadErrorStatus,
409 TWrappedField
410 >;
411};
412
413template <typename TTrailField, typename... TOptions>
414class OptionsParser<
415 comms::option::def::SequenceTrailingFieldSuffix<TTrailField>,
416 TOptions...> : public OptionsParser<TOptions...>
417{
418public:
419 static constexpr bool HasSequenceTrailingFieldSuffix = true;
420 using SequenceTrailingFieldSuffix = TTrailField;
421
422 template <typename TField>
423 using AdaptSequenceTrailingFieldSuffix = comms::field::adapter::SequenceTrailingFieldSuffix<SequenceTrailingFieldSuffix, TField>;
424};
425
426template <typename TTermField, typename... TOptions>
427class OptionsParser<
428 comms::option::def::SequenceTerminationFieldSuffix<TTermField>,
429 TOptions...> : public OptionsParser<TOptions...>
430{
431public:
432 static constexpr bool HasSequenceTerminationFieldSuffix = true;
433 using SequenceTerminationFieldSuffix = TTermField;
434
435 template <typename TField>
436 using AdaptSequenceTerminationFieldSuffix =
437 comms::field::adapter::SequenceTerminationFieldSuffix<SequenceTerminationFieldSuffix, TField>;
438};
439
440template <typename TInitialiser, typename... TOptions>
441class OptionsParser<
442 comms::option::def::DefaultValueInitialiser<TInitialiser>,
443 TOptions...> : public OptionsParser<TOptions...>
444{
445public:
446 static constexpr bool HasDefaultValueInitialiser = true;
447 using DefaultValueInitialiser = TInitialiser;
448
449 template <typename TField>
450 using AdaptDefaultValueInitialiser =
451 comms::field::adapter::DefaultValueInitialiser<DefaultValueInitialiser, TField>;
452};
453
454template <typename TValidator, typename... TOptions>
455class OptionsParser<
456 comms::option::def::ContentsValidator<TValidator>,
457 TOptions...> : public OptionsParser<TOptions...>
458{
459public:
460 static constexpr bool HasCustomValidator = true;
461 using CustomValidator = TValidator;
462
463 template <typename TField>
464 using AdaptCustomValidator = comms::field::adapter::CustomValidator<CustomValidator, TField>;
465};
466
467template <typename... TOptions>
468class OptionsParser<
469 comms::option::def::HasCustomRefresh,
470 TOptions...> : public OptionsParser<TOptions...>
471{
472public:
473 static constexpr bool HasCustomRefresh = true;
474
475 template <typename TField>
476 using AdaptCustomRefresh = comms::field::adapter::CustomRefreshWrap<TField>;
477};
478
479template <comms::ErrorStatus TStatus, typename... TOptions>
480class OptionsParser<
481 comms::option::def::FailOnInvalid<TStatus>,
482 TOptions...> : public OptionsParser<TOptions...>
483{
484public:
485 static constexpr bool HasFailOnInvalid = true;
486 static constexpr comms::ErrorStatus FailOnInvalidStatus = TStatus;
487
488 template <typename TField>
489 using AdaptFailOnInvalid = comms::field::adapter::FailOnInvalid<FailOnInvalidStatus, TField>;
490};
491
492template <typename... TOptions>
493class OptionsParser<
494 comms::option::def::IgnoreInvalid,
495 TOptions...> : public OptionsParser<TOptions...>
496{
497public:
498 static constexpr bool HasIgnoreInvalid = true;
499
500 template <typename TField>
501 using AdaptIgnoreInvalid = comms::field::adapter::IgnoreInvalid<TField>;
502};
503
504template <typename... TOptions>
505class OptionsParser<
506 comms::option::def::InvalidByDefault,
507 TOptions...> : public OptionsParser<TOptions...>
508{
509public:
510 static constexpr bool HasInvalidByDefault = true;
511
512 template <typename TField>
513 using AdaptInvalidByDefault = comms::field::adapter::InvalidByDefault<TField>;
514};
515
516template <std::size_t TSize, typename... TOptions>
517class OptionsParser<
518 comms::option::app::FixedSizeStorage<TSize>,
519 TOptions...> : public OptionsParser<TOptions...>
520{
521public:
522 static constexpr bool HasFixedSizeStorage = true;
523 static constexpr std::size_t FixedSizeStorage = TSize;
524};
525
526template <typename TType, typename... TOptions>
527class OptionsParser<
528 comms::option::app::CustomStorageType<TType>,
529 TOptions...> : public OptionsParser<TOptions...>
530{
531public:
532 static constexpr bool HasCustomStorageType = true;
533 using CustomStorageType = TType;
534};
535
536template <std::intmax_t TNum, std::intmax_t TDenom, typename... TOptions>
537class OptionsParser<
538 comms::option::def::ScalingRatio<TNum, TDenom>,
539 TOptions...> : public OptionsParser<TOptions...>
540{
541public:
542 static constexpr bool HasScalingRatio = true;
543 using ScalingRatio = std::ratio<TNum, TDenom>;
544};
545
546template <typename TType, typename TRatio, typename... TOptions>
547class OptionsParser<
548 comms::option::def::Units<TType, TRatio>,
549 TOptions...> : public OptionsParser<TOptions...>
550{
551public:
552 static constexpr bool HasUnits = true;
553 using UnitsType = TType;
554 using UnitsRatio = TRatio;
555};
556
557template <typename... TOptions>
558class OptionsParser<
559 comms::option::app::OrigDataView,
560 TOptions...> : public OptionsParser<TOptions...>
561{
562public:
563 static constexpr bool HasOrigDataView = true;
564};
565
566template <typename... TOptions>
567class OptionsParser<
568 comms::option::def::EmptySerialization,
569 TOptions...> : public OptionsParser<TOptions...>
570{
571public:
572 static constexpr bool HasEmptySerialization = true;
573
574 template <typename TField>
575 using AdaptEmptySerialization = comms::field::adapter::EmptySerialization<TField>;
576};
577
578template <bool THasMultiRangeValidation>
579struct MultiRangeAssembler
580{
581 template <typename TBase, typename T, T TMinValue, T TMaxValue>
582 using Type =
583 std::tuple<
584 std::tuple<
585 std::integral_constant<T, TMinValue>,
586 std::integral_constant<T, TMaxValue>
587 >
588 >;
589};
590
591template <>
592struct MultiRangeAssembler<true>
593{
594 using FalseAssembler = MultiRangeAssembler<false>;
595
596 template <typename TBase, typename T, T TMinValue, T TMaxValue>
597 using Type =
598 typename std::decay<
599 decltype(
600 std::tuple_cat(
601 std::declval<typename TBase::MultiRangeValidationRanges>(),
602 std::declval<typename FalseAssembler::template Type<TBase, T, TMinValue, TMaxValue> >()
603 )
604 )
605 >::type;
606};
607
608
609template <typename TBase, typename T, T TMinValue, T TMaxValue>
610using MultiRangeAssemblerT =
611 typename MultiRangeAssembler<TBase::HasMultiRangeValidation>::template Type<TBase, T, TMinValue, TMaxValue>;
612
613template <std::intmax_t TMinValue, std::intmax_t TMaxValue, typename... TOptions>
614class OptionsParser<
615 comms::option::def::ValidNumValueRange<TMinValue, TMaxValue>,
616 TOptions...> : public OptionsParser<TOptions...>
617{
618 using BaseImpl = OptionsParser<TOptions...>;
619public:
620#ifdef COMMS_COMPILER_GCC47
621 static_assert(!BaseImpl::HasMultiRangeValidation,
622 "Sorry gcc-4.7 fails to compile valid C++11 code that allows multiple usage"
623 "of comms::option::def::ValidNumValueRange options. Either use it only once or"
624 "upgrade your compiler.");
625#endif
626 using MultiRangeValidationRanges = MultiRangeAssemblerT<BaseImpl, std::intmax_t, TMinValue, TMaxValue>;
627 static constexpr bool HasMultiRangeValidation = true;
628
629 template <typename TField>
630 using AdaptMultiRangeValidation =
631 comms::field::adapter::NumValueMultiRangeValidator<MultiRangeValidationRanges, TField>;
632};
633
634template <typename... TOptions>
635class OptionsParser<
636 comms::option::def::ValidRangesClear,
637 TOptions...> : public OptionsParser<TOptions...>
638{
639 using BaseImpl = OptionsParser<TOptions...>;
640public:
641 using MultiRangeValidationRanges = void;
642 static constexpr bool HasMultiRangeValidation = false;
643
644 template <typename TField>
645 using AdaptMultiRangeValidation = TField;
646};
647
648
649template <std::uintmax_t TMinValue, std::uintmax_t TMaxValue, typename... TOptions>
650class OptionsParser<
651 comms::option::def::ValidBigUnsignedNumValueRange<TMinValue, TMaxValue>,
652 TOptions...> : public OptionsParser<TOptions...>
653{
654 using BaseImpl = OptionsParser<TOptions...>;
655public:
656#ifdef COMMS_COMPILER_GCC47
657 static_assert(!BaseImpl::HasMultiRangeValidation,
658 "Sorry gcc-4.7 fails to compile valid C++11 code that allows multiple usage"
659 "of comms::option::def::ValidNumValueRange options. Either use it only once or"
660 "upgrade your compiler.");
661#endif
662 using MultiRangeValidationRanges = MultiRangeAssemblerT<BaseImpl, std::uintmax_t, TMinValue, TMaxValue>;
663 static constexpr bool HasMultiRangeValidation = true;
664
665 template <typename TField>
666 using AdaptMultiRangeValidation =
667 comms::field::adapter::NumValueMultiRangeValidator<MultiRangeValidationRanges, TField>;
668};
669
670template <typename... TOptions>
671class OptionsParser<
672 comms::option::def::HasCustomVersionUpdate,
673 TOptions...> : public OptionsParser<TOptions...>
674{
675public:
676 static constexpr bool HasCustomVersionUpdate = true;
677};
678
679template <std::uintmax_t TFrom, std::uintmax_t TUntil, typename... TOptions>
680class OptionsParser<
681 comms::option::def::ExistsBetweenVersions<TFrom, TUntil>,
682 TOptions...> : public OptionsParser<TOptions...>
683{
684public:
685 static constexpr bool HasVersionsRange = true;
686 static constexpr std::uintmax_t ExistsFromVersion = TFrom;
687 static constexpr std::uintmax_t ExistsUntilVersion = TUntil;
688
689 template <typename TField>
690 using AdaptVersionsRange =
691 comms::field::adapter::ExistsBetweenVersions<ExistsFromVersion, ExistsUntilVersion, TField>;
692};
693
694template <typename... TOptions>
695class OptionsParser<
696 comms::option::def::VersionStorage,
697 TOptions...> : public OptionsParser<TOptions...>
698{
699public:
700 static constexpr bool HasVersionStorage = true;
701
702 template <typename TField>
703 using AdaptVersionStorage = comms::field::adapter::VersionStorage<TField>;
704};
705
706template <std::size_t TIdx, typename... TOptions>
707class OptionsParser<
708 comms::option::def::RemLengthMemberField<TIdx>,
709 TOptions...> : public OptionsParser<TOptions...>
710{
711 using BaseImpl = OptionsParser<TOptions...>;
712 static_assert(!BaseImpl::HasRemLengthMemberField,
713 "Option comms::def::option::RemLengthMemberField used multiple times");
714public:
715 static constexpr bool HasRemLengthMemberField = true;
716 static constexpr std::size_t RemLengthMemberFieldIdx = TIdx;
717
718 template <typename TField>
719 using AdaptRemLengthMemberField =
720 comms::field::adapter::RemLengthMemberField<RemLengthMemberFieldIdx, TField>;
721};
722
723template <typename... TOptions>
724class OptionsParser<
725 comms::option::def::HasCustomWrite,
726 TOptions...> : public OptionsParser<TOptions...>
727{
728public:
729 static constexpr bool HasCustomWrite = true;
730
731 template <typename TField>
732 using AdaptCustomWrite = comms::field::adapter::CustomWriteWrap<TField>;
733};
734
735template <typename TActField, typename... TOptions>
736class OptionsParser<
737 comms::option::def::FieldType<TActField>,
738 TOptions...> : public OptionsParser<TOptions...>
739{
740public:
741 static constexpr bool HasFieldType = true;
742 using FieldType = TActField;
743
744 template <typename TField>
745 using AdaptFieldType = comms::field::adapter::FieldType<TActField, TField>;
746};
747
748template <typename... TOptions>
749class OptionsParser<
750 comms::option::def::MissingOnReadFail,
751 TOptions...> : public OptionsParser<TOptions...>
752{
753public:
754 static constexpr bool HasMissingOnReadFail = true;
755
756 template <typename TField>
757 using AdaptMissingOnReadFail = comms::field::adapter::MissingOnReadFail<TField>;
758};
759
760template <typename... TOptions>
761class OptionsParser<
762 comms::option::def::MissingOnInvalid,
763 TOptions...> : public OptionsParser<TOptions...>
764{
765public:
766 static constexpr bool HasMissingOnInvalid = true;
767
768 template <typename TField>
769 using AdaptMissingOnInvalid = comms::field::adapter::MissingOnInvalid<TField>;
770};
771
772template <typename... TOptions>
773class OptionsParser<
774 comms::option::def::VariantHasCustomResetOnDestruct,
775 TOptions...> : public OptionsParser<TOptions...>
776{
777public:
778 static constexpr bool HasVariantCustomResetOnDestruct = true;
779
780 template <typename TField>
781 using AdaptVariantResetOnDestruct = TField;
782};
783
784template <bool TVersionDependent, typename... TOptions>
785class OptionsParser<
786 comms::option::def::HasVersionDependentMembers<TVersionDependent>,
787 TOptions...> : public OptionsParser<TOptions...>
788{
789public:
790 static constexpr bool HasVersionDependentMembersForced = true;
791 static constexpr MembersVersionDependency ForcedMembersVersionDependency =
792 TVersionDependent ? MembersVersionDependency_Dependent : MembersVersionDependency_Independent;
793};
794
795
796template <typename... TOptions>
797class OptionsParser<
798 comms::option::app::EmptyOption,
799 TOptions...> : public OptionsParser<TOptions...>
800{
801};
802
803template <typename... TTupleOptions, typename... TOptions>
804class OptionsParser<
805 std::tuple<TTupleOptions...>,
806 TOptions...> : public OptionsParser<TTupleOptions..., TOptions...>
807{
808};
809
810} // namespace details
811
812} // namespace field
813
814} // namespace comms
815
816
Contains various compiler related definitions.
Contains definition of various tag classes.
ExistsBetweenVersions< 0, TVer > ExistsUntilVersion
Mark an comms::field::Optional field as existing only until specified version.
Definition options.h:1195
comms::option::def::SequenceTrailingFieldSuffix< TField > SequenceTrailingFieldSuffix
Same as comms::option::def::SequenceTrailingFieldSuffix.
Definition options.h:1531
comms::option::def::SequenceElemFixedSerLengthFieldPrefix< TField, TReadErrorStatus > SequenceElemFixedSerLengthFieldPrefix
Same as comms::option::def::SequenceElemFixedSerLengthFieldPrefix.
Definition options.h:1523
comms::option::def::SequenceTerminationFieldSuffix< TField > SequenceTerminationFieldSuffix
Same as comms::option::def::SequenceTerminationFieldSuffix.
Definition options.h:1527
comms::option::def::SequenceSerLengthFieldPrefix< TField, TReadErrorStatus > SequenceSerLengthFieldPrefix
Same as comms::option::def::SequenceSerLengthFieldPrefix.
Definition options.h:1513
comms::option::def::DefaultValueInitialiser< T > DefaultValueInitialiser
Same as comms::option::def::DefaultValueInitialiser.
Definition options.h:1548
comms::option::def::FixedLength< TLen, TSignExtend > FixedLength
Same as comms::option::def::FixedLength.
Definition options.h:1488
comms::option::def::SequenceFixedSize< TSize > SequenceFixedSize
Same as comms::option::def::SequenceFixedSize.
Definition options.h:1544
comms::option::def::HasCustomVersionUpdate HasCustomVersionUpdate
Same as comms::option::def::HasCustomVersionUpdate.
Definition options.h:1800
comms::option::def::HasCustomRead HasCustomRead
Same as comms::option::def::HasCustomRead.
Definition options.h:1780
comms::option::def::FieldType< TMsg > FieldType
Same as comms::option::def::FieldType.
Definition options.h:1463
comms::option::def::SequenceElemSerLengthFieldPrefix< TField, TReadErrorStatus > SequenceElemSerLengthFieldPrefix
Same as comms::option::def::SequenceElemSerLengthFieldPrefix.
Definition options.h:1518
comms::option::app::FixedSizeStorage< TSize > FixedSizeStorage
Same as comms::option::app::FixedSizeStorage.
Definition options.h:1887
comms::option::app::CustomStorageType< TType > CustomStorageType
Same as comms::option::app::CustomStorageType.
Definition options.h:1891
comms::option::def::HasCustomRefresh HasCustomRefresh
Same as comms::option::def::HasCustomRefresh.
Definition options.h:1783
comms::option::def::FixedBitLength< TLen, TSignExtend > FixedBitLength
Same as comms::option::def::FixedBitLength.
Definition options.h:1492
comms::option::def::SequenceSizeFieldPrefix< TField > SequenceSizeFieldPrefix
Same as comms::option::def::SequenceSizeFieldPrefix.
Definition options.h:1508
comms::option::def::ScalingRatio< TNum, TDenom > ScalingRatio
Same as comms::option::def::ScalingRatio.
Definition options.h:1504
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:17
STL namespace.
Contains definition of all the options used by the COMMS library.
Replacement to std::conditional.
Definition type_traits.h:28
Replacement to some types from standard type_traits.