summaryrefslogtreecommitdiff
path: root/TAO/interop-tests/wchar/interop_wchar_i.cpp
blob: 907d1c45285ebd00f5c370b0b0747c69706dd5a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// -*- C++ -*-
//
// $Id$

// ****  Code generated by the The ACE ORB (TAO) IDL Compiler ****
// TAO and the TAO IDL Compiler have been developed by:
//       Center for Distributed Object Computing
//       Washington University
//       St. Louis, MO
//       USA
//       http://www.cs.wustl.edu/~schmidt/doc-center.html
// and
//       Distributed Object Computing Laboratory
//       University of California at Irvine
//       Irvine, CA
//       USA
//       http://doc.ece.uci.edu/
//
// Information about TAO is available at:
//     http://www.cs.wustl.edu/~schmidt/TAO.html

// TAO_IDL - Generated from
// be/be_codegen.cpp:986

#include "interop_wchar_i.h"

// Implementation skeleton constructor
interop_WChar_Passer_i::interop_WChar_Passer_i (CORBA::ORB_ptr o,
                                                int verbose)
  : orb_(CORBA::ORB::_duplicate (o)),
    ref_ (verbose)
{
}

// Implementation skeleton destructor
interop_WChar_Passer_i::~interop_WChar_Passer_i (void)
{
}

char *
interop_WChar_Passer_i::orb_name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
    ACE_THROW_SPEC (( CORBA::SystemException ))
{
  return CORBA::string_dup ("TAO");
}

CORBA::Boolean
interop_WChar_Passer_i::wchar_to_server (CORBA::WChar test,
                                         CORBA::Short key
                                         ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  return ref_.match_wchar (key,test);
}

CORBA::WChar
interop_WChar_Passer_i::wchar_from_server (CORBA::Short key
                                           ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  return ref_.get_wchar (key);
}

CORBA::Boolean
interop_WChar_Passer_i::wstring_to_server (const CORBA::WChar * test,
                                           CORBA::Short key
                                           ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  return ref_.match_wstring(key,test);
}

CORBA::WChar *
interop_WChar_Passer_i::wstring_from_server (CORBA::Short key
                                             ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  return CORBA::wstring_dup (ref_.get_wstring(key));
}

CORBA::Boolean
interop_WChar_Passer_i::warray_to_server (const interop::warray test,
                                          CORBA::Short key
                                          ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  return ref_.match_warray(key,test);
}

interop::warray_slice *
interop_WChar_Passer_i::warray_from_server (CORBA::Short key
                                            ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  return interop::warray_dup (ref_.get_warray(key));
}

CORBA::Boolean
interop_WChar_Passer_i::wstruct_to_server (const interop::wstruct & test,
                                           CORBA::Short key
                                           ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  return
    ref_.match_wchar (key,test.st_char) &&
    ref_.match_wstring (key,test.st_string) &&
    ref_.match_warray (key,test.st_array) &&
    this->any_to_server (test.st_any,key);
}

interop::wstruct *
interop_WChar_Passer_i::wstruct_from_server (CORBA::Short key
                                             ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  interop::wstruct *ws = new interop::wstruct ();
  ws->st_char = this->wchar_from_server(key);
  ws->st_string = this->wstring_from_server(key);
  ref_.assign_warray (key, ws->st_array);
  ws->st_any <<= ref_.get_wstring(key);
  return ws;
}

CORBA::Boolean
interop_WChar_Passer_i::wunion_to_server (const interop::wunion & test,
                                          CORBA::Short key
                                          ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  switch (test._d()) {
  case interop::is_wchar :
    return this->wchar_to_server (test.u_char(),key);
  case interop::is_wstring :
    return this->wstring_to_server (test.u_string(),key);
  case interop::is_warray :
    return this->warray_to_server (test.u_array(),key);
  default:;
  }
  return 0;
}

interop::wunion *
interop_WChar_Passer_i::wunion_from_server (CORBA::Short key,
                                            interop::wchar_types type
                                            ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  interop::wunion *wu = new interop::wunion ();
  switch (type) {
  case interop::is_wchar :
    wu->u_char (ref_.get_wchar(key));
    break;
  case interop::is_wstring :
    wu->u_string (ref_.get_wstring(key));
    break;
  case interop::is_warray :
    wu->u_array (ref_.get_warray(key));
    break;
  }
  return wu;
}


CORBA::Boolean
interop_WChar_Passer_i::any_to_server (const CORBA::Any &test,
                                       CORBA::Short key
                                       ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  CORBA::WChar wc;
  const CORBA::WChar *ws;
  CORBA::WString_var wstr;
  interop::warray_forany forany;

  if (test >>= CORBA::Any::to_wchar(wc))
    {
      return this->wchar_to_server(wc,key);
    }
  else if (test >>= ws)
    {
      return this->wstring_to_server (ws,key);
    }
  else if (test >>= forany)
    {
      return this->warray_to_server (forany.in(),key);
    }
  return 0;
}

CORBA::Any*
interop_WChar_Passer_i::any_from_server (CORBA::Short key,
                                         interop::wchar_types type
                                         ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  CORBA::Any *any = new CORBA::Any;
  switch (type) {
  case interop::is_wchar :
    (*any) <<= CORBA::Any::from_wchar(ref_.get_wchar(key));
    break;
  case interop::is_wstring :
    (*any) <<= ref_.get_wstring(key);
    break;
  case interop::is_warray :
    {
      interop::warray_forany forany(ref_.get_warray(key));
      (*any) <<= forany.in();
      break;
    }
  }
  return any;
}

CORBA::Any *
interop_WChar_Passer_i::any_echo (const CORBA::Any &test
                                  ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  return new CORBA::Any (test);
}

void
interop_WChar_Passer_i::exception_test ( CORBA::Short key
                                         ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   interop::WChar_Passer::WStringException))
{
  ACE_THROW (interop::WChar_Passer::WStringException(ref_.get_except(key),
                                             this->wchar_from_server(key)));
}

void
interop_WChar_Passer_i::shutdown (ACE_ENV_SINGLE_ARG_DECL)
  ACE_THROW_SPEC (( CORBA::SystemException ))
{
  this->orb_->shutdown(0 ACE_ENV_ARG_PARAMETER);
}