1 --- orig/Object_KeyC.cpp 2008-03-27 08:12:27.000000000 -0500
2 +++ Object_KeyC.cpp 2008-03-27 08:13:40.000000000 -0500
4 #pragma option -w-rvl -w-rch -w-ccc -w-aus -w-sig
5 #endif /* __BORLANDC__ */
8 +#include "ace/Truncate.h"
9 +#include "ace/OS_NS_string.h"
10 +#include "ace/os_include/os_ctype.h"
12 // TAO_IDL - Generated from
13 // be\be_visitor_arg_traits.cpp:70
16 TAO::ObjectKey::~ObjectKey (void)
22 +TAO::ObjectKey::encode_sequence_to_string (char* & str,
23 + TAO::unbounded_value_sequence<CORBA::Octet> const & seq)
25 + // We must allocate a buffer which is (gag) 3 times the length
26 + // of the sequence, which is the length required in the worst-case
27 + // scenario of all non-printable characters.
29 + // There are two strategies here...we could allocate all that space here,
30 + // fill it up, then copy-allocate new space of just the right length.
31 + // OR, we could just return this space. The classic time-space tradeoff,
32 + // and for now we'll let time win out, which means that we only do the
34 + CORBA::ULong const seq_len = seq.length ();
35 + CORBA::ULong const len = 3 * seq_len; /* space for zero termination
37 + str = CORBA::string_alloc (len);
39 + char * const eos = str + len;
42 + for (CORBA::ULong i = 0;
43 + cp < eos && i < seq_len;
46 + unsigned char bt = seq[i];
49 + *cp++ = static_cast<char> (bt);
54 + *cp++ = static_cast<char> (ACE::nibble2hex ((bt >> 4) & 0x0f));
55 + *cp++ = static_cast<char> (ACE::nibble2hex (bt & 0x0f));
62 +TAO::ObjectKey::is_legal (unsigned char c)
70 + return ( c == ';' || c == '/' ||c == ':' || c == '?' ||
71 + c == '@' || c == '&' ||c == '=' || c == '+' ||
72 + c == '$' || c == ',' ||c == '_' || c == '.' ||
73 + c == '!' || c == '~' ||c == '*' || c == '\'' ||
74 + c == '-' || c == '(' || c == ')' );
79 +TAO::ObjectKey::decode_string_to_sequence (
80 + TAO::unbounded_value_sequence<CORBA::Octet> & seq,
89 + size_t const str_len = ACE_OS::strlen (str);
91 + // Ensure sequence length value does not exceed maximum value for
92 + // sequence index type (CORBA::ULong). This is mostly an issue for
93 + // 64-bit MS Windows builds.
94 + CORBA::ULong const len =
95 + ACE_Utils::truncate_cast<CORBA::ULong> (str_len);
97 + char const * const eos = str + str_len;
98 + char const * cp = str;
100 + // Set the length of the sequence to be as long as we'll possibly
101 + // need...we'll reset it to the actual length later.
104 + CORBA::ULong i = 0;
106 + cp < eos && i < len;
109 + if (*cp == '%' || *cp == '\\')
111 + // This is an escaped non-printable,
112 + // so we decode the hex values into
113 + // the sequence's octet
114 + seq[i] = static_cast<CORBA::Octet> (ACE::hex2byte (cp[1]) << 4);
115 + seq[i] |= static_cast<CORBA::Octet> (ACE::hex2byte (cp[2]));
123 + // Set the length appropriately
127 +/*static*/ CORBA::Boolean
128 +TAO::ObjectKey::demarshal_key (TAO::ObjectKey &key,
129 + TAO_InputCDR &strm)
131 + CORBA::ULong _tao_seq_len;
133 + if (strm >> _tao_seq_len)
135 + // Add a check to the length of the sequence
136 + // to make sure it does not exceed the length
137 + // of the stream. (See bug 58.)
138 + if (_tao_seq_len > strm.length ())
143 + // Set the length of the sequence.
144 + key.length (_tao_seq_len);
146 + // If length is 0 we return true.
147 + if (0 >= _tao_seq_len)
152 + // Retrieve all the elements.
153 +#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
154 + if (ACE_BIT_DISABLED (strm.start ()->flags (),
155 + ACE_Message_Block::DONT_DELETE))
157 + key.replace (_tao_seq_len, strm.start ());
158 + key.mb ()->wr_ptr (key.mb()->rd_ptr () + _tao_seq_len);
159 + strm.skip_bytes (_tao_seq_len);
162 + return strm.read_octet_array (key.get_buffer (),
164 +#else /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */
165 + return strm.read_octet_array (key.get_buffer (), key.length ());
166 +#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */
172 #endif /* end #if !defined */
174 // TAO_IDL - Generated from
175 --- orig/Object_KeyC.h 2008-03-27 08:13:22.000000000 -0500
176 +++ Object_KeyC.h 2008-03-27 08:13:40.000000000 -0500
178 : TAO::unbounded_value_sequence<CORBA::Octet> (length, mb) {}
179 #endif /* TAO_NO_COPY_OCTET_SEQUENCE == 1 */
183 + static void encode_sequence_to_string (
185 + TAO::unbounded_value_sequence<CORBA::Octet> const & seq
187 + static void decode_string_to_sequence (
188 + TAO::unbounded_value_sequence<CORBA::Octet> &seq,
191 + static CORBA::Boolean is_legal (unsigned char c);
193 + /// A special method that gives no regard to how the ORB has
194 + /// configured the resource factory. This will be used only
195 + /// during Profile decoding and should be safe. This is a solution
196 + /// for the bug report [Bug 1616]
197 + static CORBA::Boolean demarshal_key (ObjectKey & key,
198 + TAO_InputCDR & cdr);
201 #endif /* end #if !defined */