summaryrefslogtreecommitdiff
path: root/TAO/tao/any.i
blob: e2232bf0fc4b75a6118f17b84b0a441758d440e2 (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
ACE_INLINE void *
CORBA_Any::operator new (size_t, const void *p)
{
  return (void *) p;
}

ACE_INLINE void *
CORBA_Any::operator new (size_t s)
{
  return ::operator new (s);
}

ACE_INLINE void
CORBA_Any::operator delete (void *p)
{
  ::operator delete (p);
}

// insertion operators

ACE_INLINE void
CORBA_Any::operator<<= (CORBA::Short s)
{
  replace (CORBA::_tc_short, new CORBA::Short (s), CORBA::B_TRUE);
}

ACE_INLINE void
CORBA_Any::operator<<= (CORBA::UShort s)
{
  replace (CORBA::_tc_ushort, new CORBA::UShort (s), CORBA::B_TRUE);
}

ACE_INLINE void
CORBA_Any::operator<<= (CORBA::Long l)
{
  replace (CORBA::_tc_long, new CORBA::Long (l), CORBA::B_TRUE);
}

ACE_INLINE void
CORBA_Any::operator<<= (CORBA::ULong l)
{
  replace (CORBA::_tc_ulong, new CORBA::ULong (l), CORBA::B_TRUE);
}

ACE_INLINE void
CORBA_Any::operator<<= (CORBA::Float f)
{
  replace (CORBA::_tc_float, new CORBA::Float (f), CORBA::B_TRUE);
}

ACE_INLINE void
CORBA_Any::operator<<= (CORBA::Double d)
{
  replace (CORBA::_tc_double, new CORBA::Double (d), CORBA::B_TRUE);
}

ACE_INLINE void
CORBA_Any::operator<<= (const CORBA_Any& a)
{
  replace (CORBA::_tc_any, new CORBA_Any (a), CORBA::B_TRUE);
}

ACE_INLINE void
CORBA_Any::operator<<= (const char* s)
{
  replace (CORBA::_tc_string, CORBA::string_dup (s), CORBA::B_TRUE);
}

// implementing the special types
ACE_INLINE
CORBA_Any::from_boolean::from_boolean (CORBA::Boolean b)
  : val_ (b)
{
}

ACE_INLINE
CORBA_Any::to_boolean::to_boolean (CORBA::Boolean &b)
  : ref_ (b)
{
}

ACE_INLINE
CORBA_Any::from_octet::from_octet (CORBA::Octet o)
  : val_ (o)
{
}

ACE_INLINE
CORBA_Any::to_octet::to_octet (CORBA::Octet &o)
  : ref_ (o)
{
}

ACE_INLINE
CORBA_Any::from_char::from_char (CORBA::Char c)
  : val_ (c)
{
}

ACE_INLINE
CORBA_Any::to_char::to_char (CORBA::Char &c)
  : ref_ (c)
{
}

ACE_INLINE
CORBA_Any::from_string::from_string (char *s, CORBA::ULong b, CORBA::Boolean nocopy)
  : val_ (s),
    bound_ (b),
    nocopy_ (nocopy)
{
}

ACE_INLINE
CORBA_Any::to_string::to_string (char *&s, CORBA::ULong b)
  : ref_ (s),
    bound_ (b)
{
}

// insertion from special types

// @@ Andy, please take a look at this method and make sure it's what
// you intended.  I couldn't find it defined anywhere.  --cjc
ACE_INLINE void
CORBA_Any::replace (CORBA::TypeCode_ptr type,
                    const void *value,
                    CORBA::Boolean orb_owns_data)
{
  CORBA_Environment e;
  this->replace(type, value, orb_owns_data, e);
}


ACE_INLINE void
CORBA_Any::operator<<= (from_boolean b)
{
  replace (CORBA::_tc_boolean, new CORBA::Boolean (b.val_), CORBA::B_TRUE);
}

ACE_INLINE void
CORBA_Any::operator<<= (from_octet o)
{
  replace (CORBA::_tc_octet, new CORBA::Octet (o.val_), CORBA::B_TRUE);
}

ACE_INLINE void
CORBA_Any::operator<<= (from_char c)
{
  replace (CORBA::_tc_char, new CORBA::Char (c.val_), CORBA::B_TRUE);
}

ACE_INLINE void
CORBA_Any::operator<<= (from_string s)
{
  if (s.nocopy_)
    replace (CORBA::_tc_string,  s.val_, CORBA::B_TRUE);
  else
    replace (CORBA::_tc_string, CORBA::string_dup (s.val_), CORBA::B_TRUE);
}

// extraction: these are safe and hence we have to check that the typecode of
// the Any is equal to the one we are trying to extract into

ACE_INLINE CORBA::Boolean
CORBA_Any::operator>>= (CORBA::Short &s) const
{
  CORBA::Environment env;

  if (type_->equal (CORBA::_tc_short, env))
    {
      s = *(CORBA::Short *) value_;
      return CORBA::B_TRUE;
    }
  else
    return CORBA::B_FALSE;
}