OpenDDS  Snapshot(2023/04/28-20:55)
Serializer.inl
Go to the documentation of this file.
1 /*
2  * Distributed under the OpenDDS License.
3  * See: http://www.opendds.org/license.html
4  */
5 
6 #include "Serializer.h"
7 #include "debug.h"
8 
9 #include <ace/Message_Block.h>
10 #include <ace/OS_NS_string.h>
11 #include <ace/Log_Msg.h>
12 
13 #include <algorithm>
14 
15 #include <cstring>
16 
18 
19 namespace OpenDDS {
20 namespace DCPS {
21 
23 void align(size_t& value, size_t by)
24 {
25  value = (value + by - 1) & ~(by - 1);
26 }
27 
30 {
31  return kind_;
32 }
33 
36 {
37  zero_init_padding(true);
38 
39  switch (value) {
40  case KIND_XCDR1:
43  break;
44 
45  case KIND_XCDR2:
48  break;
49 
50  case KIND_UNALIGNED_CDR:
53  break;
54 
55  default:
57  ACE_TEXT("(%P|%t) ERROR: Encoding::kind: Invalid Argument: %u\n"), value));
58  }
59 
60  kind_ = value;
61 }
62 
65 {
66  return endianness_;
67 }
68 
71 {
73 }
74 
77 {
78  return alignment_;
79 }
80 
83 {
84  alignment_ = value;
85 }
86 
89 {
90  return zero_init_padding_;
91 }
92 
95 {
97 }
98 
101 {
102  return skip_sequence_dheader_;
103 }
104 
107 {
109 }
110 
112 size_t Encoding::max_align() const
113 {
114  return static_cast<size_t>(alignment_);
115 }
116 
118 void Encoding::align(size_t& value, size_t by) const
119 {
120  const size_t max_alignment = max_align();
121  if (max_alignment) {
122  DCPS::align(value, (std::min)(max_alignment, by));
123  }
124 }
125 
128 {
129  return xcdr_version_;
130 }
131 
134 {
136 }
137 
140 {
141  switch (kind) {
142  case KIND_XCDR1:
143  case KIND_XCDR2:
144  return true;
145  case KIND_UNALIGNED_CDR:
146  return false;
147  default:
148  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Encoding::is_encapsulated: ")
149  ACE_TEXT("Invalid Argument: %u\n"), kind));
150  return false;
151  }
152 }
153 
156 {
157  return is_encapsulated(kind_);
158 }
159 
162 {
163  return kind_;
164 }
165 
168 {
169  kind_ = value;
170 }
171 
174 {
175  return kind_ != KIND_INVALID;
176 }
177 
180 {
181  return options_;
182 }
183 
186 {
187  options_ = value;
188 }
189 
191 bool serialized_size(const Encoding& /*encoding*/, size_t& size,
192  const EncapsulationHeader& /*value*/)
193 {
195  return true;
196 }
197 
200 {
201  return encoding_;
202 }
203 
206 {
207  encoding_ = value;
208  swap_bytes_ = value.endianness() != ENDIAN_NATIVE;
209 }
210 
213 {
214  Encoding enc = encoding();
215  enc.endianness(value);
216  encoding(enc);
217 }
218 
221 {
222  return encoding_.endianness();
223 }
224 
225 // NOTE: I use the ternary operators in here for conditionals to help
226 // the compiler inline the code -- and it does end up fairly
227 // tight...
228 ACE_INLINE size_t
229 Serializer::doread(char* dest, size_t size, bool swap, size_t offset)
230 {
231  //
232  // Ensure we work only with buffer data.
233  //
234  if (current_ == 0) {
235  good_bit_ = false;
236  return size;
237  }
238 
239  //
240  // Determine how much data will remain to be read after the current
241  // buffer has been entirely read.
242  //
243  const size_t len = current_->length();
244  const size_t remainder = (size - offset > len) ? size - offset - len : 0;
245 
246  //
247  // Derive how much data we need to read from the current buffer.
248  //
249  const size_t initial = size - offset - remainder;
250 
251  //
252  // Copy or swap the source data from the current buffer into the
253  // destination.
254  //
255  swap
256  ? swapcpy(dest + remainder, current_->rd_ptr(), initial)
257  : smemcpy(dest + offset, current_->rd_ptr(), initial);
258  current_->rd_ptr(initial);
259 
260  // Update the logical reading position in the stream.
261  rpos_ += initial;
262 
263  // smemcpy
264  //
265  // dest b1 b2 b3 offset remainder initial
266  // xxxxxxxx 01 23 4567xx
267  // ^ 0 6 2
268  // 01xxxxxx 01 23 4567xx
269  // ^ 2 4 2
270  // 0123xxxx 01 23 4567xx
271  // ^ 4 0 4
272  // 01234567 01 23 4567xx
273  // ^
274 
275  // swapcpy
276  //
277  // dest b1 b2 b3 offset remainder initial
278  // xxxxxxxx 01 23 4567xx
279  // ^ 0 6 2
280  // xxxxxx10 01 23 4567xx
281  // ^ 2 4 2
282  // xxxx3210 01 23 4567xx
283  // ^ 4 0 4
284  // 76543210 01 23 4567xx
285  // ^
286 
287  //
288  // Move to the next chained block if this one is spent.
289  //
290  if (current_->length() == 0) {
291  if (encoding().alignment()) {
292  align_cont_r();
293  } else {
294  current_ = current_->cont();
295  }
296  }
297 
298  //
299  // Return the current location in the read.
300  //
301  return offset + initial;
302 }
303 
304 ACE_INLINE void
305 Serializer::buffer_read(char* dest, size_t size, bool swap)
306 {
307  size_t offset = 0;
308 
309  while (size > offset) {
310  offset = doread(dest, size, swap, offset);
311  }
312 }
313 
314 // NOTE: I use the ternary operators in here for conditionals to help
315 // the compiler inline the code -- and it does end up fairly
316 // tight...
317 ACE_INLINE size_t
318 Serializer::dowrite(const char* src, size_t size, bool swap, size_t offset)
319 {
320  //
321  // Ensure we work only with buffer data.
322  //
323  if (current_ == 0) {
324  good_bit_ = false;
325  return size;
326  }
327 
328  //
329  // Determine how much data will remain to be written after the current
330  // buffer has been entirely filled.
331  //
332  const size_t spc = current_->space();
333  const size_t remainder = (size - offset > spc) ? size - offset - spc : 0;
334 
335  //
336  // Derive how much data we need to write to the current buffer.
337  //
338  const size_t initial = size - offset - remainder;
339 
340  //
341  // Copy or swap the source data into the current buffer.
342  //
343  swap
344  ? swapcpy(current_->wr_ptr(), src + remainder, initial)
345  : smemcpy(current_->wr_ptr(), src + offset, initial);
346  current_->wr_ptr(initial);
347 
348  // Update the logical writing position in the stream.
349  wpos_ += initial;
350 
351  // smemcpy
352  //
353  // src b1 b2 b3 offset remainder initial
354  // 01234567 xx xx xxxxxx
355  // ^ 0 6 2
356  // 01 xx xxxxxx
357  // ^ 2 4 2
358  // 01 23 xxxxxx
359  // ^ 4 0 4
360  // 01 23 4567xx
361  // ^
362 
363  // swapcpy
364  //
365  // src b1 b2 b3 offset remainder initial
366  // 01234567 xx xx xxxxxx
367  // ^ 0 6 2
368  // 76 xx xxxxxx
369  // ^ 2 4 2
370  // 76 54 xxxxxx
371  // ^ 4 0 4
372  // 76 54 3210xx
373  // ^
374 
375  //
376  // Move to the next chained block if this one is spent.
377  //
378  if (current_->space() == 0) {
379  if (encoding().alignment()) {
380  align_cont_w();
381  } else {
382  current_ = current_->cont();
383  }
384  }
385 
386  //
387  // Return the current location in the write.
388  //
389  return offset + initial;
390 }
391 
392 ACE_INLINE void
393 Serializer::buffer_write(const char* src, size_t size, bool swap)
394 {
395  size_t offset = 0;
396 
397  while (size > offset) {
398  offset = dowrite(src, size, swap, offset);
399  }
400 }
401 
403 void Serializer::swap_bytes(bool do_swap)
404 {
405  Encoding enc = encoding_;
406  enc.endianness(do_swap ? ENDIAN_NONNATIVE : ENDIAN_NATIVE);
407  encoding(enc);
408 }
409 
410 ACE_INLINE bool
412 {
413  return swap_bytes_;
414 }
415 
418 {
419  return encoding().alignment();
420 }
421 
424 {
425  Encoding enc = encoding_;
426  enc.alignment(value);
427  encoding(enc);
428 }
429 
430 ACE_INLINE bool
432 {
433  return good_bit_;
434 }
435 
436 ACE_INLINE size_t
438 {
439  return good_bit_ && current_ ? current_->total_length() : 0;
440 }
441 
442 ACE_INLINE bool
443 Serializer::skip(size_t n, int size)
444 {
445  if (size > 1 && !align_r((std::min)(size_t(size), encoding().max_align()))) {
446  return false;
447  }
448 
449  for (size_t len = static_cast<size_t>(n * size); len;) {
450  if (!current_) {
451  good_bit_ = false;
452  return false;
453  }
454  const size_t cur_len = current_->length();
455  if (cur_len <= len) {
456  len -= cur_len;
457  current_->rd_ptr(current_->wr_ptr());
458  align_cont_r();
459  } else {
460  current_->rd_ptr(len);
461  break;
462  }
463  }
464 
465  if (good_bit_) {
466  rpos_ += n * size;
467  }
468  return good_bit();
469 }
470 
471 ACE_INLINE void
472 Serializer::read_array(char* x, size_t size, ACE_CDR::ULong length)
473 {
474  read_array(x, size, length, swap_bytes_);
475 }
476 
477 ACE_INLINE void
478 Serializer::read_array(char* x, size_t size,
479  ACE_CDR::ULong length, bool swap)
480 {
481  if (!swap || size == 1) {
482  //
483  // No swap, copy direct. This silently corrupts the data if there is
484  // padding in the buffer.
485  //
486  buffer_read(x, size * length, false);
487 
488  } else {
489  //
490  // Swapping _must_ be done at 'size' boundaries, so we need to spin
491  // through the array element by element. This silently corrupts the
492  // data if there is padding in the buffer.
493  //
494  while (length-- > 0) {
495  buffer_read(x, size, true);
496  x += size;
497  }
498  }
499 }
500 
501 ACE_INLINE void
502 Serializer::write_array(const char* x, size_t size, ACE_CDR::ULong length)
503 {
504  write_array(x, size, length, swap_bytes_);
505 }
506 
507 ACE_INLINE void
508 Serializer::write_array(const char* x, size_t size,
509  ACE_CDR::ULong length, bool swap)
510 {
511  if (!swap || size == 1) {
512  //
513  // No swap, copy direct.
514  //
515  buffer_write(x, size * length, false);
516 
517  } else {
518  //
519  // Swapping _must_ be done at 'size' boundaries, so we need to spin
520  // through the array element by element.
521  // NOTE: This assumes that there is _no_ padding between the array
522  // elements. If this is not the case, do not use this
523  // method.
524  //
525  while (length-- > 0) {
526  buffer_write(x, size, true);
527  x += size;
528  }
529  }
530 }
531 
532 ACE_INLINE bool
534 {
535  read_array(reinterpret_cast<char*>(x), boolean_cdr_size, length);
536  return good_bit();
537 }
538 
539 ACE_INLINE bool
541 {
542  read_array(reinterpret_cast<char*>(x), char8_cdr_size, length);
543  return good_bit();
544 }
545 
546 ACE_INLINE bool
548 {
549  for (ACE_CDR::ULong i = 0; i < length; ++i) {
550  if (!((*this) >> ACE_InputCDR::to_wchar(x[i]))) {
551  break;
552  }
553  }
554  return good_bit();
555 }
556 
557 ACE_INLINE bool
559 {
560  read_array(reinterpret_cast<char*>(x), byte_cdr_size, length);
561  return good_bit();
562 }
563 
564 #if OPENDDS_HAS_EXPLICIT_INTS
566 bool Serializer::read_int8_array(ACE_CDR::Int8* x, ACE_CDR::ULong length)
567 {
568  read_array(reinterpret_cast<char*>(x), int8_cdr_size, length);
569  return good_bit();
570 }
571 
573 bool Serializer::read_uint8_array(ACE_CDR::UInt8* x, ACE_CDR::ULong length)
574 {
575  read_array(reinterpret_cast<char*>(x), uint8_cdr_size, length);
576  return good_bit();
577 }
578 #endif
579 
580 ACE_INLINE bool
582 {
583  if (!align_r(int16_cdr_size)) {
584  return false;
585  }
586  read_array(reinterpret_cast<char*>(x), int16_cdr_size, length);
587  return good_bit();
588 }
589 
590 ACE_INLINE bool
592 {
593  if (!align_r(uint16_cdr_size)) {
594  return false;
595  }
596  read_array(reinterpret_cast<char*>(x), uint16_cdr_size, length);
597  return good_bit();
598 }
599 
600 ACE_INLINE bool
602 {
603  if (!align_r(int32_cdr_size)) {
604  return false;
605  }
606  read_array(reinterpret_cast<char*>(x), int32_cdr_size, length);
607  return good_bit();
608 }
609 
610 ACE_INLINE bool
612 {
613  if (!align_r(uint32_cdr_size)) {
614  return false;
615  }
616  read_array(reinterpret_cast<char*>(x), uint32_cdr_size, length);
617  return good_bit();
618 }
619 
620 ACE_INLINE bool
622 {
623  if (!align_r(int64_cdr_size)) {
624  return false;
625  }
626  read_array(reinterpret_cast<char*>(x), int64_cdr_size, length);
627  return good_bit();
628 }
629 
630 ACE_INLINE bool
632 {
633  if (!align_r(uint64_cdr_size)) {
634  return false;
635  }
636  read_array(reinterpret_cast<char*>(x), uint64_cdr_size, length);
637  return good_bit();
638 }
639 
640 ACE_INLINE bool
642 {
643  if (!align_r(float32_cdr_size)) {
644  return false;
645  }
646  read_array(reinterpret_cast<char*>(x), float32_cdr_size, length);
647  return good_bit();
648 }
649 
650 ACE_INLINE bool
652 {
653  if (!align_r(float64_cdr_size)) {
654  return false;
655  }
656  read_array(reinterpret_cast<char*>(x), float64_cdr_size, length);
657  return good_bit();
658 }
659 
660 ACE_INLINE bool
662 {
663  if (!align_r(float128_cdr_size)) {
664  return false;
665  }
666  read_array(reinterpret_cast<char*>(x), float128_cdr_size, length);
667  return good_bit();
668 }
669 
670 ACE_INLINE bool
672  ACE_CDR::ULong length)
673 {
674  write_array(reinterpret_cast<const char*>(x), boolean_cdr_size, length);
675  return good_bit();
676 }
677 
678 ACE_INLINE bool
680 {
681  write_array(reinterpret_cast<const char*>(x), char8_cdr_size, length);
682  return good_bit();
683 }
684 
685 ACE_INLINE bool
687 {
688  for (ACE_CDR::ULong i = 0; i < length; ++i) {
689  if (!((*this) << ACE_OutputCDR::from_wchar(x[i]))) {
690  break;
691  }
692  }
693  return good_bit();
694 }
695 
696 ACE_INLINE bool
698 {
699  write_array(reinterpret_cast<const char*>(x), byte_cdr_size, length);
700  return good_bit();
701 }
702 
703 #if OPENDDS_HAS_EXPLICIT_INTS
705 bool Serializer::write_int8_array(const ACE_CDR::Int8* x, ACE_CDR::ULong length)
706 {
707  write_array(reinterpret_cast<const char*>(x), int8_cdr_size, length);
708  return good_bit();
709 }
710 
712 bool Serializer::write_uint8_array(const ACE_CDR::UInt8* x, ACE_CDR::ULong length)
713 {
714  write_array(reinterpret_cast<const char*>(x), uint8_cdr_size, length);
715  return good_bit();
716 }
717 #endif
718 
719 ACE_INLINE bool
721 {
722  if (!align_w(int16_cdr_size)) {
723  return false;
724  }
725  write_array(reinterpret_cast<const char*>(x), int16_cdr_size, length);
726  return good_bit();
727 }
728 
729 ACE_INLINE bool
731 {
732  if (!align_w(uint16_cdr_size)) {
733  return false;
734  }
735  write_array(reinterpret_cast<const char*>(x), uint16_cdr_size, length);
736  return good_bit();
737 }
738 
739 ACE_INLINE bool
741 {
742  if (!align_w(int32_cdr_size)) {
743  return false;
744  }
745  write_array(reinterpret_cast<const char*>(x), int32_cdr_size, length);
746  return good_bit();
747 }
748 
749 ACE_INLINE bool
751 {
752  if (!align_w(uint32_cdr_size)) {
753  return false;
754  }
755  write_array(reinterpret_cast<const char*>(x), uint32_cdr_size, length);
756  return good_bit();
757 }
758 
759 ACE_INLINE bool
761  ACE_CDR::ULong length)
762 {
763  if (!align_w(int64_cdr_size)) {
764  return false;
765  }
766  write_array(reinterpret_cast<const char*>(x), int64_cdr_size, length);
767  return good_bit();
768 }
769 
770 ACE_INLINE bool
772  ACE_CDR::ULong length)
773 {
774  if (!align_w(uint64_cdr_size)) {
775  return false;
776  }
777  write_array(reinterpret_cast<const char*>(x), uint64_cdr_size, length);
778  return good_bit();
779 }
780 
781 ACE_INLINE bool
783 {
784  if (!align_w(float32_cdr_size)) {
785  return false;
786  }
787  write_array(reinterpret_cast<const char*>(x), float32_cdr_size, length);
788  return good_bit();
789 }
790 
791 ACE_INLINE bool
793 {
794  if (!align_w(float64_cdr_size)) {
795  return false;
796  }
797  write_array(reinterpret_cast<const char*>(x), float64_cdr_size, length);
798  return good_bit();
799 }
800 
801 ACE_INLINE bool
803  ACE_CDR::ULong length)
804 {
805  if (!align_w(float128_cdr_size)) {
806  return false;
807  }
808  write_array(reinterpret_cast<const char*>(x), float128_cdr_size, length);
809  return good_bit();
810 }
811 
813 bool Serializer::align_r(size_t al)
814 {
815  if (!alignment()) {
816  return true;
817  }
818  if (!current_) {
819  good_bit_ = false;
820  return false;
821  }
822  al = (std::min)(al, encoding().max_align());
823  const size_t len =
824  (al - ptrdiff_t(current_->rd_ptr()) + align_rshift_) % al;
825 
826  return skip(static_cast<ACE_CDR::UShort>(len));
827 }
828 
830 bool Serializer::align_w(size_t al)
831 {
832  if (!alignment()) {
833  return true;
834  }
835  if (!current_) {
836  good_bit_ = false;
837  return false;
838  }
839  al = (std::min)(al, encoding().max_align());
840  size_t len =
841  (al - ptrdiff_t(current_->wr_ptr()) + align_wshift_) % al;
842  while (len) {
843  if (!current_) {
844  good_bit_ = false;
845  break;
846  }
847  const size_t cur_spc = current_->space();
848  if (cur_spc <= len) {
849  len -= cur_spc;
850  if (encoding().zero_init_padding()) {
851  smemcpy(current_->wr_ptr(), ALIGN_PAD, cur_spc);
852  }
853  current_->wr_ptr(cur_spc);
854  wpos_ += cur_spc;
855  align_cont_w();
856  } else {
857  if (encoding().zero_init_padding()) {
858  smemcpy(current_->wr_ptr(), ALIGN_PAD, len);
859  }
860  current_->wr_ptr(len);
861  wpos_ += len;
862  break;
863  }
864  }
865  return good_bit_;
866 }
867 
868 ACE_INLINE unsigned char
869 Serializer::offset(char* index, size_t start, size_t align)
870 {
871  return static_cast<unsigned char>((ptrdiff_t(index) - start) % align);
872 }
873 
874 ACE_INLINE void
876 {
877  const size_t max_align = encoding().max_align();
878  const size_t thisblock =
879  max_align ? (ptrdiff_t(current_->rd_ptr()) - align_rshift_) % max_align : 0;
880 
881  current_ = current_->cont();
882 
883  if (current_ && max_align) {
884  align_rshift_ = offset(current_->rd_ptr(), thisblock, max_align);
885  }
886 }
887 
888 ACE_INLINE void
890 {
891  const size_t max_align = encoding().max_align();
892  const size_t thisblock =
893  max_align ? (ptrdiff_t(current_->wr_ptr()) - align_wshift_) % max_align : 0;
894 
895  current_ = current_->cont();
896 
897  if (current_ && max_align) {
898  align_wshift_ = offset(current_->wr_ptr(), thisblock, max_align);
899  }
900 }
901 
904 {
906  return skip(uint32_cdr_size);
907  }
908  return true;
909 }
910 
912 bool Serializer::read_delimiter(size_t& size)
913 {
915  ACE_CDR::ULong dheader;
916  if (*this >> dheader) {
917  size = dheader;
918  return true;
919  }
920  }
921  return false;
922 }
923 
926 {
928  return *this << static_cast<ACE_CDR::ULong>(size - uint32_cdr_size);
929  }
930  return true;
931 }
932 
935 {
937  return align_w(xcdr1_pid_alignment) && *this << pid_list_end && *this << ACE_CDR::UShort(0);
938  }
939  return true;
940 }
941 
942 //
943 // The following insertion operators are done in the style of the
944 // ACE_CDR insertion operators instead of a stream abstraction. This
945 // is done to allow their use in the same way as existing ACE_CDR
946 // inserters, rather than as a true stream abstraction (which would
947 // return the argument stream).
948 //
949 
950 ACE_INLINE bool
952 {
953  s.buffer_write(reinterpret_cast<char*>(&x), char8_cdr_size, s.swap_bytes());
954  return s.good_bit();
955 }
956 
957 ACE_INLINE bool
959 {
960  if (!s.align_w(int16_cdr_size)) {
961  return false;
962  }
963  s.buffer_write(reinterpret_cast<char*>(&x), int16_cdr_size, s.swap_bytes());
964  return s.good_bit();
965 }
966 
967 ACE_INLINE bool
969 {
970  if (!s.align_w(uint16_cdr_size)) {
971  return false;
972  }
973  s.buffer_write(reinterpret_cast<char*>(&x), uint16_cdr_size, s.swap_bytes());
974  return s.good_bit();
975 }
976 
977 ACE_INLINE bool
979 {
980  if (!s.align_w(int32_cdr_size)) {
981  return false;
982  }
983  s.buffer_write(reinterpret_cast<char*>(&x), int32_cdr_size, s.swap_bytes());
984  return s.good_bit();
985 }
986 
987 ACE_INLINE bool
989 {
990  if (!s.align_w(uint32_cdr_size)) {
991  return false;
992  }
993  s.buffer_write(reinterpret_cast<char*>(&x), uint32_cdr_size, s.swap_bytes());
994  return s.good_bit();
995 }
996 
997 ACE_INLINE bool
999 {
1000  if (!s.align_w(int64_cdr_size)) {
1001  return false;
1002  }
1003  s.buffer_write(reinterpret_cast<char*>(&x), int64_cdr_size, s.swap_bytes());
1004  return s.good_bit();
1005 }
1006 
1007 ACE_INLINE bool
1009 {
1010  if (!s.align_w(uint64_cdr_size)) {
1011  return false;
1012  }
1013  s.buffer_write(reinterpret_cast<char*>(&x), uint64_cdr_size, s.swap_bytes());
1014  return s.good_bit();
1015 }
1016 
1017 ACE_INLINE bool
1019 {
1020  if (!s.align_w(float32_cdr_size)) {
1021  return false;
1022  }
1023  s.buffer_write(reinterpret_cast<char*>(&x), float32_cdr_size, s.swap_bytes());
1024  return s.good_bit();
1025 }
1026 
1027 ACE_INLINE bool
1029 {
1030  if (!s.align_w(float64_cdr_size)) {
1031  return false;
1032  }
1033  s.buffer_write(reinterpret_cast<char*>(&x), float64_cdr_size, s.swap_bytes());
1034  return s.good_bit();
1035 }
1036 
1037 ACE_INLINE bool
1039 {
1040  if (!s.align_w(float128_cdr_size)) {
1041  return false;
1042  }
1043  s.buffer_write(reinterpret_cast<char*>(&x), float128_cdr_size, s.swap_bytes());
1044  return s.good_bit();
1045 }
1046 
1047 ACE_INLINE bool
1049 {
1050  if (x != 0) {
1051  // Include the null termination in the serialized data.
1052  const ACE_CDR::ULong stringlen =
1053  1 + static_cast<ACE_CDR::ULong>(std::strlen(x));
1054  s << stringlen;
1055  s.buffer_write(reinterpret_cast<const char*>(x), stringlen, false);
1056 
1057  } else {
1058  s << ACE_CDR::ULong(0);
1059  }
1060 
1061  return s.good_bit();
1062 }
1063 
1064 ACE_INLINE bool
1066 {
1067  if (x != 0) {
1068  // Do not include the null terminatator in the serialized data.
1069  const ACE_CDR::ULong length = static_cast<ACE_CDR::ULong>(ACE_OS::strlen(x));
1070  s << ACE_CDR::ULong(length * char16_cdr_size);
1071 
1072 #if ACE_SIZEOF_WCHAR == 2
1073  s.write_array(reinterpret_cast<const char*>(x), char16_cdr_size, length,
1074  s.swap_bytes());
1075 #else
1076  for (size_t i = 0; i < length && s.good_bit(); ++i) {
1077  const ACE_UINT16 as_utf16 = static_cast<ACE_UINT16>(x[i]);
1078  if (as_utf16 != x[i]) { // not currently handling surrogates
1079  s.good_bit_ = false;
1080  break;
1081  }
1082  s.buffer_write(reinterpret_cast<const char*>(&as_utf16), char16_cdr_size,
1083  s.swap_bytes());
1084  }
1085 #endif
1086  } else {
1087  s << ACE_CDR::ULong(0);
1088  }
1089 
1090  return s.good_bit();
1091 }
1092 
1093 #ifdef NONNATIVE_LONGDOUBLE
1094 ACE_INLINE bool
1095 operator<<(Serializer& s, long double x)
1096 {
1097  if (!s.align_w(float128_cdr_size)) {
1098  return false;
1099  }
1102  return s << ld;
1103 }
1104 #endif
1105 
1106 ACE_INLINE bool
1108 {
1109  s.buffer_write(reinterpret_cast<char*>(&x.val_), boolean_cdr_size, false);
1110  return s.good_bit();
1111 }
1112 
1113 ACE_INLINE bool
1115 {
1116  s.buffer_write(reinterpret_cast<char*>(&x.val_), char8_cdr_size, false);
1117  return s.good_bit();
1118 }
1119 
1120 ACE_INLINE bool
1122 {
1123  if (!s.align_w(char16_cdr_size)) {
1124  return false;
1125  }
1126 #if ACE_SIZEOF_WCHAR == 2
1127  s.buffer_write(reinterpret_cast<char*>(&x.val_), char16_cdr_size, s.swap_bytes());
1128 #else
1129  const ACE_UINT16 as_utf16 = static_cast<ACE_UINT16>(x.val_);
1130  if (as_utf16 != x.val_) { // not currently handling surrogates
1131  if (DCPS_debug_level) {
1132  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ")
1133  ACE_TEXT("operator<<(Serializer&, ACE_OutputCDR::from_wchar): ")
1134  ACE_TEXT("failure to convert UTF-32 to UTF-16.\n")));
1135  }
1136  s.good_bit_ = false;
1137  } else {
1138  s.buffer_write(reinterpret_cast<const char*>(&as_utf16), char16_cdr_size,
1139  s.swap_bytes());
1140  }
1141 #endif
1142  return s.good_bit();
1143 }
1144 
1145 ACE_INLINE bool
1147 {
1148  return s << x.c_str();
1149 }
1150 
1151 ACE_INLINE bool
1152 operator<<(Serializer& s, Serializer::FromBoundedString<char> x)
1153 {
1154  return (x.bound_ == 0 || x.str_.size() <= x.bound_) && s << x.str_;
1155 }
1156 
1157 #ifdef DDS_HAS_WCHAR
1158 ACE_INLINE bool
1159 operator<<(Serializer& s, const WString& x)
1160 {
1161  return s << x.c_str();
1162 }
1163 
1164 ACE_INLINE bool
1165 operator<<(Serializer& s, Serializer::FromBoundedString<wchar_t> x)
1166 {
1167  return (x.bound_ == 0 || x.str_.size() <= x.bound_) && s << x.str_;
1168 }
1169 #endif /* DDS_HAS_WCHAR */
1170 
1171 ACE_INLINE bool
1173 {
1174  s.buffer_write(reinterpret_cast<char*>(&x.val_), byte_cdr_size, false);
1175  return s.good_bit();
1176 }
1177 
1178 ACE_INLINE bool
1180 {
1181  // Include the null termination in the serialized data.
1182  ACE_CDR::ULong stringlen = 0;
1183  if (x.val_ != 0) {
1184  stringlen = 1 + static_cast<ACE_CDR::ULong>(ACE_OS::strlen(x.val_));
1185  s << stringlen;
1186  s.buffer_write(reinterpret_cast<char*>(x.val_), stringlen, false);
1187  } else {
1188  s << ACE_CDR::ULong(0);
1189  }
1190  return s.good_bit() && ((x.bound_ == 0) || (stringlen - 1 <= x.bound_));
1191 }
1192 
1193 ACE_INLINE bool
1195 {
1196  s << x.val_;
1197  const ACE_CDR::ULong stringlen =
1198  x.bound_ ? static_cast<ACE_CDR::ULong>(ACE_OS::strlen(x.val_)) : 0;
1199  return s.good_bit() && ((x.bound_ == 0) || (stringlen <= x.bound_));
1200 }
1201 
1202 #if OPENDDS_HAS_EXPLICIT_INTS
1203 ACE_INLINE
1205 {
1206  s.buffer_write(reinterpret_cast<const char*>(&x.val_), uint8_cdr_size, false);
1207  return s.good_bit();
1208 }
1209 
1210 ACE_INLINE
1212 {
1213  s.buffer_write(reinterpret_cast<const char*>(&x.val_), int8_cdr_size, false);
1214  return s.good_bit();
1215 }
1216 #endif
1217 
1218 //
1219 // The following extraction operators are done in the style of the
1220 // ACE_CDR extraction operators instead of a stream abstraction. This
1221 // is done to allow their use in the same way as existing ACE_CDR
1222 // extractors, rather than as a true stream abstraction (which would
1223 // return the argument stream).
1224 //
1225 
1226 ACE_INLINE bool
1228 {
1229  s.buffer_read(reinterpret_cast<char*>(&x), char8_cdr_size, s.swap_bytes());
1230  return s.good_bit();
1231 }
1232 
1233 ACE_INLINE bool
1235 {
1236  if (!s.align_r(int16_cdr_size)) {
1237  return false;
1238  }
1239  s.buffer_read(reinterpret_cast<char*>(&x), int16_cdr_size, s.swap_bytes());
1240  return s.good_bit();
1241 }
1242 
1243 ACE_INLINE bool
1245 {
1246  if (!s.align_r(uint16_cdr_size)) {
1247  return false;
1248  }
1249  s.buffer_read(reinterpret_cast<char*>(&x), uint16_cdr_size, s.swap_bytes());
1250  return s.good_bit();
1251 }
1252 
1253 ACE_INLINE bool
1255 {
1256  if (!s.align_r(int32_cdr_size)) {
1257  return false;
1258  }
1259  s.buffer_read(reinterpret_cast<char*>(&x), int32_cdr_size, s.swap_bytes());
1260  return s.good_bit();
1261 }
1262 
1263 ACE_INLINE bool
1265 {
1266  if (!s.align_r(uint32_cdr_size)) {
1267  return false;
1268  }
1269  s.buffer_read(reinterpret_cast<char*>(&x), uint32_cdr_size, s.swap_bytes());
1270  return s.good_bit();
1271 }
1272 
1273 ACE_INLINE bool
1275 {
1276  if (!s.align_r(int64_cdr_size)) {
1277  return false;
1278  }
1279  s.buffer_read(reinterpret_cast<char*>(&x), int64_cdr_size, s.swap_bytes());
1280  return s.good_bit();
1281 }
1282 
1283 ACE_INLINE bool
1285 {
1286  if (!s.align_r(uint64_cdr_size)) {
1287  return false;
1288  }
1289  s.buffer_read(reinterpret_cast<char*>(&x), uint64_cdr_size, s.swap_bytes());
1290  return s.good_bit();
1291 }
1292 
1293 ACE_INLINE bool
1295 {
1296  if (!s.align_r(float32_cdr_size)) {
1297  return false;
1298  }
1299  s.buffer_read(reinterpret_cast<char*>(&x), float32_cdr_size, s.swap_bytes());
1300  return s.good_bit();
1301 }
1302 
1303 ACE_INLINE bool
1305 {
1306  if (!s.align_r(float64_cdr_size)) {
1307  return false;
1308  }
1309  s.buffer_read(reinterpret_cast<char*>(&x), float64_cdr_size, s.swap_bytes());
1310  return s.good_bit();
1311 }
1312 
1313 ACE_INLINE bool
1315 {
1316  if (!s.align_r(float128_cdr_size)) {
1317  return false;
1318  }
1319  s.buffer_read(reinterpret_cast<char*>(&x), float128_cdr_size, s.swap_bytes());
1320  return s.good_bit();
1321 }
1322 
1323 ACE_INLINE bool
1325 {
1326  s.read_string(x);
1327  return s.good_bit();
1328 }
1329 
1330 ACE_INLINE bool
1332 {
1333  s.read_string(x);
1334  return s.good_bit();
1335 }
1336 
1337 #ifdef NONNATIVE_LONGDOUBLE
1338 ACE_INLINE bool
1339 operator>>(Serializer& s, long double& x)
1340 {
1341  if (!s.align_r(float128_cdr_size)) {
1342  return false;
1343  }
1345  if (s >> ld) {
1346  x = ld;
1347  return true;
1348  }
1349  return false;
1350 }
1351 #endif
1352 
1353 ACE_INLINE bool
1355 {
1356  s.buffer_read(reinterpret_cast<char*>(&x.ref_), boolean_cdr_size, s.swap_bytes());
1357  return s.good_bit();
1358 }
1359 
1360 ACE_INLINE bool
1362 {
1363  s.buffer_read(reinterpret_cast<char*>(&x.ref_), char8_cdr_size, s.swap_bytes());
1364  return s.good_bit();
1365 }
1366 
1367 ACE_INLINE bool
1369 {
1370  if (!s.align_r(char16_cdr_size)) {
1371  return false;
1372  }
1373 #if ACE_SIZEOF_WCHAR == 2
1374  s.buffer_read(reinterpret_cast<char*>(&x.ref_), char16_cdr_size,
1375  s.swap_bytes());
1376 #else
1377  ACE_UINT16 as_utf16;
1378  s.buffer_read(reinterpret_cast<char*>(&as_utf16), char16_cdr_size,
1379  s.swap_bytes());
1380  x.ref_ = as_utf16;
1381 #endif
1382  return s.good_bit();
1383 }
1384 
1385 ACE_INLINE bool
1387 {
1388  s.buffer_read(reinterpret_cast<char*>(&x.ref_), byte_cdr_size, false);
1389  return s.good_bit();
1390 }
1391 
1392 ACE_INLINE bool
1394 {
1395  const size_t length = s.read_string(const_cast<char*&>(x.val_));
1396  if (s.good_bit() && (x.bound_ != 0) && (length > x.bound_)) {
1398  return false;
1399  }
1400  return s.good_bit();
1401 }
1402 
1403 ACE_INLINE bool
1405 {
1406  const size_t length = s.read_string(const_cast<ACE_CDR::WChar*&>(x.val_));
1407  if (s.good_bit() && (x.bound_ != 0) && (length > x.bound_)) {
1409  return false;
1410  }
1411  return s.good_bit();
1412 }
1413 
1414 #if OPENDDS_HAS_EXPLICIT_INTS
1415 ACE_INLINE
1417 {
1418  s.buffer_read(reinterpret_cast<char*>(&x.ref_), uint8_cdr_size, false);
1419  return s.good_bit();
1420 }
1421 
1422 ACE_INLINE
1424 {
1425  s.buffer_read(reinterpret_cast<char*>(&x.ref_), int8_cdr_size, false);
1426  return s.good_bit();
1427 }
1428 #endif
1429 
1430 ACE_INLINE bool
1432 {
1433  char* buf = 0;
1434  const size_t length = s.read_string(buf);
1435  if (!s.good_bit()) {
1436  return false;
1437  }
1438  x.assign(buf, length);
1439  s.free_string(buf);
1440  return true;
1441 }
1442 
1443 ACE_INLINE bool
1445 {
1446  if (s >> x.str_) {
1447  if ((x.bound_ != 0) && (x.str_.size() > x.bound_)) {
1449  return false;
1450  }
1451  return true;
1452  }
1453  return false;
1454 }
1455 
1456 #ifdef DDS_HAS_WCHAR
1457 ACE_INLINE bool
1459 {
1460  ACE_CDR::WChar* buf = 0;
1461  const size_t length = s.read_string(buf);
1462  if (!s.good_bit()) {
1463  return false;
1464  }
1465  x.assign(buf, length);
1466  s.free_string(buf);
1467  return true;
1468 }
1469 
1470 ACE_INLINE bool
1472 {
1473  if (s >> x.str_) {
1474  if ((x.bound_ != 0) && (x.str_.size() > x.bound_)) {
1476  return false;
1477  }
1478  return true;
1479  }
1480  return false;
1481 }
1482 #endif /* DDS_HAS_WCHAR */
1483 
1484 //----------------------------------------------------------------------------
1485 // predefined type methods
1486 
1487 ACE_INLINE
1489  const Encoding& encoding, size_t& size,
1490  const ACE_CDR::Short& /*value*/, size_t count)
1491 {
1492  encoding.align(size, int16_cdr_size);
1493  size += int16_cdr_size * count;
1494  return true;
1495 }
1496 
1497 ACE_INLINE
1499  const Encoding& encoding, size_t& size,
1500  const ACE_CDR::UShort& /*value*/, size_t count)
1501 {
1502  encoding.align(size, uint16_cdr_size);
1503  size += uint16_cdr_size * count;
1504  return true;
1505 }
1506 
1507 ACE_INLINE
1509  const Encoding& encoding, size_t& size,
1510  const ACE_CDR::Long& /*value*/, size_t count)
1511 {
1512  encoding.align(size, int32_cdr_size);
1513  size += int32_cdr_size * count;
1514  return true;
1515 }
1516 
1517 ACE_INLINE
1519  const Encoding& encoding, size_t& size,
1520  const ACE_CDR::ULong& /*value*/, size_t count)
1521 {
1522  encoding.align(size, uint32_cdr_size);
1523  size += uint32_cdr_size * count;
1524  return true;
1525 }
1526 
1527 ACE_INLINE
1529  const Encoding& encoding, size_t& size,
1530  const ACE_CDR::LongLong& /*value*/, size_t count)
1531 {
1532  encoding.align(size, int64_cdr_size);
1533  size += int64_cdr_size * count;
1534  return true;
1535 }
1536 
1537 ACE_INLINE
1539  const Encoding& encoding, size_t& size,
1540  const ACE_CDR::ULongLong& /*value*/, size_t count)
1541 {
1542  encoding.align(size, uint64_cdr_size);
1543  size += uint64_cdr_size * count;
1544  return true;
1545 }
1546 
1547 ACE_INLINE
1549  const Encoding& encoding, size_t& size,
1550  const ACE_CDR::Float& /*value*/, size_t count)
1551 {
1552  encoding.align(size, float32_cdr_size);
1553  size += float32_cdr_size * count;
1554  return true;
1555 }
1556 
1557 ACE_INLINE
1559  const Encoding& encoding, size_t& size,
1560  const ACE_CDR::Double& /*value*/, size_t count)
1561 {
1562  encoding.align(size, float64_cdr_size);
1563  size += float64_cdr_size * count;
1564  return true;
1565 }
1566 
1567 ACE_INLINE
1569  const Encoding& encoding, size_t& size,
1570  const ACE_CDR::LongDouble& /*value*/, size_t count)
1571 {
1572  encoding.align(size, float128_cdr_size);
1573  size += float128_cdr_size * count;
1574  return true;
1575 }
1576 
1577 // predefined type method disambiguators.
1578 ACE_INLINE
1580  const Encoding& /*encoding*/, size_t& size,
1581  const ACE_OutputCDR::from_boolean /*value*/, size_t count)
1582 {
1583  size += boolean_cdr_size * count;
1584  return true;
1585 }
1586 
1587 ACE_INLINE
1589  const Encoding& /*encoding*/, size_t& size,
1590  const ACE_OutputCDR::from_char /*value*/, size_t count)
1591 {
1592  size += char8_cdr_size * count;
1593  return true;
1594 }
1595 
1596 ACE_INLINE
1598  const Encoding& encoding, size_t& size,
1599  const ACE_OutputCDR::from_wchar /*value*/, size_t count)
1600 {
1601  encoding.align(size, char16_cdr_size);
1602  size += char16_cdr_size * count;
1603  return true;
1604 }
1605 
1606 ACE_INLINE
1608  const Encoding& /*encoding*/, size_t& size,
1609  const ACE_OutputCDR::from_octet /*value*/, size_t count)
1610 {
1611  size += byte_cdr_size * count;
1612  return true;
1613 }
1614 
1615 #if OPENDDS_HAS_EXPLICIT_INTS
1616 ACE_INLINE
1618  const Encoding& /*encoding*/, size_t& size,
1619  const ACE_OutputCDR::from_uint8 /*value*/, size_t count)
1620 {
1621  size += uint8_cdr_size * count;
1622  return true;
1623 }
1624 
1625 ACE_INLINE
1627  const Encoding& /*encoding*/, size_t& size,
1628  const ACE_OutputCDR::from_int8 /*value*/, size_t count)
1629 {
1630  size += int8_cdr_size * count;
1631  return true;
1632 }
1633 #endif
1634 
1635 // predefined type method explicit disambiguators.
1636 
1637 ACE_INLINE
1638 void primitive_serialized_size_boolean(const Encoding& /*encoding*/, size_t& size,
1639  size_t count)
1640 {
1641  size += boolean_cdr_size * count;
1642 }
1643 
1644 ACE_INLINE
1645 void primitive_serialized_size_char(const Encoding& /*encoding*/, size_t& size,
1646  size_t count)
1647 {
1648  size += char8_cdr_size * count;
1649 }
1650 
1651 ACE_INLINE
1653  size_t count)
1654 {
1655  encoding.align(size, char16_cdr_size);
1656  size += char16_cdr_size * count;
1657 }
1658 
1659 ACE_INLINE
1660 void primitive_serialized_size_octet(const Encoding& /*encoding*/, size_t& size,
1661  size_t count)
1662 {
1663  size += byte_cdr_size * count;
1664 }
1665 
1666 ACE_INLINE
1668  size_t count)
1669 {
1670  encoding.align(size, uint32_cdr_size);
1671  size += uint32_cdr_size * count;
1672 }
1673 
1674 #if OPENDDS_HAS_EXPLICIT_INTS
1675 ACE_INLINE
1676 void primitive_serialized_size_uint8(const Encoding& /*encoding*/, size_t& size,
1677  size_t count)
1678 {
1679  size += uint8_cdr_size * count;
1680 }
1681 
1682 ACE_INLINE
1683 void primitive_serialized_size_int8(const Encoding& /*encoding*/, size_t& size,
1684  size_t count)
1685 {
1686  size += int8_cdr_size * count;
1687 }
1688 #endif
1689 
1690 ACE_INLINE
1691 void serialized_size_delimiter(const Encoding& encoding, size_t& size)
1692 {
1693  if (encoding.xcdr_version() == Encoding::XCDR_VERSION_2) {
1694  primitive_serialized_size_ulong(encoding, size);
1695  }
1696 }
1697 
1698 ACE_INLINE
1700  const Encoding& encoding, size_t& size, size_t& running_size)
1701 {
1702  const Encoding::XcdrVersion xcdr = encoding.xcdr_version();
1703  if (xcdr == Encoding::XCDR_VERSION_1) {
1704  encoding.align(size, xcdr1_pid_alignment);
1705  size += uint16_cdr_size * 2;
1706  // TODO(iguessthislldo): Extended PID
1707 
1708  // Save and Zero Size to Reset the Alignment
1709  running_size += size;
1710  size = 0;
1711  } else if (xcdr == Encoding::XCDR_VERSION_2) {
1712  if (running_size != 0 && size != 1 && size != 2 && size != 4 && size != 8) {
1713  size += uint32_cdr_size; // nextint
1714  }
1715  encoding.align(size, uint32_cdr_size);
1716  size += uint32_cdr_size; // emheader
1717  running_size += size;
1718  size = 0;
1719  }
1720 }
1721 
1722 ACE_INLINE
1724  const Encoding& encoding, size_t& size, size_t& running_size)
1725 {
1726  if (encoding.xcdr_version() == Encoding::XCDR_VERSION_1) {
1727  /*
1728  * TODO(iguessthislldo): See how DDSXTY14-23 is resolved.
1729  * https://github.com/OpenDDS/OpenDDS/pull/1722#discussion_r447165924
1730  */
1731  encoding.align(size, xcdr1_pid_alignment);
1732  size += uint16_cdr_size * 2;
1733 
1734  // Restore Saved Totals from Alignment Resets
1735  size += running_size;
1736  } else if (encoding.xcdr_version() == Encoding::XCDR_VERSION_2) {
1737  if (running_size != 0 && size != 1 && size != 2 && size != 4 && size != 8) {
1738  size += uint32_cdr_size; // nextint
1739  }
1740  size += running_size;
1741  }
1742 }
1743 
1744 ACE_INLINE
1746 {
1747  return construction_status_;
1748 }
1749 
1750 ACE_INLINE
1752 {
1753  construction_status_ = cs;
1754 }
1755 
1756 ACE_INLINE
1758 {
1759  RdState state(align_rshift_, rpos_);
1760  return state;
1761 }
1762 
1763 ACE_INLINE
1765 {
1766  align_rshift_ = state.align_rshift;
1767  rpos_ = state.rpos;
1768 }
1769 
1770 } // namespace DCPS
1771 } // namespace OpenDDS
1772 
ACE_Byte Octet
bool write_char_array(const ACE_CDR::Char *x, ACE_CDR::ULong length)
Definition: Serializer.inl:679
bool read_boolean_array(ACE_CDR::Boolean *x, ACE_CDR::ULong length)
Definition: Serializer.inl:533
bool read_delimiter(size_t &size)
Definition: Serializer.inl:912
const size_t boolean_cdr_size
Definition: Serializer.h:89
Align for CDR and XCDR1.
Definition: Serializer.h:141
void swap(MessageBlock &lhs, MessageBlock &rhs)
const ACE_CDR::WChar *& val_
std::wstring WString
void buffer_write(const char *src, size_t size, bool swap)
Write to the chain from a source buffer.
Definition: Serializer.inl:393
#define ACE_ERROR(X)
const size_t int8_cdr_size
Definition: Serializer.h:91
ACE_INT64 LongLong
const LogLevel::Value value
Definition: debug.cpp:61
bool read_long_array(ACE_CDR::Long *x, ACE_CDR::ULong length)
Definition: Serializer.inl:601
const size_t uint64_cdr_size
Definition: Serializer.h:98
std::string String
ACE_CDR::Octet & ref_
OpenDDS_Dcps_Export void primitive_serialized_size_ulong(const Encoding &encoding, size_t &size, size_t count=1)
const size_t int64_cdr_size
Definition: Serializer.h:97
Alignment alignment() const
Definition: Serializer.inl:76
bool skip(size_t n, int size=1)
Definition: Serializer.inl:443
bool write_ulonglong_array(const ACE_CDR::ULongLong *x, ACE_CDR::ULong length)
Definition: Serializer.inl:771
bool is_encapsulated() const
Definition: Serializer.inl:155
YARD is all original work While it may rely on standard YARD does not include code from other sources We have chosen to release our work as public domain code This means that YARD has been released outside the copyright system Feel free to use the code in any way you wish especially in an academic plagiarism has very little to do with copyright In an academic or in any situation where you are expected to give credit to other people s you will need to cite YARD as a source The author is Christopher and the appropriate date is December the release date for we can t make any promises regarding whether YARD will do what you or whether we will make any changes you ask for You are free to hire your own expert for that If you choose to distribute YARD you ll probably want to read up on the laws covering warranties in your state
Definition: COPYING.txt:14
Encoding::Alignment alignment() const
Definition: Serializer.inl:417
bool read_longdouble_array(ACE_CDR::LongDouble *x, ACE_CDR::ULong length)
Definition: Serializer.inl:661
OpenDDS_Dcps_Export void serialized_size_delimiter(const Encoding &encoding, size_t &size)
Add delimiter to the size of a serialized size if the encoding has them.
Endianness endianness() const
Definition: Serializer.inl:64
bool read_longlong_array(ACE_CDR::LongLong *x, ACE_CDR::ULong length)
Definition: Serializer.inl:621
ACE_UINT64 ULongLong
OpenDDS_Dcps_Export void primitive_serialized_size_octet(const Encoding &encoding, size_t &size, size_t count=1)
const size_t float64_cdr_size
Definition: Serializer.h:100
bool write_longlong_array(const ACE_CDR::LongLong *x, ACE_CDR::ULong length)
Definition: Serializer.inl:760
const size_t int16_cdr_size
Definition: Serializer.h:93
bool read_octet_array(ACE_CDR::Octet *x, ACE_CDR::ULong length)
Definition: Serializer.inl:558
bool read_ushort_array(ACE_CDR::UShort *x, ACE_CDR::ULong length)
Definition: Serializer.inl:591
void serialized_size(const Encoding &encoding, size_t &size, const SequenceNumber &)
bool write_wchar_array(const ACE_CDR::WChar *x, ACE_CDR::ULong length)
Definition: Serializer.inl:686
const size_t uint32_cdr_size
Definition: Serializer.h:96
bool read_ulonglong_array(ACE_CDR::ULongLong *x, ACE_CDR::ULong length)
Definition: Serializer.inl:631
size_t strlen(const char *s)
bool read_short_array(ACE_CDR::Short *x, ACE_CDR::ULong length)
Definition: Serializer.inl:581
const size_t float32_cdr_size
Definition: Serializer.h:99
bool write_octet_array(const ACE_CDR::Octet *x, ACE_CDR::ULong length)
Definition: Serializer.inl:697
bool write_short_array(const ACE_CDR::Short *x, ACE_CDR::ULong length)
Definition: Serializer.inl:720
OpenDDS_Dcps_Export void primitive_serialized_size_char(const Encoding &encoding, size_t &size, size_t count=1)
ACE_INT16 Short
bool write_long_array(const ACE_CDR::Long *x, ACE_CDR::ULong length)
Definition: Serializer.inl:740
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
Class to serialize and deserialize data for DDS.
Definition: Serializer.h:369
ACE_CDR::Boolean operator<<(Serializer &serializer, CoherentChangeControl &value)
Marshal/Insertion into a buffer.
const size_t xcdr1_pid_alignment
Definition: Serializer.h:104
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
OpenDDS_Dcps_Export void primitive_serialized_size_wchar(const Encoding &encoding, size_t &size, size_t count=1)
const size_t char8_cdr_size
Definition: Serializer.h:102
char Char
Endianness endianness() const
Definition: Serializer.inl:220
size_t doread(char *dest, size_t size, bool swap, size_t offset)
Implementation of the actual read from the chain.
Definition: Serializer.inl:229
size_t dowrite(const char *dest, size_t size, bool swap, size_t offset)
Implementation of the actual write to the chain.
Definition: Serializer.inl:318
ACE_UINT16 UShort
ACE_CDR::Char & ref_
bool align_r(size_t alignment)
Definition: Serializer.inl:813
const size_t uint8_cdr_size
Definition: Serializer.h:92
bool read_ulong_array(ACE_CDR::ULong *x, ACE_CDR::ULong length)
Definition: Serializer.inl:611
bool skip_sequence_dheader() const
Definition: Serializer.inl:100
size_t read_string(ACE_CDR::Char *&dest, StrAllocate str_alloc=0, StrFree str_free=0)
Definition: Serializer.cpp:520
ACE_UINT32 ULong
bool read_char_array(ACE_CDR::Char *x, ACE_CDR::ULong length)
Definition: Serializer.inl:540
bool write_boolean_array(const ACE_CDR::Boolean *x, ACE_CDR::ULong length)
Definition: Serializer.inl:671
bool write_double_array(const ACE_CDR::Double *x, ACE_CDR::ULong length)
Definition: Serializer.inl:792
OpenDDS_Dcps_Export void align(size_t &value, size_t by)
Align "value" by "by" if it&#39;s not already.
Definition: Serializer.inl:23
const size_t int32_cdr_size
Definition: Serializer.h:95
void align_cont_w()
Update alignment state when a cont() chain is followed during a write.
Definition: Serializer.inl:889
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
#define ACE_CDR_LONG_DOUBLE_ASSIGNMENT(LHS, RHS)
ACE_TEXT("TCP_Factory")
OpenDDS_Dcps_Export void serialized_size_parameter_id(const Encoding &encoding, size_t &size, size_t &running_size)
size_t max_align() const
Return the maximum alignment dictated by the alignment policy.
Definition: Serializer.inl:112
void align_cont_r()
Update alignment state when a cont() chain is followed during a read.
Definition: Serializer.inl:875
ACE_INT32 Long
XcdrVersion xcdr_version() const
Definition: Serializer.inl:127
bool read_float_array(ACE_CDR::Float *x, ACE_CDR::ULong length)
Definition: Serializer.inl:641
ConstructionStatus get_construction_status() const
void swap_bytes(bool do_swap)
Definition: Serializer.inl:403
bool zero_init_padding() const
Definition: Serializer.inl:88
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
ACE_CDR::UInt8 & ref_
bool write_ulong_array(const ACE_CDR::ULong *x, ACE_CDR::ULong length)
Definition: Serializer.inl:750
const size_t char16_cdr_size
Definition: Serializer.h:103
bool align_w(size_t alignment)
Definition: Serializer.inl:830
ACE_CDR::Int8 & ref_
const Encoding & encoding() const
Definition: Serializer.inl:199
ACE_CDR::WChar & ref_
ACE_INT8 Int8
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
void set_construction_status(ConstructionStatus cs)
ACE_CDR::Boolean operator>>(Serializer &serializer, CoherentChangeControl &value)
const size_t uint16_cdr_size
Definition: Serializer.h:94
void free_string(ACE_CDR::Char *str, StrFree str_free=0)
Definition: Serializer.cpp:589
bool write_ushort_array(const ACE_CDR::UShort *x, ACE_CDR::ULong length)
Definition: Serializer.inl:730
static unsigned char offset(char *index, size_t start, size_t align)
Definition: Serializer.inl:869
ACE_CDR::Boolean & ref_
#define ACE_INLINE
ACE_WCHAR_T WChar
void buffer_read(char *dest, size_t size, bool swap)
Read from the chain into a destination buffer.
Definition: Serializer.inl:305
const DCPS::Encoding encoding(DCPS::Encoding::KIND_UNALIGNED_CDR, DCPS::ENDIAN_BIG)
void write_array(const char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:502
bool read_double_array(ACE_CDR::Double *x, ACE_CDR::ULong length)
Definition: Serializer.inl:651
const size_t byte_cdr_size
Definition: Serializer.h:90
bool Boolean
LM_ERROR
bool write_delimiter(size_t size)
Definition: Serializer.inl:925
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
OpenDDS_Dcps_Export void serialized_size_list_end_parameter_id(const Encoding &encoding, size_t &size, size_t &running_size)
static const size_t serialized_size
Definition: Serializer.h:251
OpenDDS_Dcps_Export void primitive_serialized_size_boolean(const Encoding &encoding, size_t &size, size_t count=1)
ACE_UINT8 UInt8
bool write_float_array(const ACE_CDR::Float *x, ACE_CDR::ULong length)
Definition: Serializer.inl:782
const size_t float128_cdr_size
Definition: Serializer.h:101
XcdrVersion xcdr_version_
Definition: Serializer.h:218
bool read_wchar_array(ACE_CDR::WChar *x, ACE_CDR::ULong length)
Definition: Serializer.inl:547
void align(size_t &value, size_t by=(std::numeric_limits< size_t >::max)()) const
Align "value" to "by" and according to the stream&#39;s alignment.
Definition: Serializer.inl:118
OpenDDS_Dcps_Export bool primitive_serialized_size(const Encoding &encoding, size_t &size, const ACE_CDR::Short &value, size_t count=1)
const ACE_CDR::Char *& val_
ACE_CDR::ULong bound_
bool write_longdouble_array(const ACE_CDR::LongDouble *x, ACE_CDR::ULong length)
Definition: Serializer.inl:802
const Encoding & encoding_