#include <Object_KeyC.h>
Inheritance diagram for TAO::ObjectKey:
Public Types | |
typedef ObjectKey_var | _var_type |
Public Member Functions | |
ObjectKey (void) | |
ObjectKey (CORBA::ULong max) | |
ObjectKey (CORBA::ULong max, CORBA::ULong length, CORBA::Octet *buffer, CORBA::Boolean release=false) | |
ObjectKey (const ObjectKey &) | |
~ObjectKey (void) | |
ObjectKey (CORBA::ULong length, const ACE_Message_Block *mb) | |
Static Public Member Functions | |
static void | encode_sequence_to_string (char *&str, TAO::unbounded_value_sequence< CORBA::Octet > const &seq) |
static void | decode_string_to_sequence (TAO::unbounded_value_sequence< CORBA::Octet > &seq, char const *str) |
static CORBA::Boolean | is_legal (unsigned char c) |
static CORBA::Boolean | demarshal_key (ObjectKey &key, TAO_InputCDR &cdr) |
Definition at line 92 of file Object_KeyC.h.
typedef ObjectKey_var TAO::ObjectKey::_var_type |
Definition at line 110 of file Object_KeyC.h.
TAO::ObjectKey::ObjectKey | ( | void | ) |
TAO::ObjectKey::ObjectKey | ( | CORBA::ULong | max | ) |
Definition at line 65 of file Object_KeyC.cpp.
References ObjectKey().
00068 : TAO::unbounded_value_sequence< 00069 CORBA::Octet 00070 > 00071 (max) 00072 {}
TAO::ObjectKey::ObjectKey | ( | CORBA::ULong | max, | |
CORBA::ULong | length, | |||
CORBA::Octet * | buffer, | |||
CORBA::Boolean | release = false | |||
) |
Definition at line 74 of file Object_KeyC.cpp.
References ObjectKey().
00080 : TAO::unbounded_value_sequence< 00081 CORBA::Octet 00082 > 00083 (max, length, buffer, release) 00084 {}
TAO::ObjectKey::ObjectKey | ( | const ObjectKey & | ) |
Definition at line 86 of file Object_KeyC.cpp.
References ObjectKey().
00089 : TAO::unbounded_value_sequence< 00090 CORBA::Octet 00091 > 00092 (seq) 00093 {}
TAO::ObjectKey::~ObjectKey | ( | void | ) |
TAO::ObjectKey::ObjectKey | ( | CORBA::ULong | length, | |
const ACE_Message_Block * | mb | |||
) | [inline] |
Definition at line 113 of file Object_KeyC.h.
00117 : TAO::unbounded_value_sequence<CORBA::Octet> (length, mb) {}
void TAO::ObjectKey::decode_string_to_sequence | ( | TAO::unbounded_value_sequence< CORBA::Octet > & | seq, | |
char const * | str | |||
) | [static] |
Definition at line 158 of file Object_KeyC.cpp.
References decode_string_to_sequence(), ACE::hex2byte(), and ACE_OS::strlen().
Referenced by decode_string_to_sequence().
00161 { 00162 if (str == 0) 00163 { 00164 seq.length (0); 00165 return; 00166 } 00167 00168 size_t const str_len = ACE_OS::strlen (str); 00169 00170 // Ensure sequence length value does not exceed maximum value for 00171 // sequence index type (CORBA::ULong). This is mostly an issue for 00172 // 64-bit MS Windows builds. 00173 CORBA::ULong const len = 00174 ACE_Utils::truncate_cast<CORBA::ULong> (str_len); 00175 00176 char const * const eos = str + str_len; 00177 char const * cp = str; 00178 00179 // Set the length of the sequence to be as long as we'll possibly 00180 // need...we'll reset it to the actual length later. 00181 seq.length (len); 00182 00183 CORBA::ULong i = 0; 00184 for (; 00185 cp < eos && i < len; 00186 ++i) 00187 { 00188 if (*cp == '%' || *cp == '\\') 00189 { 00190 // This is an escaped non-printable, 00191 // so we decode the hex values into 00192 // the sequence's octet 00193 seq[i] = static_cast<CORBA::Octet> (ACE::hex2byte (cp[1]) << 4); 00194 seq[i] |= static_cast<CORBA::Octet> (ACE::hex2byte (cp[2])); 00195 cp += 3; 00196 } 00197 else 00198 // Copy it in 00199 seq[i] = *cp++; 00200 } 00201 00202 // Set the length appropriately 00203 seq.length (i); 00204 }
CORBA::Boolean TAO::ObjectKey::demarshal_key | ( | ObjectKey & | key, | |
TAO_InputCDR & | cdr | |||
) | [static] |
A special method that gives no regard to how the ORB has configured the resource factory. This will be used only during Profile decoding and should be safe. This is a solution for the bug report [Bug 1616]
Definition at line 207 of file Object_KeyC.cpp.
References ACE_BIT_DISABLED, demarshal_key(), ACE_Message_Block::DONT_DELETE, ACE_Message_Block::flags(), ACE_InputCDR::length(), ACE_InputCDR::read_octet_array(), ACE_InputCDR::skip_bytes(), and ACE_InputCDR::start().
Referenced by demarshal_key().
00209 { 00210 CORBA::ULong _tao_seq_len; 00211 00212 if (strm >> _tao_seq_len) 00213 { 00214 // Add a check to the length of the sequence 00215 // to make sure it does not exceed the length 00216 // of the stream. (See bug 58.) 00217 if (_tao_seq_len > strm.length ()) 00218 { 00219 return 0; 00220 } 00221 00222 // Set the length of the sequence. 00223 key.length (_tao_seq_len); 00224 00225 // If length is 0 we return true. 00226 if (0 >= _tao_seq_len) 00227 { 00228 return 1; 00229 } 00230 00231 // Retrieve all the elements. 00232 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1) 00233 if (ACE_BIT_DISABLED (strm.start ()->flags (), 00234 ACE_Message_Block::DONT_DELETE)) 00235 { 00236 key.replace (_tao_seq_len, strm.start ()); 00237 key.mb ()->wr_ptr (key.mb()->rd_ptr () + _tao_seq_len); 00238 strm.skip_bytes (_tao_seq_len); 00239 return 1; 00240 } 00241 return strm.read_octet_array (key.get_buffer (), 00242 _tao_seq_len); 00243 #else /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */ 00244 return strm.read_octet_array (key.get_buffer (), key.length ()); 00245 #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */ 00246 00247 } 00248 return 0; 00249 }
void TAO::ObjectKey::encode_sequence_to_string | ( | char *& | str, | |
TAO::unbounded_value_sequence< CORBA::Octet > const & | seq | |||
) | [static] |
Definition at line 101 of file Object_KeyC.cpp.
References encode_sequence_to_string(), is_legal(), ACE::nibble2hex(), and CORBA::string_alloc().
Referenced by encode_sequence_to_string().
00103 { 00104 // We must allocate a buffer which is (gag) 3 times the length 00105 // of the sequence, which is the length required in the worst-case 00106 // scenario of all non-printable characters. 00107 // 00108 // There are two strategies here...we could allocate all that space here, 00109 // fill it up, then copy-allocate new space of just the right length. 00110 // OR, we could just return this space. The classic time-space tradeoff, 00111 // and for now we'll let time win out, which means that we only do the 00112 // allocation once. 00113 CORBA::ULong const seq_len = seq.length (); 00114 CORBA::ULong const len = 3 * seq_len; /* space for zero termination 00115 not needed */ 00116 str = CORBA::string_alloc (len); 00117 00118 char * const eos = str + len; 00119 char * cp = str; 00120 00121 for (CORBA::ULong i = 0; 00122 cp < eos && i < seq_len; 00123 ++i) 00124 { 00125 unsigned char bt = seq[i]; 00126 if (is_legal (bt)) 00127 { 00128 *cp++ = static_cast<char> (bt); 00129 continue; 00130 } 00131 00132 *cp++ = '%'; 00133 *cp++ = static_cast<char> (ACE::nibble2hex ((bt >> 4) & 0x0f)); 00134 *cp++ = static_cast<char> (ACE::nibble2hex (bt & 0x0f)); 00135 } 00136 // Zero terminate 00137 *cp = '\0'; 00138 }
CORBA::Boolean TAO::ObjectKey::is_legal | ( | unsigned char | c | ) | [static] |
Definition at line 141 of file Object_KeyC.cpp.
References is_legal().
Referenced by encode_sequence_to_string(), and is_legal().
00142 { 00143 if (isalnum (c)) 00144 { 00145 return true; 00146 } 00147 else 00148 { 00149 return ( c == ';' || c == '/' ||c == ':' || c == '?' || 00150 c == '@' || c == '&' ||c == '=' || c == '+' || 00151 c == '$' || c == ',' ||c == '_' || c == '.' || 00152 c == '!' || c == '~' ||c == '*' || c == '\'' || 00153 c == '-' || c == '(' || c == ')' ); 00154 } 00155 }