RTI Connext Traditional C++ API Version 7.3.0
Offset.hpp
1/*
2(c) Copyright, Real-Time Innovations, 2018.
3All rights reserved.
4
5No duplications, whole or partial, manual or electronic, may be made
6without express written permission. Any such copies, or
7revisions thereof, must display this notice unaltered.
8This code contains trade secrets of Real-Time Innovations, Inc.
9*/
10
11#ifndef RTI_DDS_FLAT_FLATOFFSETS_HPP_
12#define RTI_DDS_FLAT_FLATOFFSETS_HPP_
13
14#include "xcdr/xcdr_stream.h"
15#include "xcdr/xcdr_stream_impl.h"
16#include "xcdr/xcdr_interpreter.h"
17
18#include "rti/xcdr/Stream.hpp"
19
108#ifdef DOXYGEN_DOCUMENTATION_ONLY
109
125class MyFlatFinalOffset : public rti::flat::FinalOffset<MyFlatFinalOffset> {
126 public:
135 typedef MyFlatFinalConstOffset ConstOffset;
136
143 {
144 }
145
149 int32_t my_primitive() const;
150
156 FlatFinalBar::ConstOffset my_complex() const;
157
162
167
171 bool my_primitive(int32_t value);
172
178 FlatFinalBar::Offset my_complex();
179
184
189};
190
203class NDDSUSERDllExport MyFlatMutableOffset : public rti::flat::MutableOffset {
204 public:
213 typedef MyFlatMutableConstOffset ConstOffset;
214
221 {
222 }
223
230 int32_t my_primitive() const;
231
241
246
251
256
261
266
272 FlatMutableBar::ConstOffset my_mutable() const;
273
278
283
288
293
297 bool my_primitive(int32_t value);
298
299 /* @brief Retrieves a non-const Offset to an optional primitive
300 *
301 * Unlike the non-optional my_primitive(), which allows accessing the integer
302 * directly, an optional primitive may not exist. If it doesn't, the Offset
303 * this function returns will be null (\p is_null()).
304 */
305 rti::flat::PrimitiveOffset<int32_t> my_optional_primitive();
306
311
316
321
326
331
337 FlatMutableBar::Offset my_mutable();
338
343
348
353
358};
359
375class NDDSUSERDllExport MyFlatUnionOffset
377 public:
381 typedef MyFlatUnionConstOffset ConstOffset;
382
389 {
390 }
391
411 int32_t _d() const;
412
419 int32_t my_primitive() const;
420
428
436
445 bool my_primitive(int32_t value);
446
454
462};
463
464#endif
465
466namespace rti { namespace flat {
467
468namespace detail {
469
470inline rti::flat::offset_t ptrdiff(unsigned char *a, unsigned char *b)
471{
472 RTI_FLAT_ASSERT(a - b < RTI_XCDR_MAX_SERIALIZED_SIZE, return 0);
473
474 return static_cast<rti::flat::offset_t>(a - b);
475}
476
477// Used to determine which fixed-size types need a DHeader when adding a
478// fixed-size member or element. OffsetType classes may specialize this template
479// to indicate if they need a DHeader.
480template <typename OffsetType, typename Enable = void>
481struct is_fixed_type_w_dheader {
482 static bool value()
483 {
484 return false;
485 }
486};
487
488inline bool is_dheader_required_in_non_primitive_collections()
489{
490 // Allow setting the behavior at compilation time to gain compiler
491 // optimizations
492#if defined(RTI_FLATDATA_NO_DHEADER_COLLECTIONS)
493 return false;
494#elif defined(RTI_FLATDATA_DHEADER_COLLECTIONS)
495 return true;
496#else
497 // Without any compilation flag, the behavior is configurable at runtime
498 RTIXCdrXTypesComplianceMask xTypesComplianceMask;
499 xTypesComplianceMask = RTIXCdrInterpreter_getGlobalXtypeComplianceMask();
500 return RTIXCdrXTypesComplianceMask_isBitSet(
501 xTypesComplianceMask,
502 RTI_XCDR_XTYPES_DHEADER_IN_NON_PRIMITIVE_COLLECTIONS_BIT);
503#endif
504}
505
506inline bool is_dheader_required_in_enum_collections()
507{
508#if defined(RTI_FLATDATA_NO_DHEADER_COLLECTIONS)
509 return false;
510#elif defined(RTI_FLATDATA_DHEADER_COLLECTIONS)
511 return true;
512#else
513 RTIXCdrXTypesComplianceMask xTypesComplianceMask;
514 xTypesComplianceMask = RTIXCdrInterpreter_getGlobalXtypeComplianceMask();
515 return RTIXCdrXTypesComplianceMask_isBitSet(
516 xTypesComplianceMask,
517 RTI_XCDR_XTYPES_DHEADER_IN_NON_PRIMITIVE_COLLECTIONS_BIT)
518 && !RTIXCdrXTypesComplianceMask_isBitSet(
519 xTypesComplianceMask,
520 RTI_XCDR_XTYPES_ENUM_AS_PRIMITIVE_IN_COLLECTIONS_BIT);
521#endif
522}
523
524template <bool IsForEnum>
525struct collection_dheader_traits {
526 static bool dheader_required()
527 {
528 return is_dheader_required_in_non_primitive_collections();
529 }
530
531 static unsigned int dheader_size()
532 {
533 return dheader_required() ? RTI_XCDR_DHEADER_SIZE : 0;
534 }
535};
536
537template <>
538struct collection_dheader_traits<true> {
539 static bool dheader_required()
540 {
541 return is_dheader_required_in_enum_collections();
542 }
543
544 static unsigned int dheader_size()
545 {
546 return dheader_required() ? RTI_XCDR_DHEADER_SIZE : 0;
547 }
548};
549
550} // namespace detail
551
552// Forward declaration
553template <typename T, unsigned int N>
554class FinalArrayOffset;
555
563public:
564
582 bool is_null() const
583 {
584 return sample_ == NULL;
585 }
586
595 bool is_cpp_compatible() const
596 {
597 // Derived classes may indicate whether
598 // a type is cpp-compatible
599 return false;
600 }
601
607 unsigned char * get_buffer()
608 {
609 if (is_null()) {
610 return NULL;
611 }
612 return stream_.current_position();
613 }
614
627 const unsigned char * get_buffer() const
628 {
629 if (is_null()) {
630 return NULL;
631 }
632 return stream_.current_position();
633 }
634
641 offset_t get_buffer_size() const
642 {
643 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return 0);
644 return stream_.total_size();
645 }
646
652 friend bool operator<(
653 const OffsetBase & s1,
654 const OffsetBase & s2) {
655 return s1.get_buffer() < s2.get_buffer();
656 }
657
663 friend bool operator > (
664 const OffsetBase & s1,
665 const OffsetBase & s2) {
666 return s1.get_buffer() > s2.get_buffer();
667 }
668
674 friend bool operator <= (
675 const OffsetBase & s1,
676 const OffsetBase & s2) {
677 return s1.get_buffer() <= s2.get_buffer();
678 }
679
685 friend bool operator >= (
686 const OffsetBase & s1,
687 const OffsetBase & s2) {
688 return s1.get_buffer() >= s2.get_buffer();
689 }
690
696 friend bool operator == (
697 const OffsetBase & s1,
698 const OffsetBase & s2) {
699 return s1.get_buffer() == s2.get_buffer();
700 }
701
707 friend bool operator != (
708 const OffsetBase & s1,
709 const OffsetBase & s2) {
710 return !(s1 == s2);
711 }
712
713protected:
714
715 OffsetBase() :
716 sample_(NULL),
717 absolute_offset_(0)
718 {
719 }
720
721 OffsetBase(
722 SampleBase *sample,
723 offset_t absolute_offset,
724 offset_t serialized_size)
725 : sample_(sample),
726 absolute_offset_(absolute_offset)
727 {
728 // In modern C++ this throws PreconditionNotMetError; in traditional
729 // C++, this ends the constructor leaving the object in a state such
730 // that is_null() is true.
731 RTI_FLAT_CHECK_PRECONDITION(sample != NULL, return);
732
733 sample_->initialize_stream(
734 stream_.c_stream(),
735 absolute_offset_,
736 serialized_size);
737 }
738
739 // Gets the value of a primitive member at the specified relative Offset
740 template <typename U>
741 U deserialize(offset_t member_offset) const
742 {
743 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return U());
744 RTI_FLAT_ASSERT(stream_.check_size(member_offset + static_cast<offset_t>(sizeof(U))), return U());
745
746 rti::xcdr::Stream::Memento stream_memento(stream_);
747 stream_.skip_fast(member_offset);
748 return stream_.deserialize_fast<U>();
749 }
750
751 // Sets the value of a primitive member at the specified relative Offset
752 template <typename U>
753 bool serialize(offset_t member_offset, U value)
754 {
755 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return false);
756 RTI_FLAT_ASSERT(stream_.check_size(member_offset + static_cast<offset_t>(sizeof(U))), return false);
757
758 rti::xcdr::Stream::Memento stream_memento(stream_);
759
760 stream_.skip_fast(member_offset);
761 stream_.serialize_fast<U>(value);
762 return true;
763 }
764
765 // Obtains a member at the specified relative offset
766 //
767 // U is the type of the member. U must be a subclass of Offset<U>.
768 template <typename U>
769 U get_member(offset_t relative_member_offset)
770 {
771 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return U());
772
773 return U(
774 sample_,
775 // the absolute location of the member:
776 absolute_offset_ + relative_member_offset);
777 }
778
779 template <typename U>
780 U get_member(offset_t relative_member_offset) const
781 {
782 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return U());
783
784 return U(
785 sample_,
786 // the absolute location of the member:
787 absolute_offset_ + relative_member_offset);
788 }
789
790protected:
791 SampleBase *sample_; // the actual CDR buffer is in the sample
792
793 offset_t absolute_offset_; // the position of this Offset in the buffer
794 mutable rti::xcdr::Stream stream_; // a substream that shares the same buffer
795};
796
804template <typename T>
805class FinalOffset : public OffsetBase {
806public:
807 typedef fixed_size_type_tag_t offset_kind;
808
809 static offset_t serialized_size_w_padding()
810 {
811 RTI_FLAT_ASSERT(T::serialized_size(0) > 0, return 0);
812 RTI_FLAT_ASSERT(T::required_alignment > 0, return 0);
813
814 const offset_t element_size = T::serialized_size(0);
815 if (element_size % T::required_alignment != 0) {
816 return element_size + T::required_alignment
817 - element_size % T::required_alignment;
818 } else {
819 return element_size;
820 }
821 }
822
823 bool is_cpp_compatible() const // override
824 {
825 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return false);
826 return !stream_.needs_byte_swap()
827 && rti::xcdr::has_cpp_friendly_cdr_layout<
829 }
830
831protected:
833 {
834 }
835
836 // Creates an Offset within the sample's CDR buffer at the specified
837 // absolute offset
838 //
839 // This overload requires T::serialized_size(offset_t)
840 //
841 FinalOffset(SampleBase *sample, offset_t absolute_offset)
842 : OffsetBase(
843 sample,
844 absolute_offset,
845 T::serialized_size(absolute_offset))
846 {
847 }
848
849 // Gets the value of a primitive member at the specified relative offset
850 // relative_member_offsets - the 4 possible offsets depending on the this
851 // type's initial alignment
852 template <typename U>
853 U deserialize(const offset_t *relative_member_offsets) const
854 {
855 RTI_FLAT_ASSERT(relative_member_offsets != NULL, return U());
856
857 // In a FinalOffset the stream is guaranteed to have enough space to
858 // contain all its members. There are two possible cases:
859 //
860 // - If the FinalOffset is a member of a mutable type, the member getter
861 // will ensure that the stream has enough space for the whole final
862 // type.
863 //
864 // - If the final offset is a top-level type, the type plugin ensures
865 // that the serialized buffer is large enough to contain the type.
866
867 return OffsetBase::deserialize<U>(
868 // pick the right offset based on the initial alignment
869 get_value_for_alignment(relative_member_offsets));
870 }
871
872 // Sets the value of a primitive member at the specified relative offset
873 template <typename U>
874 bool serialize(const offset_t *relative_member_offsets, U value)
875 {
876 RTI_FLAT_ASSERT(relative_member_offsets != NULL, return false);
877
878 return OffsetBase::serialize<U>(
879 // pick the right offset based on the initial alignment
880 get_value_for_alignment(relative_member_offsets), value);
881 }
882
883
884 // Obtains a member at the specified relative offset
885 //
886 // U is the type of the member. U must be a subclass of Offset<U>.
887 template <typename U>
888 U get_member(const offset_t *relative_member_offsets)
889 {
890 RTI_FLAT_ASSERT(relative_member_offsets != NULL, return U());
891
892 return OffsetBase::get_member<U>(
893 get_value_for_alignment(relative_member_offsets));
894 }
895
896 template <typename U>
897 U get_member(const offset_t *relative_member_offsets) const
898 {
899 RTI_FLAT_ASSERT(relative_member_offsets != NULL, return U());
900
901 return OffsetBase::get_member<U>(
902 get_value_for_alignment(relative_member_offsets));
903 }
904
905 // Returns an FinalArrayOffset located within this Offset
906 template <typename U, unsigned int N>
907 FinalArrayOffset<U, N> get_array_member(
908 const offset_t *relative_member_offsets,
909 const offset_t *first_element_sizes,
910 offset_t element_size)
911 {
912 typedef FinalArrayOffset<U, N> ArrayType;
913
914 RTI_FLAT_ASSERT(relative_member_offsets != NULL, return ArrayType());
915 RTI_FLAT_ASSERT(first_element_sizes != NULL, return ArrayType());
916
917 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return ArrayType());
918
919 return ArrayType(
920 sample_,
921 // the absolute location of the member:
922 absolute_offset_ + get_value_for_alignment(relative_member_offsets),
923 // the size of the first element, which can differ from the rest
924 get_value_for_alignment(first_element_sizes),
925 // the size of every other element
926 element_size);
927 }
928
929 template <typename U, unsigned int N>
930 FinalArrayOffset<U, N> get_array_member(
931 const offset_t *relative_member_offsets,
932 const offset_t *first_element_sizes,
933 offset_t element_size) const
934 {
935 typedef FinalArrayOffset<U, N> ArrayType;
936
937 RTI_FLAT_ASSERT(relative_member_offsets != NULL, return ArrayType());
938 RTI_FLAT_ASSERT(first_element_sizes != NULL, return ArrayType());
939
940 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return ArrayType());
941 return ArrayType(
942 sample_,
943 // the absolute location of the member:
944 absolute_offset_ + get_value_for_alignment(relative_member_offsets),
945 // the size of the first element, which can differ from the rest
946 get_value_for_alignment(first_element_sizes),
947 // the size of every other element
948 element_size);
949 }
950
951private:
952 // A member's relative offset or an array's first element size
953 // may be different depending on the alignment of the position in the CDR
954 // buffer of the type that contains them (this). These values are passed
955 // to get_member or get_array_member as an array of 4 possible values. This
956 // function picks the right one based on the alingmenet of absolute_offset_
957 offset_t get_value_for_alignment(const offset_t *values_per_alignment) const
958 {
959 return values_per_alignment
960 [absolute_offset_ % RTI_XCDR_MAX_XCDR2_ALIGNMENT];
961 }
962};
963
964struct MutableOffsetHelper {
965 // Obtains the size of a mutable struct located at the absolute_offset of
966 // a FlatData sample
967 static offset_t calculate_serialized_size(
968 rti::flat::SampleBase *sample,
969 offset_t absolute_offset,
970 offset_t)
971 {
972 RTI_FLAT_ASSERT(sample != NULL, return 0);
973
974 return RTIXCdrFlatSample_getMutableSampleSize(
975 sample->get_buffer(),
976 absolute_offset);
977 }
978};
979
987class MutableOffset : public OffsetBase {
988public:
989 typedef variable_size_type_tag_t offset_kind;
990 typedef MutableOffsetHelper Helper;
991
992protected:
994 {
995 }
996
998 SampleBase *sample,
999 offset_t absolute_offset,
1000 offset_t serialized_size)
1001 : OffsetBase(
1002 sample,
1003 absolute_offset,
1004 serialized_size)
1005 {
1006 }
1007
1008 template <typename U>
1009 U deserialize(member_id_t member_id, U default_val = U()) const
1010 {
1011 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return U());
1012
1013 rti::xcdr::Stream::Memento stream_memento(stream_);
1014
1015 offset_t member_size = 0;
1016 if (!RTIXCdrStream_findV2MutableSampleMember(
1017 &stream_.c_stream(),
1018 member_id,
1019 &member_size)) {
1020 return default_val;
1021 }
1022
1023 return stream_.deserialize_fast<U>();
1024 }
1025
1026 // Sets the value of a primitive member at the specified relative offset
1027 template <typename U>
1028 bool serialize(member_id_t member_id, U value)
1029 {
1030 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return false);
1031
1032 rti::xcdr::Stream::Memento stream_memento(stream_);
1033
1034 offset_t member_size = 0;
1035 if (!RTIXCdrStream_findV2MutableSampleMember(
1036 &stream_.c_stream(),
1037 member_id,
1038 &member_size)) {
1039 return false;
1040 }
1041
1042 stream_.serialize_fast<U>(value);
1043 return true;
1044 }
1045
1046 template <typename U>
1047 U get_member(member_id_t member_id) const
1048 {
1049 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return U());
1050
1051 rti::xcdr::Stream::Memento stream_memento(stream_);
1052
1053 offset_t member_size = 0;
1054 if (!RTIXCdrStream_findV2MutableSampleMember(
1055 &stream_.c_stream(),
1056 member_id,
1057 &member_size)) {
1058 return U();
1059 }
1060
1061 return get_member_impl<U>(
1062 // absolute offset to the found member
1063 detail::ptrdiff(stream_.current_position(), sample_->get_buffer()),
1064 member_size,
1065 typename U::offset_kind());
1066 }
1067
1068private:
1069 template <typename U>
1070 U get_member_impl(
1071 offset_t absolute_member_offset,
1072 offset_t member_size,
1073 variable_size_type_tag_t) const
1074 {
1075 RTI_FLAT_ASSERT(absolute_member_offset > 0, return U());
1076
1077 // VariableOffsets receive a member_size
1078 return U(sample_, absolute_member_offset, member_size);
1079 }
1080
1081 template <typename U>
1082 U get_member_impl(
1083 offset_t absolute_member_offset,
1084 offset_t member_size,
1085 fixed_size_type_tag_t) const
1086 {
1087 (void) member_size; // suppress unused-param warning in release mode
1088 RTI_FLAT_ASSERT(absolute_member_offset > 0, return U());
1089
1090 // FixedOffsets do not receive a member_size (it's already known)
1091 return U(sample_, absolute_member_offset);
1092 }
1093};
1094
1103template <typename T>
1105public:
1106 typedef fixed_size_type_tag_t offset_kind;
1107
1109 {
1110 }
1111
1113 SampleBase *sample,
1114 offset_t absolute_offset)
1115 : OffsetBase(
1116 sample,
1117 absolute_offset,
1118 serialized_size(0))
1119 {
1120 }
1121
1122 bool is_cpp_compatible() const
1123 {
1124 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return false);
1125 return sizeof(T) == 1 || !stream_.needs_byte_swap();
1126 }
1127
1133 T get() const
1134 {
1135 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return T());
1136 RTI_FLAT_ASSERT(stream_.check_size(sizeof(T)), return T());
1137
1138 return stream_.deserialize_fast<T>();
1139 }
1140
1141 static offset_t serialized_size(offset_t)
1142 {
1143 return sizeof(T);
1144 }
1145
1146 static offset_t serialized_size_w_padding()
1147 {
1148 return serialized_size(0);
1149 }
1150
1151};
1152
1169template <typename T>
1171public:
1173 {
1174 }
1175
1177 SampleBase *sample,
1178 offset_t absolute_offset)
1180 sample,
1181 absolute_offset)
1182 {
1183 }
1184
1190 bool set(T value)
1191 {
1192 RTI_FLAT_OFFSET_CHECK_NOT_NULL(return false);
1193 RTI_FLAT_ASSERT(this->stream_.check_size(sizeof(T)), return false);
1194
1195 this->stream_.template serialize_fast<T>(value);
1196 return true;
1197 }
1198};
1199
1200} }
1201
1202#endif // RTI_DDS_FLAT_FLATOFFSETS_HPP_
1203
Represents the Offset to an arbitrary user-defined FlatData final IDL struct.
Definition: Offset.hpp:125
bool my_primitive(int32_t value)
Sets the value for a primitive member.
FlatFinalBar::ConstOffset my_complex() const
Retrieves a const Offset to a complex member.
MyFlatFinalConstOffset ConstOffset
The equivalent read-only Offset type.
Definition: Offset.hpp:135
FlatFinalBar::Offset my_complex()
Retrieves a non-const Offset to a complex member.
rti::flat::PrimitiveArrayOffset< int32_t, 10 > my_primitive_array()
Retrieves a non-const Offset to a primitive array.
int32_t my_primitive() const
Retrieves the value for a primitive member.
rti::flat::FinalArrayOffset< FlatFinalBar::ConstOffset, 10 > my_complex_array() const
Retrieves a const Offset to a complex array.
rti::flat::FinalArrayOffset< FlatFinalBar::Offset, 10 > my_complex_array()
Retrieves a non-const Offset to a complex array.
const rti::flat::PrimitiveArrayOffset< int32_t, 10 > my_primitive_array() const
Retrieves a const Offset to a primitive array.
MyFlatFinalOffset()
Creates a null Offset.
Definition: Offset.hpp:142
Represents the Offset to an arbitrary user-defined FlatData mutable IDL struct.
Definition: Offset.hpp:203
MyFlatFinal::Offset my_final()
Retrieves a non-const Offset to a complex member.
bool my_primitive(int32_t value)
Sets the value of a primitive member.
rti::flat::MutableArrayOffset< FlatMutableBar::ConstOffset, 10 > my_mutable_array() const
Retrieves a const Offset to a complex array.
int32_t my_primitive() const
Retrieves the value for a primitive member.
MyFlatFinal::ConstOffset my_final() const
Retrieves a const Offset to a complex member.
FlatMutableBar::ConstOffset my_mutable() const
Retrieves a const Offset to a complex member.
rti::flat::PrimitiveConstOffset< int32_t > my_optional_primitive() const
Retrieves a const Offset to an optional primitive.
rti::flat::SequenceOffset< MyFlatFinal::ConstOffset > my_final_seq() const
Retrieves a const Offset to a complex sequence.
rti::flat::PrimitiveSequenceOffset< int32_t > my_primitive_seq()
Retrieves a non-const Offset to a primitive sequence.
MyFlatMutableOffset()
Creates a null Offset.
Definition: Offset.hpp:220
rti::flat::SequenceOffset< rti::flat::StringOffset > my_string_seq()
Retrieves a non-const Offset to a sequence of strings.
rti::flat::FinalAlignedArrayOffset< MyFlatFinal::Offset, 10 > my_final_array()
Retrieves a non-const Offset to a complex array.
rti::flat::SequenceOffset< MyFlatFinal::Offset > my_final_seq()
Retrieves a non-const Offset to a complex sequence.
rti::flat::MutableArrayOffset< FlatMutableBar::Offset, 10 > my_mutable_array()
Retrieves a non-const Offset to a complex array.
rti::flat::SequenceOffset< const rti::flat::StringOffset > my_string_seq() const
Retrieves a const Offset to a sequence of strings.
const rti::flat::PrimitiveArrayOffset< int32_t, 10 > my_primitive_array() const
Retrieves a const Offset to a primitive array.
rti::flat::SequenceOffset< FlatMutableBar::Offset > my_mutable_seq()
Retrieves a non-const Offset to a complex sequence.
rti::flat::SequenceOffset< FlatMutableBar::ConstOffset > my_mutable_seq() const
Retrieves a const Offset to a complex sequence.
const rti::flat::PrimitiveSequenceOffset< int32_t > my_primitive_seq() const
Retrieves a const Offset to a primitive sequence.
FlatMutableBar::Offset my_mutable()
Retrieves a non-const Offset to a complex member.
const rti::flat::StringOffset my_string() const
Retrieves a const Offset to a string.
rti::flat::FinalAlignedArrayOffset< MyFlatFinal::ConstOffset, 10 > my_final_array() const
Retrieves a const Offset to a complex array.
rti::flat::PrimitiveArrayOffset< int32_t, 10 > my_primitive_array()
Retrieves a non-const Offset to a primitive array.
rti::flat::StringOffset my_string()
Retrieves a non-const Offset to a string.
MyFlatMutableConstOffset ConstOffset
The equivalent read-only Offset type.
Definition: Offset.hpp:213
Represents the Offset to an arbitrary user-defined FlatData mutable IDL union.
Definition: Offset.hpp:376
MyFlatMutable::Offset my_mutable()
Retrieves a non-const Offset to a complex member.
bool my_primitive(int32_t value)
Sets the value for a primitive member.
int32_t my_primitive() const
Retrieves the value for a primitive member.
int32_t _d() const
Retrieves the union discriminator.
MyFlatFinal::Offset my_final()
Retrieves a non-const Offset to a complex member.
MyFlatUnionOffset()
Creates a null Offset.
Definition: Offset.hpp:388
MyFlatMutable::ConstOffset my_mutable() const
Retrieves a const Offset to a complex member.
MyFlatUnionConstOffset ConstOffset
The equivalent read-only Offset type.
Definition: Offset.hpp:381
MyFlatFinal::ConstOffset my_final() const
Retrieves a const Offset to a complex member.
Offset to an array of final elements.
Definition: SequenceOffsets.hpp:776
Offset to an array of final elements.
Definition: SequenceOffsets.hpp:683
The base class of all Offsets to a final struct type.
Definition: Offset.hpp:805
Offset to an array of variable-size elements.
Definition: SequenceOffsets.hpp:621
The base class of all Offsets to a final struct type.
Definition: Offset.hpp:987
Base class of all Offset types.
Definition: Offset.hpp:562
bool is_null() const
Indicates whether this Offset doesn't point to a valid element.
Definition: Offset.hpp:582
friend bool operator>=(const OffsetBase &s1, const OffsetBase &s2)
Compares two Offsets.
Definition: Offset.hpp:685
friend bool operator<(const OffsetBase &s1, const OffsetBase &s2)
Compares two Offsets.
Definition: Offset.hpp:652
const unsigned char * get_buffer() const
Gets this member's position in the buffer.
Definition: Offset.hpp:627
friend bool operator!=(const OffsetBase &s1, const OffsetBase &s2)
Determines if two offets point to different positions.
Definition: Offset.hpp:707
friend bool operator==(const OffsetBase &s1, const OffsetBase &s2)
Determines if two offets point to the same position.
Definition: Offset.hpp:696
offset_t get_buffer_size() const
Gets the size, in bytes, of this member in the buffer.
Definition: Offset.hpp:641
friend bool operator<=(const OffsetBase &s1, const OffsetBase &s2)
Compares two Offsets.
Definition: Offset.hpp:674
friend bool operator>(const OffsetBase &s1, const OffsetBase &s2)
Compares two Offsets.
Definition: Offset.hpp:663
bool is_cpp_compatible() const
Indicates whether rti::flat::plain_cast() is possible.
Definition: Offset.hpp:595
Offset to an array of primitive elements.
Definition: SequenceOffsets.hpp:241
Offset to a sequence of primitive elements.
Definition: SequenceOffsets.hpp:146
OffsetType Offset
The related Offset type.
Definition: FlatSample.hpp:155
OffsetType::ConstOffset ConstOffset
The related read-only Offset type.
Definition: FlatSample.hpp:162
Offset to a sequence of non-primitive elements.
Definition: SequenceOffsets.hpp:501
Offset to a string.
Definition: SequenceOffsets.hpp:291
The RTI namespace.
Definition: AggregationBuilders.hpp:17
A const Offset to an optional primitive member.
Definition: Offset.hpp:1104
T get() const
Gets the value of this primitive member.
Definition: Offset.hpp:1133
An Offset to an optional primitive member.
Definition: Offset.hpp:1170
bool set(T value)
Sets a value for this primitive member.
Definition: Offset.hpp:1190
Given a Sample, an Offset or a Builder, it allows obtaining the other types.
Definition: FlatSample.hpp:340