=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / interop-tests / wchar / interop_wchar_i.cpp
blob6a9597d01edeeda9bd14743e5a653573318f45c4
1 // -*- C++ -*-
2 #include "interop_wchar_i.h"
4 // Implementation skeleton constructor
5 interop_WChar_Passer_i::interop_WChar_Passer_i (CORBA::ORB_ptr o,
6 int verbose)
7 : orb_(CORBA::ORB::_duplicate (o)),
8 ref_ (verbose)
12 // Implementation skeleton destructor
13 interop_WChar_Passer_i::~interop_WChar_Passer_i ()
17 char *
18 interop_WChar_Passer_i::orb_name ()
20 return CORBA::string_dup ("TAO");
23 CORBA::Boolean
24 interop_WChar_Passer_i::wchar_to_server (CORBA::WChar test,
25 CORBA::Short key)
27 return ref_.match_wchar (key,test);
30 CORBA::WChar
31 interop_WChar_Passer_i::wchar_from_server (CORBA::Short key)
33 return ref_.get_wchar (key);
36 CORBA::Boolean
37 interop_WChar_Passer_i::wstring_to_server (const CORBA::WChar * test,
38 CORBA::Short key)
40 return ref_.match_wstring(key,test);
43 CORBA::WChar *
44 interop_WChar_Passer_i::wstring_from_server (CORBA::Short key)
46 return CORBA::wstring_dup (ref_.get_wstring(key));
49 CORBA::Boolean
50 interop_WChar_Passer_i::warray_to_server (const interop::warray test,
51 CORBA::Short key)
53 return ref_.match_warray(key,test);
56 interop::warray_slice *
57 interop_WChar_Passer_i::warray_from_server (CORBA::Short key)
59 return interop::warray_dup (ref_.get_warray(key));
62 CORBA::Boolean
63 interop_WChar_Passer_i::wstruct_to_server (const interop::wstruct & test,
64 CORBA::Short key)
66 return
67 ref_.match_wchar (key,test.st_char) &&
68 ref_.match_wstring (key,test.st_string) &&
69 ref_.match_warray (key,test.st_array) &&
70 this->any_to_server (test.st_any,key);
73 interop::wstruct *
74 interop_WChar_Passer_i::wstruct_from_server (CORBA::Short key)
76 interop::wstruct_var ws = new interop::wstruct ();
77 ws->st_char = this->wchar_from_server(key);
78 ws->st_string = this->wstring_from_server(key);
79 ref_.assign_warray (key, ws->st_array);
80 ws->st_any <<= ref_.get_wstring(key);
81 return ws._retn ();
84 CORBA::Boolean
85 interop_WChar_Passer_i::wstructseq_to_server (const interop::wstructseq & test,
86 CORBA::Short key)
88 CORBA::Boolean result = 1;
89 for (CORBA::ULong i = 0; result && i < test.length(); i++)
91 result = this->wstruct_to_server(test[i], key);
93 return result;
96 interop::wstructseq *
97 interop_WChar_Passer_i::wstructseq_from_server (CORBA::Short key)
99 interop::wstructseq_var wsListI = new interop::wstructseq();
100 wsListI->length(5);
102 for (CORBA::ULong i = 0; i < wsListI->length(); i++)
104 wsListI[i].st_char = this->wchar_from_server(key);
105 wsListI[i].st_string = this->wstring_from_server(key);
106 ref_.assign_warray (key, wsListI[i].st_array);
107 // this is to keep Cxx on TRUE64 happy
108 // it won't cast a wide character literal (i.e. L"")
109 // to a CORBA::WChar *. +
110 // {I wonder if sizeof(wchar_t) != sizeof (CORBA::WChar)?}
111 const CORBA::WChar empty_wstring[] = {0};
112 wsListI[i].st_any <<= CORBA::wstring_dup(empty_wstring);
114 return wsListI._retn();
117 CORBA::Boolean
118 interop_WChar_Passer_i::wunion_to_server (const interop::wunion & test,
119 CORBA::Short key)
121 switch (test._d()) {
122 case interop::is_wchar :
123 return this->wchar_to_server (test.u_char(),key);
124 case interop::is_wstring :
125 return this->wstring_to_server (test.u_string(),key);
126 case interop::is_warray :
127 return this->warray_to_server (test.u_array(),key);
128 default:
129 /*return 0*/;
131 return 0;
134 interop::wunion *
135 interop_WChar_Passer_i::wunion_from_server (CORBA::Short key,
136 interop::wchar_types type)
138 interop::wunion *wu = new interop::wunion ();
139 switch (type) {
140 case interop::is_wchar :
141 wu->u_char (ref_.get_wchar(key));
142 break;
143 case interop::is_wstring :
144 wu->u_string (ref_.get_wstring(key));
145 break;
146 case interop::is_warray :
147 wu->u_array (ref_.get_warray(key));
148 break;
150 return wu;
154 CORBA::Boolean
155 interop_WChar_Passer_i::any_to_server (const CORBA::Any &test,
156 CORBA::Short key)
158 CORBA::WChar wc;
159 const CORBA::WChar *ws;
160 CORBA::WString_var wstr;
161 interop::warray_forany forany;
163 if (test >>= CORBA::Any::to_wchar(wc))
165 return this->wchar_to_server(wc,key);
167 else if (test >>= ws)
169 return this->wstring_to_server (ws,key);
171 else if (test >>= forany)
173 return this->warray_to_server (forany.in(),key);
175 return 0;
178 CORBA::Any*
179 interop_WChar_Passer_i::any_from_server (CORBA::Short key,
180 interop::wchar_types type)
182 CORBA::Any *any = new CORBA::Any;
183 switch (type) {
184 case interop::is_wchar :
185 (*any) <<= CORBA::Any::from_wchar(ref_.get_wchar(key));
186 break;
187 case interop::is_wstring :
188 (*any) <<= ref_.get_wstring(key);
189 break;
190 case interop::is_warray :
192 interop::warray_forany forany(ref_.get_warray(key));
193 (*any) <<= forany.in();
194 break;
197 return any;
200 CORBA::Any *
201 interop_WChar_Passer_i::any_echo (const CORBA::Any &test)
203 return new CORBA::Any (test);
206 void
207 interop_WChar_Passer_i::exception_test ( CORBA::Short key)
209 throw interop::WChar_Passer::WStringException(ref_.get_except(key),
210 this->wchar_from_server(key));
213 void
214 interop_WChar_Passer_i::shutdown ()
216 this->orb_->shutdown(0);