OpenDDS  Snapshot(2023/04/28-20:55)
SafetyProfileSequences.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 #ifdef OPENDDS_SAFETY_PROFILE
9 
10 #include "SafetyProfileSequences.h"
11 
12 #include "debug.h"
13 
14 #include <tao/Basic_Types.h>
15 #include <tao/CORBA_String.h>
16 
18 namespace OpenDDS { namespace DCPS {
19 
20 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::BooleanSeq& seq)
21 {
22  ACE_UNUSED_ARG(encoding);
23  ACE_UNUSED_ARG(size);
24  ACE_UNUSED_ARG(seq);
25  primitive_serialized_size_ulong(encoding, size);
26  if (seq.length() == 0) {
27  return;
28  }
29  primitive_serialized_size_boolean(encoding, size, seq.length());
30 }
31 
32 bool operator<<(Serializer& strm, const CORBASeq::BooleanSeq& seq)
33 {
34  ACE_UNUSED_ARG(strm);
35  ACE_UNUSED_ARG(seq);
36  const Encoding& encoding = strm.encoding();
37  ACE_UNUSED_ARG(encoding);
38  const CORBA::ULong length = seq.length();
39  if (!(strm << length)) {
40  return false;
41  }
42  if (length == 0) {
43  return true;
44  }
45  return strm.write_boolean_array(seq.get_buffer(), length);
46 }
47 
48 bool operator>>(Serializer& strm, CORBASeq::BooleanSeq& seq)
49 {
50  ACE_UNUSED_ARG(strm);
51  ACE_UNUSED_ARG(seq);
52  const Encoding& encoding = strm.encoding();
53  ACE_UNUSED_ARG(encoding);
54  CORBA::ULong length;
55  if (!(strm >> length)) {
56  return false;
57  }
58  if (length > strm.length()) {
59  if (DCPS_debug_level >= 8) {
60  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
61  }
62  return false;
63  }
64  CORBA::ULong new_length = length;
65  seq.length(new_length);
66  if (length == 0) {
67  return true;
68  }
69  return strm.read_boolean_array(seq.get_buffer(), length);
70 }
71 
72 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::CharSeq& seq)
73 {
74  ACE_UNUSED_ARG(encoding);
75  ACE_UNUSED_ARG(size);
76  ACE_UNUSED_ARG(seq);
77  primitive_serialized_size_ulong(encoding, size);
78  if (seq.length() == 0) {
79  return;
80  }
81  primitive_serialized_size_char(encoding, size, seq.length());
82 }
83 
84 bool operator<<(Serializer& strm, const CORBASeq::CharSeq& seq)
85 {
86  ACE_UNUSED_ARG(strm);
87  ACE_UNUSED_ARG(seq);
88  const Encoding& encoding = strm.encoding();
89  ACE_UNUSED_ARG(encoding);
90  const CORBA::ULong length = seq.length();
91  if (!(strm << length)) {
92  return false;
93  }
94  if (length == 0) {
95  return true;
96  }
97  return strm.write_char_array(seq.get_buffer(), length);
98 }
99 
100 bool operator>>(Serializer& strm, CORBASeq::CharSeq& seq)
101 {
102  ACE_UNUSED_ARG(strm);
103  ACE_UNUSED_ARG(seq);
104  const Encoding& encoding = strm.encoding();
105  ACE_UNUSED_ARG(encoding);
106  CORBA::ULong length;
107  if (!(strm >> length)) {
108  return false;
109  }
110  if (length > strm.length()) {
111  if (DCPS_debug_level >= 8) {
112  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
113  }
114  return false;
115  }
116  CORBA::ULong new_length = length;
117  seq.length(new_length);
118  if (length == 0) {
119  return true;
120  }
121  return strm.read_char_array(seq.get_buffer(), length);
122 }
123 
124 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::DoubleSeq& seq)
125 {
126  ACE_UNUSED_ARG(encoding);
127  ACE_UNUSED_ARG(size);
128  ACE_UNUSED_ARG(seq);
129  primitive_serialized_size_ulong(encoding, size);
130  if (seq.length() == 0) {
131  return;
132  }
133  encoding.align(size, 8);
134  primitive_serialized_size(encoding, size, CORBA::Double(), seq.length());
135 }
136 
137 bool operator<<(Serializer& strm, const CORBASeq::DoubleSeq& seq)
138 {
139  ACE_UNUSED_ARG(strm);
140  ACE_UNUSED_ARG(seq);
141  const Encoding& encoding = strm.encoding();
142  ACE_UNUSED_ARG(encoding);
143  const CORBA::ULong length = seq.length();
144  if (!(strm << length)) {
145  return false;
146  }
147  if (length == 0) {
148  return true;
149  }
150  return strm.write_double_array(seq.get_buffer(), length);
151 }
152 
153 bool operator>>(Serializer& strm, CORBASeq::DoubleSeq& seq)
154 {
155  ACE_UNUSED_ARG(strm);
156  ACE_UNUSED_ARG(seq);
157  const Encoding& encoding = strm.encoding();
158  ACE_UNUSED_ARG(encoding);
159  CORBA::ULong length;
160  if (!(strm >> length)) {
161  return false;
162  }
163  if (length > strm.length()) {
164  if (DCPS_debug_level >= 8) {
165  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
166  }
167  return false;
168  }
169  CORBA::ULong new_length = length;
170  seq.length(new_length);
171  if (length == 0) {
172  return true;
173  }
174  return strm.read_double_array(seq.get_buffer(), length);
175 }
176 
177 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::FloatSeq& seq)
178 {
179  ACE_UNUSED_ARG(encoding);
180  ACE_UNUSED_ARG(size);
181  ACE_UNUSED_ARG(seq);
182  primitive_serialized_size_ulong(encoding, size);
183  if (seq.length() == 0) {
184  return;
185  }
186  primitive_serialized_size(encoding, size, CORBA::Float(), seq.length());
187 }
188 
189 bool operator<<(Serializer& strm, const CORBASeq::FloatSeq& seq)
190 {
191  ACE_UNUSED_ARG(strm);
192  ACE_UNUSED_ARG(seq);
193  const Encoding& encoding = strm.encoding();
194  ACE_UNUSED_ARG(encoding);
195  const CORBA::ULong length = seq.length();
196  if (!(strm << length)) {
197  return false;
198  }
199  if (length == 0) {
200  return true;
201  }
202  return strm.write_float_array(seq.get_buffer(), length);
203 }
204 
205 bool operator>>(Serializer& strm, CORBASeq::FloatSeq& seq)
206 {
207  ACE_UNUSED_ARG(strm);
208  ACE_UNUSED_ARG(seq);
209  const Encoding& encoding = strm.encoding();
210  ACE_UNUSED_ARG(encoding);
211  CORBA::ULong length;
212  if (!(strm >> length)) {
213  return false;
214  }
215  if (length > strm.length()) {
216  if (DCPS_debug_level >= 8) {
217  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
218  }
219  return false;
220  }
221  CORBA::ULong new_length = length;
222  seq.length(new_length);
223  if (length == 0) {
224  return true;
225  }
226  return strm.read_float_array(seq.get_buffer(), length);
227 }
228 
229 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::Int8Seq& seq)
230 {
231  ACE_UNUSED_ARG(encoding);
232  ACE_UNUSED_ARG(size);
233  ACE_UNUSED_ARG(seq);
234  primitive_serialized_size_ulong(encoding, size);
235  if (seq.length() == 0) {
236  return;
237  }
238  primitive_serialized_size_int8(encoding, size, seq.length());
239 }
240 
241 bool operator<<(Serializer& strm, const CORBASeq::Int8Seq& seq)
242 {
243  ACE_UNUSED_ARG(strm);
244  ACE_UNUSED_ARG(seq);
245  const Encoding& encoding = strm.encoding();
246  ACE_UNUSED_ARG(encoding);
247  const CORBA::ULong length = seq.length();
248  if (!(strm << length)) {
249  return false;
250  }
251  if (length == 0) {
252  return true;
253  }
254  return strm.write_int8_array(seq.get_buffer(), length);
255 }
256 
257 bool operator>>(Serializer& strm, CORBASeq::Int8Seq& seq)
258 {
259  ACE_UNUSED_ARG(strm);
260  ACE_UNUSED_ARG(seq);
261  const Encoding& encoding = strm.encoding();
262  ACE_UNUSED_ARG(encoding);
263  CORBA::ULong length;
264  if (!(strm >> length)) {
265  return false;
266  }
267  if (length > strm.length()) {
268  if (DCPS_debug_level >= 8) {
269  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
270  }
271  return false;
272  }
273  CORBA::ULong new_length = length;
274  seq.length(new_length);
275  if (length == 0) {
276  return true;
277  }
278  return strm.read_int8_array(seq.get_buffer(), length);
279 }
280 
281 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::LongDoubleSeq& seq)
282 {
283  ACE_UNUSED_ARG(encoding);
284  ACE_UNUSED_ARG(size);
285  ACE_UNUSED_ARG(seq);
286  primitive_serialized_size_ulong(encoding, size);
287  if (seq.length() == 0) {
288  return;
289  }
290  encoding.align(size, 8);
291  primitive_serialized_size(encoding, size, CORBA::LongDouble(), seq.length());
292 }
293 
294 bool operator<<(Serializer& strm, const CORBASeq::LongDoubleSeq& seq)
295 {
296  ACE_UNUSED_ARG(strm);
297  ACE_UNUSED_ARG(seq);
298  const Encoding& encoding = strm.encoding();
299  ACE_UNUSED_ARG(encoding);
300  const CORBA::ULong length = seq.length();
301  if (!(strm << length)) {
302  return false;
303  }
304  if (length == 0) {
305  return true;
306  }
307  return strm.write_longdouble_array(seq.get_buffer(), length);
308 }
309 
310 bool operator>>(Serializer& strm, CORBASeq::LongDoubleSeq& seq)
311 {
312  ACE_UNUSED_ARG(strm);
313  ACE_UNUSED_ARG(seq);
314  const Encoding& encoding = strm.encoding();
315  ACE_UNUSED_ARG(encoding);
316  CORBA::ULong length;
317  if (!(strm >> length)) {
318  return false;
319  }
320  if (length > strm.length()) {
321  if (DCPS_debug_level >= 8) {
322  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
323  }
324  return false;
325  }
326  CORBA::ULong new_length = length;
327  seq.length(new_length);
328  if (length == 0) {
329  return true;
330  }
331  return strm.read_longdouble_array(seq.get_buffer(), length);
332 }
333 
334 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::LongLongSeq& seq)
335 {
336  ACE_UNUSED_ARG(encoding);
337  ACE_UNUSED_ARG(size);
338  ACE_UNUSED_ARG(seq);
339  primitive_serialized_size_ulong(encoding, size);
340  if (seq.length() == 0) {
341  return;
342  }
343  encoding.align(size, 8);
344  primitive_serialized_size(encoding, size, CORBA::LongLong(), seq.length());
345 }
346 
347 bool operator<<(Serializer& strm, const CORBASeq::LongLongSeq& seq)
348 {
349  ACE_UNUSED_ARG(strm);
350  ACE_UNUSED_ARG(seq);
351  const Encoding& encoding = strm.encoding();
352  ACE_UNUSED_ARG(encoding);
353  const CORBA::ULong length = seq.length();
354  if (!(strm << length)) {
355  return false;
356  }
357  if (length == 0) {
358  return true;
359  }
360  return strm.write_longlong_array(seq.get_buffer(), length);
361 }
362 
363 bool operator>>(Serializer& strm, CORBASeq::LongLongSeq& seq)
364 {
365  ACE_UNUSED_ARG(strm);
366  ACE_UNUSED_ARG(seq);
367  const Encoding& encoding = strm.encoding();
368  ACE_UNUSED_ARG(encoding);
369  CORBA::ULong length;
370  if (!(strm >> length)) {
371  return false;
372  }
373  if (length > strm.length()) {
374  if (DCPS_debug_level >= 8) {
375  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
376  }
377  return false;
378  }
379  CORBA::ULong new_length = length;
380  seq.length(new_length);
381  if (length == 0) {
382  return true;
383  }
384  return strm.read_longlong_array(seq.get_buffer(), length);
385 }
386 
387 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::LongSeq& seq)
388 {
389  ACE_UNUSED_ARG(encoding);
390  ACE_UNUSED_ARG(size);
391  ACE_UNUSED_ARG(seq);
392  primitive_serialized_size_ulong(encoding, size);
393  if (seq.length() == 0) {
394  return;
395  }
396  primitive_serialized_size(encoding, size, CORBA::Long(), seq.length());
397 }
398 
399 bool operator<<(Serializer& strm, const CORBASeq::LongSeq& seq)
400 {
401  ACE_UNUSED_ARG(strm);
402  ACE_UNUSED_ARG(seq);
403  const Encoding& encoding = strm.encoding();
404  ACE_UNUSED_ARG(encoding);
405  const CORBA::ULong length = seq.length();
406  if (!(strm << length)) {
407  return false;
408  }
409  if (length == 0) {
410  return true;
411  }
412  return strm.write_long_array(seq.get_buffer(), length);
413 }
414 
415 bool operator>>(Serializer& strm, CORBASeq::LongSeq& seq)
416 {
417  ACE_UNUSED_ARG(strm);
418  ACE_UNUSED_ARG(seq);
419  const Encoding& encoding = strm.encoding();
420  ACE_UNUSED_ARG(encoding);
421  CORBA::ULong length;
422  if (!(strm >> length)) {
423  return false;
424  }
425  if (length > strm.length()) {
426  if (DCPS_debug_level >= 8) {
427  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
428  }
429  return false;
430  }
431  CORBA::ULong new_length = length;
432  seq.length(new_length);
433  if (length == 0) {
434  return true;
435  }
436  return strm.read_long_array(seq.get_buffer(), length);
437 }
438 
439 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::OctetSeq& seq)
440 {
441  ACE_UNUSED_ARG(encoding);
442  ACE_UNUSED_ARG(size);
443  ACE_UNUSED_ARG(seq);
444  primitive_serialized_size_ulong(encoding, size);
445  if (seq.length() == 0) {
446  return;
447  }
448  primitive_serialized_size_octet(encoding, size, seq.length());
449 }
450 
451 bool operator<<(Serializer& strm, const CORBASeq::OctetSeq& seq)
452 {
453  ACE_UNUSED_ARG(strm);
454  ACE_UNUSED_ARG(seq);
455  const Encoding& encoding = strm.encoding();
456  ACE_UNUSED_ARG(encoding);
457  const CORBA::ULong length = seq.length();
458  if (!(strm << length)) {
459  return false;
460  }
461  if (length == 0) {
462  return true;
463  }
464  return strm.write_octet_array(seq.get_buffer(), length);
465 }
466 
467 bool operator>>(Serializer& strm, CORBASeq::OctetSeq& seq)
468 {
469  ACE_UNUSED_ARG(strm);
470  ACE_UNUSED_ARG(seq);
471  const Encoding& encoding = strm.encoding();
472  ACE_UNUSED_ARG(encoding);
473  CORBA::ULong length;
474  if (!(strm >> length)) {
475  return false;
476  }
477  if (length > strm.length()) {
478  if (DCPS_debug_level >= 8) {
479  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
480  }
481  return false;
482  }
483  CORBA::ULong new_length = length;
484  seq.length(new_length);
485  if (length == 0) {
486  return true;
487  }
488  return strm.read_octet_array(seq.get_buffer(), length);
489 }
490 
491 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::ShortSeq& seq)
492 {
493  ACE_UNUSED_ARG(encoding);
494  ACE_UNUSED_ARG(size);
495  ACE_UNUSED_ARG(seq);
496  primitive_serialized_size_ulong(encoding, size);
497  if (seq.length() == 0) {
498  return;
499  }
500  primitive_serialized_size(encoding, size, CORBA::Short(), seq.length());
501 }
502 
503 bool operator<<(Serializer& strm, const CORBASeq::ShortSeq& seq)
504 {
505  ACE_UNUSED_ARG(strm);
506  ACE_UNUSED_ARG(seq);
507  const Encoding& encoding = strm.encoding();
508  ACE_UNUSED_ARG(encoding);
509  const CORBA::ULong length = seq.length();
510  if (!(strm << length)) {
511  return false;
512  }
513  if (length == 0) {
514  return true;
515  }
516  return strm.write_short_array(seq.get_buffer(), length);
517 }
518 
519 bool operator>>(Serializer& strm, CORBASeq::ShortSeq& seq)
520 {
521  ACE_UNUSED_ARG(strm);
522  ACE_UNUSED_ARG(seq);
523  const Encoding& encoding = strm.encoding();
524  ACE_UNUSED_ARG(encoding);
525  CORBA::ULong length;
526  if (!(strm >> length)) {
527  return false;
528  }
529  if (length > strm.length()) {
530  if (DCPS_debug_level >= 8) {
531  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
532  }
533  return false;
534  }
535  CORBA::ULong new_length = length;
536  seq.length(new_length);
537  if (length == 0) {
538  return true;
539  }
540  return strm.read_short_array(seq.get_buffer(), length);
541 }
542 
543 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::StringSeq& seq)
544 {
545  ACE_UNUSED_ARG(encoding);
546  ACE_UNUSED_ARG(size);
547  ACE_UNUSED_ARG(seq);
548  if (encoding.xcdr_version() == Encoding::XCDR_VERSION_2) {
549  serialized_size_delimiter(encoding, size);
550  }
551  primitive_serialized_size_ulong(encoding, size);
552  if (seq.length() == 0) {
553  return;
554  }
555  for (CORBA::ULong i = 0; i < seq.length(); ++i) {
556  primitive_serialized_size_ulong(encoding, size);
557  if (seq[i]) {
558  size += ACE_OS::strlen(seq[i]) + 1;
559  }
560  }
561 }
562 
563 bool operator<<(Serializer& strm, const CORBASeq::StringSeq& seq)
564 {
565  ACE_UNUSED_ARG(strm);
566  ACE_UNUSED_ARG(seq);
567  const Encoding& encoding = strm.encoding();
568  ACE_UNUSED_ARG(encoding);
569  size_t total_size = 0;
570  if (encoding.xcdr_version() == Encoding::XCDR_VERSION_2) {
571  serialized_size(encoding, total_size, seq);
572  if (!strm.write_delimiter(total_size)) {
573  return false;
574  }
575  }
576  const CORBA::ULong length = seq.length();
577  if (!(strm << length)) {
578  return false;
579  }
580  if (length == 0) {
581  return true;
582  }
583  for (CORBA::ULong i = 0; i < length; ++i) {
584  if (!(strm << seq[i])) {
585  return false;
586  }
587  }
588  return true;
589 }
590 
591 bool operator>>(Serializer& strm, CORBASeq::StringSeq& seq)
592 {
593  ACE_UNUSED_ARG(strm);
594  ACE_UNUSED_ARG(seq);
595  const Encoding& encoding = strm.encoding();
596  ACE_UNUSED_ARG(encoding);
597  size_t total_size = 0;
598  if (encoding.xcdr_version() == Encoding::XCDR_VERSION_2) {
599  if (!strm.read_delimiter(total_size)) {
600  return false;
601  }
602  }
603  const size_t end_of_seq = strm.rpos() + total_size;
604  CORBA::ULong length;
605  if (!(strm >> length)) {
606  return false;
607  }
608  if (length > strm.length()) {
609  if (DCPS_debug_level >= 8) {
610  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
611  }
612  return false;
613  }
614  CORBA::ULong new_length = length;
615  seq.length(new_length);
616  for (CORBA::ULong i = 0; i < new_length; ++i) {
617  if (!(strm >> seq[i])) {
618  strm.set_construction_status(Serializer::ElementConstructionFailure);
619  if (encoding.xcdr_version() == Encoding::XCDR_VERSION_2) {
620  strm.skip(end_of_seq - strm.rpos());
621  } else {
622  CORBASeq::StringSeq tempvar;
623  tempvar.length(1);
624  for (CORBA::ULong j = i + 1; j < length; ++j) {
625  strm >> tempvar[0];
626  }
627  }
628  return false;
629  }
630  }
631  if (new_length != length) {
632  if (encoding.xcdr_version() == Encoding::XCDR_VERSION_2) {
633  strm.skip(end_of_seq - strm.rpos());
634  } else {
635  CORBASeq::StringSeq tempvar;
636  tempvar.length(1);
637  for (CORBA::ULong j = new_length + 1; j < length; ++j) {
638  strm >> tempvar[0];
639  }
640  }
641  strm.set_construction_status(Serializer::BoundConstructionFailure);
642  return false;
643  }
644  return true;
645 }
646 
647 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::UInt8Seq& seq)
648 {
649  ACE_UNUSED_ARG(encoding);
650  ACE_UNUSED_ARG(size);
651  ACE_UNUSED_ARG(seq);
652  primitive_serialized_size_ulong(encoding, size);
653  if (seq.length() == 0) {
654  return;
655  }
656  primitive_serialized_size_uint8(encoding, size, seq.length());
657 }
658 
659 bool operator<<(Serializer& strm, const CORBASeq::UInt8Seq& seq)
660 {
661  ACE_UNUSED_ARG(strm);
662  ACE_UNUSED_ARG(seq);
663  const Encoding& encoding = strm.encoding();
664  ACE_UNUSED_ARG(encoding);
665  const CORBA::ULong length = seq.length();
666  if (!(strm << length)) {
667  return false;
668  }
669  if (length == 0) {
670  return true;
671  }
672  return strm.write_uint8_array(seq.get_buffer(), length);
673 }
674 
675 bool operator>>(Serializer& strm, CORBASeq::UInt8Seq& seq)
676 {
677  ACE_UNUSED_ARG(strm);
678  ACE_UNUSED_ARG(seq);
679  const Encoding& encoding = strm.encoding();
680  ACE_UNUSED_ARG(encoding);
681  CORBA::ULong length;
682  if (!(strm >> length)) {
683  return false;
684  }
685  if (length > strm.length()) {
686  if (DCPS_debug_level >= 8) {
687  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
688  }
689  return false;
690  }
691  CORBA::ULong new_length = length;
692  seq.length(new_length);
693  if (length == 0) {
694  return true;
695  }
696  return strm.read_uint8_array(seq.get_buffer(), length);
697 }
698 
699 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::ULongLongSeq& seq)
700 {
701  ACE_UNUSED_ARG(encoding);
702  ACE_UNUSED_ARG(size);
703  ACE_UNUSED_ARG(seq);
704  primitive_serialized_size_ulong(encoding, size);
705  if (seq.length() == 0) {
706  return;
707  }
708  encoding.align(size, 8);
709  primitive_serialized_size(encoding, size, CORBA::ULongLong(), seq.length());
710 }
711 
712 bool operator<<(Serializer& strm, const CORBASeq::ULongLongSeq& seq)
713 {
714  ACE_UNUSED_ARG(strm);
715  ACE_UNUSED_ARG(seq);
716  const Encoding& encoding = strm.encoding();
717  ACE_UNUSED_ARG(encoding);
718  const CORBA::ULong length = seq.length();
719  if (!(strm << length)) {
720  return false;
721  }
722  if (length == 0) {
723  return true;
724  }
725  return strm.write_ulonglong_array(seq.get_buffer(), length);
726 }
727 
728 bool operator>>(Serializer& strm, CORBASeq::ULongLongSeq& seq)
729 {
730  ACE_UNUSED_ARG(strm);
731  ACE_UNUSED_ARG(seq);
732  const Encoding& encoding = strm.encoding();
733  ACE_UNUSED_ARG(encoding);
734  CORBA::ULong length;
735  if (!(strm >> length)) {
736  return false;
737  }
738  if (length > strm.length()) {
739  if (DCPS_debug_level >= 8) {
740  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
741  }
742  return false;
743  }
744  CORBA::ULong new_length = length;
745  seq.length(new_length);
746  if (length == 0) {
747  return true;
748  }
749  return strm.read_ulonglong_array(seq.get_buffer(), length);
750 }
751 
752 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::ULongSeq& seq)
753 {
754  ACE_UNUSED_ARG(encoding);
755  ACE_UNUSED_ARG(size);
756  ACE_UNUSED_ARG(seq);
757  primitive_serialized_size_ulong(encoding, size);
758  if (seq.length() == 0) {
759  return;
760  }
761  primitive_serialized_size(encoding, size, CORBA::ULong(), seq.length());
762 }
763 
764 bool operator<<(Serializer& strm, const CORBASeq::ULongSeq& seq)
765 {
766  ACE_UNUSED_ARG(strm);
767  ACE_UNUSED_ARG(seq);
768  const Encoding& encoding = strm.encoding();
769  ACE_UNUSED_ARG(encoding);
770  const CORBA::ULong length = seq.length();
771  if (!(strm << length)) {
772  return false;
773  }
774  if (length == 0) {
775  return true;
776  }
777  return strm.write_ulong_array(seq.get_buffer(), length);
778 }
779 
780 bool operator>>(Serializer& strm, CORBASeq::ULongSeq& seq)
781 {
782  ACE_UNUSED_ARG(strm);
783  ACE_UNUSED_ARG(seq);
784  const Encoding& encoding = strm.encoding();
785  ACE_UNUSED_ARG(encoding);
786  CORBA::ULong length;
787  if (!(strm >> length)) {
788  return false;
789  }
790  if (length > strm.length()) {
791  if (DCPS_debug_level >= 8) {
792  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
793  }
794  return false;
795  }
796  CORBA::ULong new_length = length;
797  seq.length(new_length);
798  if (length == 0) {
799  return true;
800  }
801  return strm.read_ulong_array(seq.get_buffer(), length);
802 }
803 
804 void serialized_size(const Encoding& encoding, size_t& size, const CORBASeq::UShortSeq& seq)
805 {
806  ACE_UNUSED_ARG(encoding);
807  ACE_UNUSED_ARG(size);
808  ACE_UNUSED_ARG(seq);
809  primitive_serialized_size_ulong(encoding, size);
810  if (seq.length() == 0) {
811  return;
812  }
813  primitive_serialized_size(encoding, size, CORBA::UShort(), seq.length());
814 }
815 
816 bool operator<<(Serializer& strm, const CORBASeq::UShortSeq& seq)
817 {
818  ACE_UNUSED_ARG(strm);
819  ACE_UNUSED_ARG(seq);
820  const Encoding& encoding = strm.encoding();
821  ACE_UNUSED_ARG(encoding);
822  const CORBA::ULong length = seq.length();
823  if (!(strm << length)) {
824  return false;
825  }
826  if (length == 0) {
827  return true;
828  }
829  return strm.write_ushort_array(seq.get_buffer(), length);
830 }
831 
832 bool operator>>(Serializer& strm, CORBASeq::UShortSeq& seq)
833 {
834  ACE_UNUSED_ARG(strm);
835  ACE_UNUSED_ARG(seq);
836  const Encoding& encoding = strm.encoding();
837  ACE_UNUSED_ARG(encoding);
838  CORBA::ULong length;
839  if (!(strm >> length)) {
840  return false;
841  }
842  if (length > strm.length()) {
843  if (DCPS_debug_level >= 8) {
844  ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Invalid sequence length (%u)\n"), length));
845  }
846  return false;
847  }
848  CORBA::ULong new_length = length;
849  seq.length(new_length);
850  if (length == 0) {
851  return true;
852  }
853  return strm.read_ushort_array(seq.get_buffer(), length);
854 }
855 
856 } }
858 
859 #endif
#define ACE_DEBUG(X)
ACE_CDR::Long Long
sequence< unsigned long > ULongSeq
Definition: ULongSeq.idl:23
OpenDDS_Dcps_Export void primitive_serialized_size_ulong(const Encoding &encoding, size_t &size, size_t count=1)
ACE_CDR::LongLong LongLong
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.
ACE_CDR::Short Short
OpenDDS_Dcps_Export void primitive_serialized_size_octet(const Encoding &encoding, size_t &size, size_t count=1)
void serialized_size(const Encoding &encoding, size_t &size, const SequenceNumber &)
size_t strlen(const char *s)
ACE_CDR::ULongLong ULongLong
OpenDDS_Dcps_Export void primitive_serialized_size_char(const Encoding &encoding, size_t &size, size_t count=1)
ACE_CDR::ULong ULong
ACE_CDR::Boolean operator<<(Serializer &serializer, CoherentChangeControl &value)
Marshal/Insertion into a buffer.
sequence< string > StringSeq
Definition: StringSeq.idl:30
ACE_CDR::UShort UShort
sequence< double > DoubleSeq
Definition: DoubleSeq.idl:33
ACE_TEXT("TCP_Factory")
sequence< boolean > BooleanSeq
Definition: BooleanSeq.idl:19
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
ACE_CDR::Boolean operator>>(Serializer &serializer, CoherentChangeControl &value)
sequence< float > FloatSeq
Definition: FloatSeq.idl:34
sequence< short > ShortSeq
Definition: ShortSeq.idl:32
const DCPS::Encoding encoding(DCPS::Encoding::KIND_UNALIGNED_CDR, DCPS::ENDIAN_BIG)
sequence< long > LongSeq
Definition: LongSeq.idl:31
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
sequence< unsigned short > UShortSeq
Definition: UShortSeq.idl:30
OpenDDS_Dcps_Export void primitive_serialized_size_boolean(const Encoding &encoding, size_t &size, size_t count=1)
OpenDDS_Dcps_Export bool primitive_serialized_size(const Encoding &encoding, size_t &size, const ACE_CDR::Short &value, size_t count=1)