OpenDDS  Snapshot(2023/04/28-20:55)
Serializer.cpp
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 <DCPS/DdsDcps_pch.h> // Only the _pch include should start with DCPS/
7 
8 #include "Serializer.h"
9 
10 #if !defined (__ACE_INLINE__)
11 # include "Serializer.inl"
12 #endif /* !__ACE_INLINE__ */
13 
14 #include "SafetyProfileStreams.h"
15 
16 #ifndef OPENDDS_UTIL_BUILD
17 # include <tao/String_Alloc.h>
18 #endif
19 
20 #include <ace/OS_NS_string.h>
21 #include <ace/OS_Memory.h>
22 #include <ace/Log_Msg.h>
23 
24 #include <cstdlib>
25 
27 
28 namespace OpenDDS {
29 namespace DCPS {
30 
31 #ifdef OPENDDS_UTIL_BUILD
32 namespace {
33 
35 {
36  return static_cast<ACE_CDR::Char*>(std::malloc(size + 1));
37 }
38 
39 void string_free(ACE_CDR::Char* ptr)
40 {
41  std::free(ptr);
42 }
43 
45 {
46  return static_cast<ACE_CDR::WChar*>(std::malloc(sizeof(ACE_CDR::WChar) * (size + 1)));
47 }
48 
50 {
51  std::free(ptr);
52 }
53 
54 }
55 #endif
56 
58 {
59  switch (endianness) {
60  case ENDIAN_BIG:
61  return "big-endian ("
62 #ifdef ACE_LITTLE_ENDIAN
63  "non-"
64 #endif
65  "native)";
66  case ENDIAN_LITTLE:
67  return "little-endian ("
68 #ifndef ACE_LITTLE_ENDIAN
69  "non-"
70 #endif
71  "native)";
72  default:
73  return "invalid endianness";
74  }
75 }
76 
78  : endianness_(ENDIAN_NATIVE)
79  , skip_sequence_dheader_(false)
80 {
82 }
83 
85  : endianness_(endianness)
86  , skip_sequence_dheader_(false)
87 {
88  kind(k);
89 }
90 
91 Encoding::Encoding(Kind k, bool swap_bytes)
93  , skip_sequence_dheader_(false)
94 {
95  kind(k);
96 }
97 
99  : kind_(kind)
100  , options_(options)
101 {
102 }
103 
106  , options_(options)
107 {
108  if (!from_encoding(enc, ext)) {
110  }
111 }
112 
115 {
116  const bool big = encoding.endianness() == ENDIAN_BIG;
117  switch (encoding.kind()) {
119  switch (extensibility) {
120  case FINAL:
121  case APPENDABLE:
122  kind_ = big ? KIND_CDR_BE : KIND_CDR_LE;
123  break;
124  case MUTABLE:
126  break;
127  }
128  break;
130  switch (extensibility) {
131  case FINAL:
132  kind_ = big ? KIND_CDR2_BE : KIND_CDR2_LE;
133  break;
134  case APPENDABLE:
136  break;
137  case MUTABLE:
139  break;
140  }
141  break;
142  default:
143  if (log_level >= LogLevel::Error) {
144  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: EncapsulationHeader::from_encoding: "
145  "Got Encoding With Unsupported Kind: %C\n",
146  Encoding::kind_to_string(encoding.kind()).c_str()));
147  }
148  return false;
149  }
150  return true;
151 }
152 
154  Encoding& encoding, Extensibility expected_extensibility)
155 {
156  return to_encoding_i(encoding, &expected_extensibility);
157 }
158 
160 {
161  return to_encoding_i(encoding, 0);
162 }
163 
165  Encoding& encoding, Extensibility* expected_extensibility_ptr)
166 {
167  Extensibility expected_extensibility = expected_extensibility_ptr ?
168  *expected_extensibility_ptr : FINAL; // Placeholder, doesn't matter
169  bool wrong_extensibility = true;
170  switch (kind_) {
171  case KIND_CDR_BE:
172  encoding.kind(Encoding::KIND_XCDR1);
173  encoding.endianness(ENDIAN_BIG);
174  wrong_extensibility = expected_extensibility == MUTABLE;
175  break;
176 
177  case KIND_CDR_LE:
178  encoding.kind(Encoding::KIND_XCDR1);
179  encoding.endianness(ENDIAN_LITTLE);
180  wrong_extensibility = expected_extensibility == MUTABLE;
181  break;
182 
183  case KIND_PL_CDR_BE:
184  encoding.kind(Encoding::KIND_XCDR1);
185  encoding.endianness(ENDIAN_BIG);
186  wrong_extensibility = expected_extensibility != MUTABLE;
187  break;
188 
189  case KIND_PL_CDR_LE:
190  encoding.kind(Encoding::KIND_XCDR1);
191  encoding.endianness(ENDIAN_LITTLE);
192  wrong_extensibility = expected_extensibility != MUTABLE;
193  break;
194 
195  case KIND_CDR2_BE:
196  encoding.kind(Encoding::KIND_XCDR2);
197  encoding.endianness(ENDIAN_BIG);
198  wrong_extensibility = expected_extensibility != FINAL;
199  break;
200 
201  case KIND_CDR2_LE:
202  encoding.kind(Encoding::KIND_XCDR2);
203  encoding.endianness(ENDIAN_LITTLE);
204  wrong_extensibility = expected_extensibility != FINAL;
205  break;
206 
207  case KIND_D_CDR2_BE:
208  encoding.kind(Encoding::KIND_XCDR2);
209  encoding.endianness(ENDIAN_BIG);
210  wrong_extensibility = expected_extensibility != APPENDABLE;
211  break;
212 
213  case KIND_D_CDR2_LE:
214  encoding.kind(Encoding::KIND_XCDR2);
215  encoding.endianness(ENDIAN_LITTLE);
216  wrong_extensibility = expected_extensibility != APPENDABLE;
217  break;
218 
219  case KIND_PL_CDR2_BE:
220  encoding.kind(Encoding::KIND_XCDR2);
221  encoding.endianness(ENDIAN_BIG);
222  wrong_extensibility = expected_extensibility != MUTABLE;
223  break;
224 
225  case KIND_PL_CDR2_LE:
226  encoding.kind(Encoding::KIND_XCDR2);
227  encoding.endianness(ENDIAN_LITTLE);
228  wrong_extensibility = expected_extensibility != MUTABLE;
229  break;
230 
231  default:
232  if (log_level >= LogLevel::Error) {
233  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: EncapsulationHeader::to_encoding: "
234  "Unsupported Encoding: %C\n", to_string().c_str()));
235  }
236  return false;
237  }
238 
239  if (expected_extensibility_ptr && wrong_extensibility) {
240  if (log_level >= LogLevel::Error) {
241  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: EncapsulationHeader::to_encoding: "
242  "expected %C extensibility, but got %C\n",
243  ext_to_string(*expected_extensibility_ptr), to_string().c_str()));
244  }
245  return false;
246  }
247 
248  return true;
249 }
250 
252 {
253  if (mb->length() < padding_marker_byte_index + 1) {
254  if (log_level >= LogLevel::Error) {
255  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: EncapsulationHeader::set_encapsulation_options: "
256  "Insufficient buffer size %B\n", mb->length()));
257  }
258  return false;
259  }
260 
262  return true;
263 }
264 
266 {
267  switch (kind_) {
268  case KIND_CDR_BE:
269  return "CDR/XCDR1 Big Endian Plain";
270  case KIND_CDR_LE:
271  return "CDR/XCDR1 Little Endian Plain";
272  case KIND_PL_CDR_BE:
273  return "CDR/XCDR1 Big Endian Parameter List";
274  case KIND_PL_CDR_LE:
275  return "CDR/XCDR1 Little Endian Parameter List";
276  case KIND_CDR2_BE:
277  return "XCDR2 Big Endian Plain";
278  case KIND_CDR2_LE:
279  return "XCDR2 Little Endian Plain";
280  case KIND_D_CDR2_BE:
281  return "XCDR2 Big Endian Delimited";
282  case KIND_D_CDR2_LE:
283  return "XCDR2 Little Endian Delimited";
284  case KIND_PL_CDR2_BE:
285  return "XCDR2 Big Endian Parameter List";
286  case KIND_PL_CDR2_LE:
287  return "XCDR2 Little Endian Parameter List";
288  case KIND_XML:
289  return "XML";
290  case KIND_INVALID:
291  return "Invalid";
292  default:
293  return "Unknown: " + to_dds_string(static_cast<unsigned>(kind_), true);
294  }
295 }
296 
298 {
301  return false;
302  }
303  value.kind(static_cast<EncapsulationHeader::Kind>(
304  (static_cast<ACE_UINT16>(data[0]) << 8) | data[1]));
305  value.options((static_cast<ACE_UINT16>(data[2]) << 8) | data[3]);
306  s.reset_alignment();
307  return true;
308 }
309 
311 {
312  if (!value.is_good()) {
313  return false;
314  }
316  data[0] = (value.kind() >> 8) & 0xff;
317  data[1] = value.kind() & 0xff;
318  data[2] = (value.options() >> 8) & 0xff;
319  data[3] = value.options() & 0xff;
320  const bool ok = s.write_octet_array(&data[0],
322  s.reset_alignment();
323  return ok;
324 }
325 
327 {
328  switch (value) {
329  case KIND_XCDR1:
330  return "CDR/XCDR1";
331  case KIND_XCDR2:
332  return "XCDR2";
333  case KIND_UNALIGNED_CDR:
334  return "Unaligned CDR";
335  default:
336  return "Unknown: " + to_dds_string(static_cast<unsigned>(value), true);
337  }
338 }
339 
341 {
343  endianness_to_string(endianness_);
344  if (!zero_init_padding_) {
345  rv += ", non-initialized padding";
346  }
347  return rv;
348 }
349 
350 const char Serializer::ALIGN_PAD[] = {0};
351 
353  : current_(chain)
354  , good_bit_(true)
355  , construction_status_(ConstructionSuccessful)
356  , align_rshift_(0)
357  , align_wshift_(0)
358  , rpos_(0)
359  , wpos_(0)
360 {
361  encoding(enc);
362  reset_alignment();
363 }
364 
367  : current_(chain)
368  , good_bit_(true)
370  , align_rshift_(0)
371  , align_wshift_(0)
372  , rpos_(0)
373  , wpos_(0)
374 {
375  encoding(Encoding(kind, endianness));
376  reset_alignment();
377 }
378 
380  Encoding::Kind kind, bool swap_bytes)
381  : current_(chain)
382  , good_bit_(true)
384  , align_rshift_(0)
385  , align_wshift_(0)
386  , rpos_(0)
387  , wpos_(0)
388 {
389  encoding(Encoding(kind, swap_bytes));
390  reset_alignment();
391 }
392 
394 {
395 }
396 
398  : ser_(ser)
399  , max_align_(ser.encoding().max_align())
400  , start_rpos_(ser.rpos())
401  , rblock_(max_align_ ? (ptrdiff_t(ser.current_->rd_ptr()) - ser.align_rshift_) % max_align_ : 0)
402  , min_read_(min_read)
403  , start_wpos_(ser.wpos())
404  , wblock_(max_align_ ? (ptrdiff_t(ser.current_->wr_ptr()) - ser.align_wshift_) % max_align_ : 0)
405 {
407 }
408 
409 void
411 {
412  if (min_read_ != 0 && (ser.rpos() - start_rpos_) < min_read_) {
413  ser.skip(min_read_ - (ser.rpos() - start_rpos_));
414  }
415 
416  if (ser.current_ && max_align_) {
419  }
420 }
421 
422 bool
424 {
425  // save
426  const size_t rpos = rpos_;
427  const unsigned char align_rshift = align_rshift_;
429 
430  // read
431  if (!peek_helper(current_, 2 * uint32_cdr_size, t)) {
432  return false;
433  }
434 
435  // reset
436  current_ = current;
437  align_rshift_ = align_rshift;
438  rpos_ = rpos;
439  return true;
440 }
441 
442 void
444 {
445  const ptrdiff_t align = encoding().max_align();
446  if (current_ && align) {
449  }
450 }
451 
452 void
453 Serializer::smemcpy(char* to, const char* from, size_t n)
454 {
455  OPENDDS_ASSERT(from);
456  (void) ACE_OS::memcpy(to, from, n);
457 }
458 
459 void
460 Serializer::swapcpy(char* to, const char* from, size_t n)
461 {
462  // Unroll the loop...
463  switch (n) { // 2 4 8 16
464  case 16:
465  to[ 15] = from[ n - 16]; // x x x 0
466  // fallthrough
467  case 15:
468  to[ 14] = from[ n - 15]; // x x x 1
469  // fallthrough
470  case 14:
471  to[ 13] = from[ n - 14]; // x x x 2
472  // fallthrough
473  case 13:
474  to[ 12] = from[ n - 13]; // x x x 3
475  // fallthrough
476  case 12:
477  to[ 11] = from[ n - 12]; // x x x 4
478  // fallthrough
479  case 11:
480  to[ 10] = from[ n - 11]; // x x x 5
481  // fallthrough
482  case 10:
483  to[ 9] = from[ n - 10]; // x x x 6
484  // fallthrough
485  case 9:
486  to[ 8] = from[ n - 9]; // x x x 7
487  // fallthrough
488  case 8:
489  to[ 7] = from[ n - 8]; // x x 0 8
490  // fallthrough
491  case 7:
492  to[ 6] = from[ n - 7]; // x x 1 9
493  // fallthrough
494  case 6:
495  to[ 5] = from[ n - 6]; // x x 2 10
496  // fallthrough
497  case 5:
498  to[ 4] = from[ n - 5]; // x x 3 11
499  // fallthrough
500  case 4:
501  to[ 3] = from[ n - 4]; // x 0 4 12
502  // fallthrough
503  case 3:
504  to[ 2] = from[ n - 3]; // x 1 5 13
505  // fallthrough
506  case 2:
507  to[ 1] = from[ n - 2]; // 0 2 6 14
508  // fallthrough
509  case 1:
510  to[ 0] = from[ n - 1]; // 1 3 7 15
511  // fallthrough
512  case 0:
513  return;
514  default:
515  good_bit_ = false;
516  }
517 }
518 
519 size_t
521  StrAllocate str_alloc,
522  StrFree str_free)
523 {
524  if (str_alloc == 0) {
525 #ifdef OPENDDS_UTIL_BUILD
526  str_alloc = string_alloc;
527 #else
528  str_alloc = CORBA::string_alloc;
529 #endif
530  }
531 
532  //
533  // Ensure no bad values leave the routine.
534  //
535  free_string(dest, str_free);
536  dest = 0;
537 
538  //
539  // Extract the string length.
540  //
541  ACE_CDR::ULong length; // includes the null
542  if (!(*this >> length)) {
543  return 0;
544  }
545 
546  if (length == 0) {
547  // not legal CDR, but we need to accept it since other implementations may generate this
548  dest = str_alloc(0);
549  return 0;
550  }
551 
552  //
553  // NOTE: Maintain the ACE implementation where the length check is
554  // done here before the allocation even though it will be
555  // checked during the actual read as well.
556  //
557  if (current_ && length <= current_->total_length()) {
558 
559  dest = str_alloc(length - 1);
560 
561  if (dest == 0) {
562  good_bit_ = false;
563 
564  } else {
565  //
566  // Extract the string.
567  //
568  read_char_array(dest, length);
569 
570  if (good_bit_ && dest[length - 1]) {
571  // If the last byte was not a 0 it's not a valid CDR string
572  good_bit_ = false;
573  }
574  }
575 
576  if (!good_bit_) {
577  free_string(dest, str_free);
578  dest = 0;
579  }
580 
581  } else {
582  good_bit_ = false;
583  }
584 
585  return length - 1;
586 }
587 
588 void
590  StrFree str_free)
591 {
592  if (str_free == 0) {
593 #ifdef OPENDDS_UTIL_BUILD
594  str_free = string_free;
595 #else
596  str_free = CORBA::string_free;
597 #endif
598  }
599  str_free(str);
600 }
601 
602 size_t
604  WStrAllocate str_alloc,
605  WStrFree str_free)
606 {
607  if (str_alloc == 0) {
608 #ifdef OPENDDS_UTIL_BUILD
609  str_alloc = wstring_alloc;
610 #else
611  str_alloc = CORBA::wstring_alloc;
612 #endif
613  }
614 
615  //
616  // Ensure no bad values leave the routine.
617  //
618  free_string(dest, str_free);
619  dest = 0;
620 
621  //
622  // Extract the string size.
623  //
624  ACE_CDR::ULong bytecount;
625  if (!(*this >> bytecount)) {
626  return 0;
627  }
628 
629  //
630  // NOTE: Maintain the ACE implementation where the length check is
631  // done here before the allocation even though it will be
632  // checked during the actual read as well.
633  //
635  if (current_ && bytecount <= current_->total_length()) {
636  length = bytecount / char16_cdr_size;
637  dest = str_alloc(length);
638 
639  if (dest == 0) {
640  good_bit_ = false;
641  return 0;
642  }
643 
644 #if ACE_SIZEOF_WCHAR == 2
645  read_array(reinterpret_cast<char*>(dest), char16_cdr_size, length, swap_bytes());
646 #else
647  for (size_t i = 0; i < length && good_bit_; ++i) {
648  ACE_UINT16 as_utf16;
649  buffer_read(reinterpret_cast<char*>(&as_utf16), char16_cdr_size, swap_bytes());
650  if (good_bit_) {
651  dest[i] = as_utf16;
652  }
653  }
654 #endif
655 
656  if (good_bit_) {
657  //
658  // Null terminate the string.
659  //
660  dest[length] = L'\0';
661  } else {
662  free_string(dest, str_free);
663  dest = 0;
664  length = 0;
665  }
666 
667  } else {
668  good_bit_ = false;
669  }
670 
671  return length;
672 }
673 
674 void
676  WStrFree str_free)
677 {
678  if (str_free == 0) {
679 #ifdef OPENDDS_UTIL_BUILD
680  str_free = wstring_free;
681 #else
682  str_free = CORBA::wstring_free;
683 #endif
684  }
685  str_free(str);
686 }
687 
689 {
690  if (!good_bit() || !current_ || n > length()) {
691  return 0;
692  }
694  ACE_Message_Block* i = dup.get();
695  for (size_t remain = n; i && remain; i = i->cont()) {
696  if (i->length() >= remain) {
697  i->wr_ptr(i->rd_ptr() + remain);
698  ACE_Message_Block::release(i->cont());
699  i->cont(0);
700  break;
701  }
702  remain -= i->length();
703  }
704  return dup.release();
705 }
706 
707 bool Serializer::read_parameter_id(unsigned& id, size_t& size, bool& must_understand)
708 {
710  if (xcdr == Encoding::XCDR_VERSION_1) {
711  // Get the "short" id and size
713  return false;
714  }
715  ACE_CDR::UShort pid;
716  if (!(*this >> pid)) {
717  return false;
718  }
719  const ACE_CDR::UShort short_id = pid & 0x3fff;
720  ACE_CDR::UShort short_size;
721  if (!(*this >> short_size)) {
722  return false;
723  }
724 
725  // TODO(iguessthislldo): handle PID flags
726  must_understand = false; // Placeholder
727 
728  // If extended, get the "long" id and size
729  if (short_id == pid_extended) {
730  ACE_CDR::ULong long_id, long_size;
731  if (!(*this >> long_id) || !(*this >> long_size)) {
732  return false;
733  }
734  const unsigned short_size_left = short_size - 8;
735  if (short_size_left) {
736  skip(short_size_left);
737  }
738  id = long_id;
739  size = long_size;
740  } else {
741  id = short_id;
742  size = short_size;
743  }
744 
745  reset_alignment();
746  } else if (xcdr == Encoding::XCDR_VERSION_2) {
747  ACE_CDR::ULong emheader;
748  if (!(*this >> emheader)) {
749  return false;
750  }
751 
752  must_understand = emheader & emheader_must_understand;
753 
754  // Get Size
755  const unsigned short lc = (emheader >> 28) & 0x7;
756  if (lc < 4) {
757  size = size_t(1) << lc;
758  } else {
759  ACE_CDR::ULong next_int;
760  if (lc == 4 ? !(*this >> next_int) : !peek(next_int)) {
761  return false;
762  }
763  switch (lc) {
764  case 4:
765  size = next_int;
766  break;
767  case 5:
768  size = uint32_cdr_size + next_int;
769  break;
770  case 6:
771  size = uint32_cdr_size + next_int * 4;
772  break;
773  case 7:
774  size = uint32_cdr_size + next_int * 8;
775  break;
776  }
777  }
778  id = emheader & 0xfffffff;
779  }
780 
781  return true;
782 }
783 
784 bool Serializer::write_parameter_id(const unsigned id, const size_t size, const bool must_understand)
785 {
786  if (static_cast<ACE_CDR::ULong>(id) > MEMBER_ID_MAX) {
787  return false;
788  }
789 
791  if (xcdr == Encoding::XCDR_VERSION_1) {
793  return false;
794  }
795 
796  // Determine if we need to use a short or long PID
797  const bool long_pid = id > (1 << 14) || size > (1 << 16);
798 
799  // Write the short part of the PID
800  /*
801  * TODO(iguessthislldo): Control when to use "must understand" and "impl
802  * extension"?
803  *
804  * The XTypes CDR rules seem to imply they're alway here but that doesn't
805  * sound quite right.
806  *
807  * Also see TODOs above and the TODO below.
808  */
809  const ACE_CDR::UShort pid_id =
811  (long_pid ? pid_extended : static_cast<ACE_CDR::UShort>(id));
812  if (!(*this << pid_id)) {
813  return false;
814  }
815  const ACE_CDR::UShort pid_size = long_pid ? 8 : ACE_CDR::UShort(size);
816  if (!(*this << pid_size)) {
817  return false;
818  }
819 
820  // If PID is long, write the extended/long part.
821  if (long_pid && (
822  !(*this << static_cast<ACE_CDR::ULong>(id)) ||
823  !(*this << static_cast<ACE_CDR::ULong>(size)))) {
824  return false;
825  }
826 
827  reset_alignment();
828  } else if (xcdr == Encoding::XCDR_VERSION_2) {
829  // Compute Length Code, write EM Header and NEXTINT
830  const ACE_CDR::ULong lc = (size == 1 ? 0 : size == 2 ? 1 : size == 4 ? 2 : size == 8 ? 3 : 4);
831  const ACE_CDR::ULong emheader = (lc << 28) | id | (must_understand ? emheader_must_understand : 0);
832  if (!(*this << emheader)) {
833  return false;
834  }
835  if (lc == 4) {
836  return *this << ACE_CDR::ULong(size);
837  }
838  }
839  return true;
840 }
841 
842 } // namespace DCPS
843 } // namespace OpenDDS
844 
ACE_Byte Octet
static const ACE_CDR::UShort pid_must_understand
Definition: Serializer.h:380
Encoding()
Encoding with KIND_XCDR1 and ENDIAN_NATIVE.
Definition: Serializer.cpp:77
size_t rpos() const
Examine the logical reading position of the stream.
Definition: Serializer.h:475
#define ACE_ERROR(X)
static String kind_to_string(Kind value)
Definition: Serializer.cpp:326
const LogLevel::Value value
Definition: debug.cpp:61
std::string String
size_t length(void) const
static const ACE_CDR::ULong MEMBER_ID_MAX
Maximum value for member id.
Definition: Serializer.h:387
size_t wpos() const
Examine the logical writing position of the stream.
Definition: Serializer.h:478
void wstring_free(WChar *const)
ConstructionStatus construction_status_
The way to judge whether tryconstruct trim is able to be properly done.
Definition: Serializer.h:876
bool skip(size_t n, int size=1)
Definition: Serializer.inl:443
Kind kind_
The first two bytes as a big endian integer.
Definition: Serializer.h:295
char * string_alloc(ULong len)
String to_dds_string(unsigned short to_convert)
void * memcpy(void *t, const void *s, size_t len)
void string_free(Char *str)
bool write_parameter_id(const unsigned id, size_t size, bool must_understand=false)
Definition: Serializer.cpp:784
Endianness endianness() const
Definition: Serializer.inl:64
#define OPENDDS_ASSERT(C)
Definition: Definitions.h:72
bool read_parameter_id(unsigned &id, size_t &size, bool &must_understand)
Definition: Serializer.cpp:707
String endianness_to_string(Endianness endianness)
Definition: Serializer.cpp:57
String to_string() const
Definition: Serializer.cpp:340
void(* WStrFree)(ACE_CDR::WChar *)
Definition: Serializer.h:440
bool read_octet_array(ACE_CDR::Octet *x, ACE_CDR::ULong length)
Definition: Serializer.inl:558
static const ACE_CDR::UShort pid_extended
Definition: Serializer.h:373
const size_t uint32_cdr_size
Definition: Serializer.h:96
char * rd_ptr(void) const
Char * string_alloc(UnsignedLong len)
void reset_alignment()
Reset alignment as if a new instance were created.
Definition: Serializer.cpp:443
ACE_CDR::UShort options_
The last two bytes as a big endian integer.
Definition: Serializer.h:297
bool write_octet_array(const ACE_CDR::Octet *x, ACE_CDR::ULong length)
Definition: Serializer.inl:697
static bool set_encapsulation_options(Message_Block_Ptr &mb)
Definition: Serializer.cpp:251
ACE_CDR::Char *(* StrAllocate)(ACE_CDR::ULong)
Definition: Serializer.h:437
void read_array(char *x, size_t size, ACE_CDR::ULong length)
Definition: Serializer.inl:472
void(* StrFree)(ACE_CDR::Char *)
Definition: Serializer.h:438
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.
ACE_Message_Block * trim(size_t n) const
Definition: Serializer.cpp:688
const size_t xcdr1_pid_alignment
Definition: Serializer.h:104
static const size_t padding_marker_byte_index
Definition: Serializer.h:252
size_t length() const
Number of bytes left to read in message block chain.
Definition: Serializer.inl:437
bool from_encoding(const Encoding &encoding, Extensibility extensibility)
Definition: Serializer.cpp:113
unsigned char align_wshift_
Definition: Serializer.h:888
char Char
Endianness endianness() const
Definition: Serializer.inl:220
size_t wpos_
Logical writing position of the stream.
Definition: Serializer.h:894
ACE_UINT16 UShort
ACE_Message_Block * current() const
Definition: Serializer.h:480
virtual ACE_Message_Block * release(void)
ScopedAlignmentContext(Serializer &ser, size_t min_read=0)
Definition: Serializer.cpp:397
bool align_r(size_t alignment)
Definition: Serializer.inl:813
bool to_any_encoding(Encoding &encoding)
Definition: Serializer.cpp:159
ACE_Message_Block * cont(void) const
static const size_t padding_marker_alignment
Definition: Serializer.h:253
virtual ACE_Message_Block * duplicate(void) const
WChar * wstring_alloc(ULong len)
size_t read_string(ACE_CDR::Char *&dest, StrAllocate str_alloc=0, StrFree str_free=0)
Definition: Serializer.cpp:520
static const ACE_CDR::ULong emheader_must_understand
Definition: Serializer.h:384
char * wr_ptr(void) const
void string_free(char *)
ACE_UINT32 ULong
bool read_char_array(ACE_CDR::Char *x, ACE_CDR::ULong length)
Definition: Serializer.inl:540
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
bool good_bit_
Indicates the current state of the stream abstraction.
Definition: Serializer.h:873
size_t max_align() const
Return the maximum alignment dictated by the alignment policy.
Definition: Serializer.inl:112
void smemcpy(char *to, const char *from, size_t n)
Definition: Serializer.cpp:453
XcdrVersion xcdr_version() const
Definition: Serializer.inl:127
OpenDDS_Dcps_Export LogLevel log_level
bool to_encoding_i(Encoding &encoding, Extensibility *expected_extensibility_ptr)
Definition: Serializer.cpp:164
const size_t char16_cdr_size
Definition: Serializer.h:103
void swapcpy(char *to, const char *from, size_t n)
Definition: Serializer.cpp:460
bool align_w(size_t alignment)
Definition: Serializer.inl:830
static const char ALIGN_PAD[Encoding::ALIGN_MAX]
Buffer that is copied for zero padding.
Definition: Serializer.h:897
static const ACE_CDR::UShort pid_impl_extension
Definition: Serializer.h:379
EncapsulationHeader(Kind k=KIND_CDR_BE, ACE_CDR::UShort options=0)
Definition: Serializer.cpp:98
const Encoding & encoding() const
Definition: Serializer.inl:199
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
ACE_Message_Block * current_
Currently active message block in chain.
Definition: Serializer.h:864
bool peek_helper(ACE_Message_Block *const block, size_t bytes, T &t)
Definition: Serializer.h:768
ACE_CDR::Boolean operator>>(Serializer &serializer, CoherentChangeControl &value)
void free_string(ACE_CDR::Char *str, StrFree str_free=0)
Definition: Serializer.cpp:589
static unsigned char offset(char *index, size_t start, size_t align)
Definition: Serializer.inl:869
Serializer(ACE_Message_Block *chain, const Encoding &encoding)
Definition: Serializer.cpp:352
ACE_CDR::WChar *(* WStrAllocate)(ACE_CDR::ULong)
Definition: Serializer.h:439
ACE_HANDLE dup(ACE_HANDLE handle)
unsigned char align_rshift_
Definition: Serializer.h:882
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)
size_t rpos_
Logical reading position of the stream.
Definition: Serializer.h:891
LM_ERROR
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
static const size_t serialized_size
Definition: Serializer.h:251
const char * ext_to_string(Extensibility ext)
Definition: Serializer.h:75
extensibility(MUTABLE) struct TypeLookup_getTypes_In
Definition: TypeLookup.idl:29
bool to_encoding(Encoding &encoding, Extensibility expected_extensibility)
Definition: Serializer.cpp:153