=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / tao / CDR.inl
blobe881ea29bd07477cba2d0a3ad4704e850d094933
1 // -*- C++ -*-
2 #include "tao/SystemException.h"
3 #include <cstring>
5 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
7 ACE_INLINE
8 TAO_OutputCDR::~TAO_OutputCDR ()
12 ACE_INLINE bool
13 TAO_OutputCDR::more_fragments () const
15   return this->more_fragments_;
18 ACE_INLINE void
19 TAO_OutputCDR::more_fragments (bool more)
21   this->more_fragments_ = more;
24 ACE_INLINE void
25 TAO_OutputCDR::message_attributes (CORBA::ULong request_id,
26                                    TAO_Stub * stub,
27                                    TAO_Message_Semantics message_semantics,
28                                    ACE_Time_Value * timeout)
30   this->request_id_        = request_id;
31   this->stub_              = stub;
32   this->message_semantics_ = message_semantics;
33   this->timeout_           = timeout;
36 ACE_INLINE CORBA::ULong
37 TAO_OutputCDR::request_id () const
39   return this->request_id_;
42 ACE_INLINE TAO_Stub *
43 TAO_OutputCDR::stub () const
45   return this->stub_;
48 ACE_INLINE TAO_Message_Semantics
49 TAO_OutputCDR::message_semantics () const
51   return this->message_semantics_;
54 ACE_INLINE ACE_Time_Value *
55 TAO_OutputCDR::timeout () const
57   return this->timeout_;
60 ACE_INLINE void
61 TAO_OutputCDR::get_version (TAO_GIOP_Message_Version& giop_version)
63   giop_version.set_version (this->major_version_, this->minor_version_);
66 ACE_INLINE TAO_OutputCDR::Repo_Id_Map_Handle&
67 TAO_OutputCDR::get_repo_id_map ()
69   return this->repo_id_map_;
72 #ifdef TAO_HAS_VALUETYPE_CODEBASE
73 ACE_INLINE TAO_OutputCDR::Codebase_URL_Map_Handle&
74 TAO_OutputCDR::get_codebase_url_map ()
76   return this->codebase_map_;
78 #endif
80 ACE_INLINE TAO_OutputCDR::Value_Map_Handle&
81 TAO_OutputCDR::get_value_map ()
83   return this->value_map_;
86 ACE_INLINE void
87 TAO_OutputCDR::set_repo_id_map (TAO_OutputCDR::Repo_Id_Map_Handle& map)
89   this->repo_id_map_ = map;
92 #ifdef TAO_HAS_VALUETYPE_CODEBASE
93 ACE_INLINE void
94 TAO_OutputCDR::set_codebase_url_map (TAO_OutputCDR::Codebase_URL_Map_Handle& map)
96   this->codebase_map_ = map;
98 #endif
100 ACE_INLINE void
101 TAO_OutputCDR::set_value_map (TAO_OutputCDR::Value_Map_Handle& map)
103   this->value_map_ = map;
106 ACE_INLINE void
107 TAO_OutputCDR::reset_vt_indirect_maps ()
109   if (! this->repo_id_map_.is_nil () && this->repo_id_map_->get()->current_size () != 0)
110   {
111     this->repo_id_map_->get()->unbind_all ();
112   }
113 #ifdef TAO_HAS_VALUETYPE_CODEBASE
114   if (! this->codebase_map_.is_nil () && this->codebase_map_->get()->current_size () != 0)
115   {
116     this->codebase_map_->get()->unbind_all ();
117   }
118 #endif
119   if (! this->value_map_.is_nil () && this->value_map_->get()->current_size () != 0)
120   {
121     this->value_map_->get()->unbind_all ();
122   }
125 // -------------------------------------------------------------------
127 ACE_INLINE
128 TAO_InputCDR::TAO_InputCDR (const char *buf,
129                             size_t bufsiz,
130                             int byte_order,
131                             ACE_CDR::Octet major_version,
132                             ACE_CDR::Octet minor_version,
133                             TAO_ORB_Core* orb_core)
134   : ACE_InputCDR (buf,
135                   bufsiz,
136                   byte_order,
137                   major_version,
138                   minor_version),
139     orb_core_ (orb_core)
143 ACE_INLINE
144 TAO_InputCDR::TAO_InputCDR (size_t bufsiz,
145                             int byte_order,
146                             ACE_CDR::Octet major_version,
147                             ACE_CDR::Octet minor_version,
148                             TAO_ORB_Core* orb_core)
149   : ACE_InputCDR (bufsiz,
150                   byte_order,
151                   major_version,
152                   minor_version),
153     orb_core_ (orb_core)
157 ACE_INLINE
158 TAO_InputCDR::TAO_InputCDR (const ACE_Message_Block *data,
159                             int byte_order,
160                             ACE_CDR::Octet major_version,
161                             ACE_CDR::Octet minor_version,
162                             TAO_ORB_Core* orb_core)
163   : ACE_InputCDR (data,
164                   byte_order,
165                   major_version,
166                   minor_version),
167     orb_core_ (orb_core)
171 ACE_INLINE
172 TAO_InputCDR::TAO_InputCDR (const ACE_Message_Block *data,
173                             ACE_Lock* lock,
174                             int byte_order,
175                             ACE_CDR::Octet major_version,
176                             ACE_CDR::Octet minor_version,
177                             TAO_ORB_Core* orb_core)
178   : ACE_InputCDR (data,
179                   byte_order,
180                   major_version,
181                   minor_version,
182                   lock),
183     orb_core_ (orb_core)
187 ACE_INLINE
188 TAO_InputCDR::TAO_InputCDR (ACE_Data_Block *data,
189                             ACE_Message_Block::Message_Flags flag,
190                             int byte_order,
191                             ACE_CDR::Octet major_version,
192                             ACE_CDR::Octet minor_version,
193                             TAO_ORB_Core* orb_core)
194   : ACE_InputCDR (data,
195                   flag,
196                   byte_order,
197                   major_version,
198                   minor_version),
199     orb_core_ (orb_core)
204 ACE_INLINE
205 TAO_InputCDR::TAO_InputCDR (ACE_Data_Block *data,
206                             ACE_Message_Block::Message_Flags flag,
207                             size_t rd_pos,
208                             size_t wr_pos,
209                             int byte_order,
210                             ACE_CDR::Octet major_version,
211                             ACE_CDR::Octet minor_version,
212                             TAO_ORB_Core* orb_core)
213   : ACE_InputCDR (data,
214                   flag,
215                   rd_pos,
216                   wr_pos,
217                   byte_order,
218                   major_version,
219                   minor_version),
220     orb_core_ (orb_core)
225 ACE_INLINE
226 TAO_InputCDR::TAO_InputCDR (const TAO_InputCDR& rhs,
227                             size_t size,
228                             ACE_CDR::Long offset)
229   : ACE_InputCDR (rhs,
230                   size,
231                   offset),
232     orb_core_ (rhs.orb_core_)
236 ACE_INLINE
237 TAO_InputCDR::TAO_InputCDR (const TAO_InputCDR& rhs,
238                             size_t size)
239   : ACE_InputCDR (rhs,
240                   size),
241     orb_core_ (rhs.orb_core_)
245 ACE_INLINE
246 TAO_InputCDR::TAO_InputCDR (const TAO_InputCDR& rhs)
247   : ACE_InputCDR (rhs),
248     orb_core_ (rhs.orb_core_),
249     repo_id_map_ (rhs.repo_id_map_),
250     codebase_map_ (rhs.codebase_map_),
251     value_map_ (rhs.value_map_)
255 ACE_INLINE
256 TAO_InputCDR::TAO_InputCDR (ACE_InputCDR::Transfer_Contents rhs,
257                             TAO_ORB_Core* orb_core)
258   : ACE_InputCDR (rhs),
259     orb_core_ (orb_core)
264 ACE_INLINE
265 TAO_InputCDR::~TAO_InputCDR ()
269 ACE_INLINE TAO_ORB_Core*
270 TAO_InputCDR::orb_core () const
272   return this->orb_core_;
276 ACE_INLINE TAO_InputCDR::Repo_Id_Map_Handle&
277 TAO_InputCDR::get_repo_id_map ()
279   return this->repo_id_map_;
282 ACE_INLINE TAO_InputCDR::Codebase_URL_Map_Handle&
283 TAO_InputCDR::get_codebase_url_map ()
285   return this->codebase_map_;
288 ACE_INLINE TAO_InputCDR::Value_Map_Handle&
289 TAO_InputCDR::get_value_map ()
291   return this->value_map_;
294 ACE_INLINE void
295 TAO_InputCDR::set_repo_id_map (TAO_InputCDR::Repo_Id_Map_Handle& map)
297   this->repo_id_map_ = map;
300 ACE_INLINE void
301 TAO_InputCDR::set_codebase_url_map (TAO_InputCDR::Codebase_URL_Map_Handle& map)
303   this->codebase_map_ = map;
306 ACE_INLINE void
307 TAO_InputCDR::set_value_map (TAO_InputCDR::Value_Map_Handle& map)
309   this->value_map_ = map;
312 ACE_INLINE void
313 TAO_InputCDR::reset_vt_indirect_maps ()
315   if (! this->repo_id_map_.is_nil () && this->repo_id_map_->get()->current_size () != 0)
316   {
317     this->repo_id_map_->get()->unbind_all ();
318   }
319   if (! this->codebase_map_.is_nil () && this->codebase_map_->get()->current_size () != 0)
320   {
321     this->codebase_map_->get()->unbind_all ();
322   }
323   if (! this->value_map_.is_nil () && this->value_map_->get()->current_size () != 0)
324   {
325     this->value_map_->get()->unbind_all ();
326   }
329 // ****************************************************************
331 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
332                                       CORBA::Short x)
334   return
335     os.fragment_stream (ACE_CDR::SHORT_ALIGN,
336                         sizeof (CORBA::Short))
337     && static_cast<ACE_OutputCDR &> (os) << x;
340 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
341                                       CORBA::UShort x)
343   return
344     os.fragment_stream (ACE_CDR::SHORT_ALIGN,
345                         sizeof (CORBA::UShort))
346     && static_cast<ACE_OutputCDR &> (os) << x;
349 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
350                                       CORBA::Long x)
352   return
353     os.fragment_stream (ACE_CDR::LONG_ALIGN,
354                         sizeof (CORBA::Long))
355     && static_cast<ACE_OutputCDR &> (os) << x;
358 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
359                                       CORBA::ULong x)
361   return
362     os.fragment_stream (ACE_CDR::LONG_ALIGN,
363                         sizeof (CORBA::ULong))
364     && static_cast<ACE_OutputCDR &> (os) << x;
367 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
368                                       CORBA::LongLong x)
370   return
371     os.fragment_stream (ACE_CDR::LONGLONG_ALIGN,
372                         sizeof (CORBA::LongLong))
373     && static_cast<ACE_OutputCDR &> (os) << x;
376 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
377                                       CORBA::ULongLong x)
379   return
380     os.fragment_stream (ACE_CDR::LONGLONG_ALIGN,
381                         sizeof (CORBA::ULongLong))
382     && static_cast<ACE_OutputCDR &> (os) << x;
385 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR& os,
386                                       CORBA::LongDouble x)
388   return
389     os.fragment_stream (ACE_CDR::LONGDOUBLE_ALIGN,
390                         sizeof (CORBA::LongDouble))
391     && static_cast<ACE_OutputCDR &> (os) << x;
394 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
395                                       CORBA::Float x)
397   return
398     os.fragment_stream (ACE_CDR::LONG_ALIGN,
399                         sizeof (CORBA::Float))
400     && static_cast<ACE_OutputCDR &> (os) << x;
403 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
404                                       CORBA::Double x)
406   return
407     os.fragment_stream (ACE_CDR::LONGLONG_ALIGN,
408                         sizeof (CORBA::Double))
409     && static_cast<ACE_OutputCDR &> (os) << x;
412 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
413                                       const char * x)
415   return
416     os.fragment_stream (ACE_CDR::OCTET_ALIGN,
417                         sizeof (char))
418     && static_cast<ACE_OutputCDR &> (os) << x;
421 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
422                                       const CORBA::WChar * x)
424   return
425     os.fragment_stream ((sizeof (CORBA::WChar) == 2
426                          ? ACE_CDR::SHORT_ALIGN
427                          : ACE_CDR::LONG_ALIGN),
428                         sizeof (CORBA::WChar))
429     && static_cast<ACE_OutputCDR &> (os) << x;
432 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
433                                       ACE_OutputCDR::from_string x)
435   if (x.bound_ != 0 && x.val_ != 0 &&
436       std::strlen (x.val_) > x.bound_)
437     {
438       throw CORBA::BAD_PARAM ();
439     }
440   return os << x.val_;
443 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
444                                       ACE_OutputCDR::from_wstring x)
446   if (x.bound_ != 0 && x.val_ != 0 &&
447       ACE_OS::strlen (x.val_) > x.bound_)
448     {
449       throw CORBA::BAD_PARAM ();
450     }
451   return os << x.val_;
454 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
455                                       const std::string &x)
457   return
458     os.fragment_stream (ACE_CDR::OCTET_ALIGN,
459                         sizeof (char))
460     && static_cast<ACE_OutputCDR &> (os) << x;
463 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
464                                       const std::string_view &x)
466   return
467     os.fragment_stream (ACE_CDR::OCTET_ALIGN,
468                         sizeof (char))
469     && static_cast<ACE_OutputCDR &> (os) << x;
472 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
473                                       ACE_OutputCDR::from_std_string x)
475   if (x.bound_ != 0 &&
476       static_cast<ACE_CDR::ULong> (x.val_.size ()) > x.bound_)
477     {
478       throw CORBA::BAD_PARAM ();
479     }
480   return os << x.val_;
483 #if !defined(ACE_LACKS_STD_WSTRING)
484 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
485                                       const std::wstring &x)
487   return
488     os.fragment_stream ((sizeof (CORBA::WChar) == 2
489                          ? ACE_CDR::SHORT_ALIGN
490                          : ACE_CDR::LONG_ALIGN),
491                         sizeof (CORBA::WChar))
492     && static_cast<ACE_OutputCDR &> (os) << x;
495 ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os,
496                                       ACE_OutputCDR::from_std_wstring x)
498   if (x.bound_ != 0 &&
499       static_cast<ACE_CDR::ULong> (x.val_.size ()) > x.bound_)
500     {
501       throw CORBA::BAD_PARAM ();
502     }
503   return os << x.val_;
505 #endif /* ACE_LACKS_STD_WSTRING */
507 // ****************************************************************
509 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
510                                       CORBA::Short &x)
512   return static_cast<ACE_InputCDR &> (is) >> x;
515 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
516                                       CORBA::UShort &x)
518   return static_cast<ACE_InputCDR &> (is) >> x;
521 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
522                                       CORBA::Long &x)
524   return static_cast<ACE_InputCDR&> (is) >> x;
527 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
528                                       CORBA::ULong &x)
530   return static_cast<ACE_InputCDR &> (is) >> x;
533 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
534                                       CORBA::LongLong &x)
536   return static_cast<ACE_InputCDR &> (is) >> x;
539 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
540                                       CORBA::ULongLong &x)
542   return static_cast<ACE_InputCDR &> (is) >> x;
545 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
546                                       CORBA::LongDouble &x)
548   return static_cast<ACE_InputCDR &> (is) >> x;
551 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
552                                       CORBA::Float &x)
554   return static_cast<ACE_InputCDR &> (is) >> x;
557 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
558                                       CORBA::Double &x)
560   return static_cast<ACE_InputCDR &> (is) >> x;
563 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
564                                       CORBA::Char* &x)
566   return static_cast<ACE_InputCDR &> (is) >> x;
569 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
570                                       CORBA::WChar* &x)
572   return static_cast<ACE_InputCDR &> (is) >> x;
575 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
576                                       ACE_InputCDR::to_string x)
578   CORBA::Boolean const marshal_flag =
579     is >> const_cast<ACE_CDR::Char *&> (x.val_);
580   if (marshal_flag && x.bound_ != 0 && x.val_ != 0 &&
581       std::strlen (x.val_) > x.bound_)
582     {
583       throw CORBA::BAD_PARAM ();
584     }
585   return marshal_flag;
588 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
589                                       ACE_InputCDR::to_wstring x)
591   CORBA::Boolean const marshal_flag =
592     is >> const_cast<ACE_CDR::WChar *&> (x.val_);
593   if (marshal_flag && x.bound_ != 0 && x.val_ != 0 &&
594       ACE_OS::strlen (x.val_) > x.bound_)
595     {
596       throw CORBA::BAD_PARAM ();
597     }
598   return marshal_flag;
601 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
602                                       std::string &x)
604   return static_cast<ACE_InputCDR &> (is) >> x;
607 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
608                                       ACE_InputCDR::to_std_string x)
610   CORBA::Boolean const marshal_flag = is >> x.val_;
611   if (marshal_flag && x.bound_ != 0 && x.val_.size () > x.bound_)
612     {
613       throw CORBA::BAD_PARAM ();
614     }
615   return marshal_flag;
618 #if !defined(ACE_LACKS_STD_WSTRING)
619 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
620                                       std::wstring &x)
622   return static_cast<ACE_InputCDR &> (is) >> x;
625 ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is,
626                                       ACE_InputCDR::to_std_wstring x)
628   CORBA::Boolean const marshal_flag = is >> x.val_;
629   if (marshal_flag && x.bound_ != 0 && x.val_.size () > x.bound_)
630     {
631       throw CORBA::BAD_PARAM ();
632     }
633   return marshal_flag;
635 #endif /* ACE_LACKS_STD_WSTRING */
637 TAO_END_VERSIONED_NAMESPACE_DECL