2 // **** Code generated by the The ACE ORB (TAO) IDL Compiler ****
3 // TAO and the TAO IDL Compiler have been developed by:
4 // Center for Distributed Object Computing
5 // Washington University
8 // http://www.cs.wustl.edu/~schmidt/doc-center.html
10 // Distributed Object Computing Laboratory
11 // University of California at Irvine
14 // http://doc.ece.uci.edu/
16 // Institute for Software Integrated Systems
17 // Vanderbilt University
20 // http://www.isis.vanderbilt.edu/
22 // Information about TAO is available at:
23 // http://www.dre.vanderbilt.edu/~schmidt/TAO.html
25 // TAO_IDL - Generated from
26 // be\be_codegen.cpp:291
29 #include "tao/Object_KeyC.h"
31 #include "tao/ORB_Core.h"
34 #include "ace/Truncate.h"
35 #include "ace/OS_NS_string.h"
36 #include "ace/os_include/os_ctype.h"
39 // TAO_IDL - Generated from
40 // be\be_visitor_arg_traits.cpp:70
42 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
44 // Arg traits specializations.
50 // TAO_IDL - Generated from
51 // be\be_visitor_sequence/sequence_cs.cpp:65
53 #if !defined (_TAO_OBJECTKEY_CS_)
54 #define _TAO_OBJECTKEY_CS_
56 TAO::ObjectKey::ObjectKey ()
59 TAO::ObjectKey::ObjectKey (
62 : TAO::unbounded_value_sequence
<
68 TAO::ObjectKey::ObjectKey (
71 CORBA::Octet
* buffer
,
72 CORBA::Boolean release
74 : TAO::unbounded_value_sequence
<
77 (max
, length
, buffer
, release
)
80 TAO::ObjectKey::~ObjectKey ()
86 TAO::ObjectKey::encode_sequence_to_string (char* & str
,
87 TAO::unbounded_value_sequence
<CORBA::Octet
> const & seq
)
89 // We must allocate a buffer which is (gag) 3 times the length
90 // of the sequence, which is the length required in the worst-case
91 // scenario of all non-printable characters.
93 // There are two strategies here...we could allocate all that space here,
94 // fill it up, then copy-allocate new space of just the right length.
95 // OR, we could just return this space. The classic time-space tradeoff,
96 // and for now we'll let time win out, which means that we only do the
98 CORBA::ULong
const seq_len
= seq
.length ();
99 CORBA::ULong
const len
= 3 * seq_len
; /* space for zero termination
101 str
= CORBA::string_alloc (len
);
103 char * const eos
= str
+ len
;
106 for (CORBA::ULong i
= 0;
107 cp
< eos
&& i
< seq_len
;
110 unsigned char bt
= seq
[i
];
113 *cp
++ = static_cast<char> (bt
);
118 *cp
++ = static_cast<char> (ACE::nibble2hex ((bt
>> 4) & 0x0f));
119 *cp
++ = static_cast<char> (ACE::nibble2hex (bt
& 0x0f));
126 TAO::ObjectKey::is_legal (unsigned char c
)
134 return ( c
== ';' || c
== '/' ||c
== ':' || c
== '?' ||
135 c
== '@' || c
== '&' ||c
== '=' || c
== '+' ||
136 c
== '$' || c
== ',' ||c
== '_' || c
== '.' ||
137 c
== '!' || c
== '~' ||c
== '*' || c
== '\'' ||
138 c
== '-' || c
== '(' || c
== ')' );
143 TAO::ObjectKey::decode_string_to_sequence (
144 TAO::unbounded_value_sequence
<CORBA::Octet
> & seq
,
153 size_t const str_len
= std::strlen (str
);
155 // Ensure sequence length value does not exceed maximum value for
156 // sequence index type (CORBA::ULong). This is mostly an issue for
157 // 64-bit MS Windows builds.
158 CORBA::ULong
const len
=
159 ACE_Utils::truncate_cast
<CORBA::ULong
> (str_len
);
161 char const * const eos
= str
+ str_len
;
162 char const * cp
= str
;
164 // Set the length of the sequence to be as long as we'll possibly
165 // need...we'll reset it to the actual length later.
173 if (*cp
== '%' || *cp
== '\\')
175 // This is an escaped non-printable,
176 // so we decode the hex values into
177 // the sequence's octet
178 seq
[i
] = static_cast<CORBA::Octet
> (ACE::hex2byte (cp
[1]) << 4);
179 seq
[i
] |= static_cast<CORBA::Octet
> (ACE::hex2byte (cp
[2]));
187 // Set the length appropriately
191 /*static*/ CORBA::Boolean
192 TAO::ObjectKey::demarshal_key (TAO::ObjectKey
&key
,
195 CORBA::ULong _tao_seq_len
;
197 if (strm
>> _tao_seq_len
)
199 // Add a check to the length of the sequence
200 // to make sure it does not exceed the length
201 // of the stream. (See bug 58.)
202 if (_tao_seq_len
> strm
.length ())
207 // Set the length of the sequence.
208 key
.length (_tao_seq_len
);
210 // If length is 0 we return true.
211 if (0 >= _tao_seq_len
)
216 // Retrieve all the elements.
217 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
218 if (ACE_BIT_DISABLED (strm
.start ()->flags (),
219 ACE_Message_Block::DONT_DELETE
))
221 key
.replace (_tao_seq_len
, strm
.start ());
222 key
.mb ()->wr_ptr (key
.mb()->rd_ptr () + _tao_seq_len
);
223 strm
.skip_bytes (_tao_seq_len
);
226 return strm
.read_octet_array (key
.get_buffer (),
228 #else /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */
229 return strm
.read_octet_array (key
.get_buffer (), key
.length ());
230 #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */
236 #endif /* end #if !defined */
238 // TAO_IDL - Generated from
239 // be\be_visitor_sequence/cdr_op_cs.cpp:96
241 #if !defined _TAO_CDR_OP_TAO_ObjectKey_CPP_
242 #define _TAO_CDR_OP_TAO_ObjectKey_CPP_
244 CORBA::Boolean
operator<< (
246 const TAO::ObjectKey
&_tao_sequence
249 return TAO::marshal_sequence(strm
, _tao_sequence
);
252 CORBA::Boolean
operator>> (
254 TAO::ObjectKey
&_tao_sequence
257 return TAO::demarshal_sequence(strm
, _tao_sequence
);
260 #endif /* _TAO_CDR_OP_TAO_ObjectKey_CPP_ */
262 TAO_END_VERSIONED_NAMESPACE_DECL