Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / tao / BD_String_Argument_T.cpp
blob364ad980a68023e3b38cf2a15a82ea5515d415ef
1 #ifndef TAO_BD_STRING_ARGUMENT_T_CPP
2 #define TAO_BD_STRING_ARGUMENT_T_CPP
4 #include "tao/BD_String_Argument_T.h"
5 #include "tao/SystemException.h"
7 #if !defined (__ACE_INLINE__)
8 #include "tao/BD_String_Argument_T.inl"
9 #endif /* __ACE_INLINE__ */
11 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
13 template<typename S_var,
14 size_t BOUND,
15 template <typename> class Insert_Policy>
16 CORBA::Boolean
17 TAO::In_BD_String_Argument_T<S_var,BOUND,Insert_Policy>::marshal (
18 TAO_OutputCDR & cdr)
20 if (this->x_ != 0 && ACE_OS::strlen (this->x_) > BOUND)
22 throw ::CORBA::BAD_PARAM ();
24 return cdr << this->x_;
27 #if TAO_HAS_INTERCEPTORS == 1
29 template<typename S_var,
30 size_t BOUND,
31 template <typename> class Insert_Policy>
32 void
33 TAO::In_BD_String_Argument_T<S_var,BOUND,Insert_Policy>::interceptor_value (
34 CORBA::Any *any) const
36 typedef typename S_var::s_traits::from_type from_type;
37 Insert_Policy<from_type>::any_insert (
38 any,
39 from_type (this->x_, BOUND));
42 #endif /* TAO_HAS_INTERCEPTORS */
44 template<typename S_var,
45 size_t BOUND,
46 template <typename> class Insert_Policy>
47 TAO::In_BD_String_Clonable_Argument_T<S_var,BOUND,Insert_Policy>::~In_BD_String_Clonable_Argument_T ()
49 if (this->is_clone_)
51 typename S_var::s_traits::char_type * tmp =
52 const_cast<typename S_var::s_traits::char_type *> (this->x_);
53 delete [] tmp;
57 template<typename S_var,
58 size_t BOUND,
59 template <typename> class Insert_Policy>
60 TAO::Argument*
61 TAO::In_BD_String_Clonable_Argument_T<S_var,BOUND,Insert_Policy>::clone ()
63 typename S_var::s_traits::char_type * clone_x =
64 new typename S_var::s_traits::char_type [BOUND];
65 ACE_OS::strncpy (clone_x, this->x_, BOUND);
66 In_BD_String_Clonable_Argument_T<S_var,BOUND,Insert_Policy>* clone_arg =
67 new In_BD_String_Clonable_Argument_T<S_var,BOUND,Insert_Policy> (clone_x);
68 clone_arg->is_clone_ = true;
69 return clone_arg;
72 // ===========================================================
74 template<typename S_var,
75 size_t BOUND,
76 template <typename> class Insert_Policy>
77 CORBA::Boolean
78 TAO::Inout_BD_String_Argument_T<S_var,BOUND,Insert_Policy>::marshal (
79 TAO_OutputCDR & cdr)
81 if (this->x_ != 0 && ACE_OS::strlen (this->x_) > BOUND)
83 throw ::CORBA::BAD_PARAM ();
85 return cdr << this->x_;
88 template<typename S_var,
89 size_t BOUND,
90 template <typename> class Insert_Policy>
91 CORBA::Boolean
92 TAO::Inout_BD_String_Argument_T<S_var,BOUND,Insert_Policy>::demarshal (
93 TAO_InputCDR & cdr)
95 S_var tmp = this->x_;
96 CORBA::Boolean const demarshalled = cdr >> this->x_;
97 if (this->x_ != 0 && ACE_OS::strlen (this->x_) > BOUND)
99 S_var for_deletion = this->x_;
100 this->x_ = tmp._retn ();
101 throw ::CORBA::BAD_PARAM ();
103 return demarshalled;
106 #if TAO_HAS_INTERCEPTORS == 1
108 template<typename S_var,
109 size_t BOUND,
110 template <typename> class Insert_Policy>
111 void
112 TAO::Inout_BD_String_Argument_T<S_var,BOUND,Insert_Policy>::interceptor_value (
113 CORBA::Any *any) const
115 typedef typename S_var::s_traits::from_type from_type;
116 Insert_Policy<from_type>::any_insert (
117 any,
118 from_type (this->x_, BOUND));
121 #endif /* TAO_HAS_INTERCEPTORS */
123 // ==============================================================
125 template<typename S_var,
126 size_t BOUND,
127 template <typename> class Insert_Policy>
128 CORBA::Boolean
129 TAO::Out_BD_String_Argument_T<S_var,BOUND,Insert_Policy>::demarshal (
130 TAO_InputCDR & cdr)
132 CORBA::Boolean const demarshalled = cdr >> this->x_;
133 if (this->x_ != 0 && ACE_OS::strlen (this->x_) > BOUND)
135 throw ::CORBA::BAD_PARAM ();
137 return demarshalled;
140 #if TAO_HAS_INTERCEPTORS == 1
142 template<typename S_var,
143 size_t BOUND,
144 template <typename> class Insert_Policy>
145 void
146 TAO::Out_BD_String_Argument_T<S_var,BOUND,Insert_Policy>::interceptor_value (
147 CORBA::Any *any) const
149 typedef typename S_var::s_traits::from_type from_type;
150 Insert_Policy<from_type>::any_insert (
151 any,
152 from_type (this->x_, BOUND));
155 #endif /* TAO_HAS_INTERCEPTORS */
157 // ============================================================
159 template<typename S_var,
160 size_t BOUND,
161 template <typename> class Insert_Policy>
162 CORBA::Boolean
163 TAO::Ret_BD_String_Argument_T<S_var,BOUND,Insert_Policy>::demarshal (
164 TAO_InputCDR & cdr)
166 CORBA::Boolean const demarshalled = cdr >> this->x_.out ();
167 if (this->x_.in () != 0 && ACE_OS::strlen (this->x_.in ()) > BOUND)
169 throw ::CORBA::BAD_PARAM ();
171 return demarshalled;
174 #if TAO_HAS_INTERCEPTORS == 1
176 template<typename S_var,
177 size_t BOUND,
178 template <typename> class Insert_Policy>
179 void
180 TAO::Ret_BD_String_Argument_T<S_var,BOUND,Insert_Policy>::interceptor_value (
181 CORBA::Any *any) const
183 typedef typename S_var::s_traits::from_type from_type;
184 Insert_Policy<from_type>::any_insert (
185 any,
186 from_type (this->x_.in (), BOUND));
189 #endif /* TAO_HAS_INTERCEPTORS */
191 TAO_END_VERSIONED_NAMESPACE_DECL
193 #endif /* TAO_BD_STRING_ARGUMENT_T_CPP */