#include <Object_KeyC.h>
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 88 of file Object_KeyC.h.
typedef ObjectKey_var TAO::ObjectKey::_var_type |
Definition at line 106 of file Object_KeyC.h.
TAO::ObjectKey::ObjectKey | ( | void | ) |
Definition at line 58 of file Object_KeyC.cpp.
{}
TAO::ObjectKey::ObjectKey | ( | CORBA::ULong | max | ) |
Definition at line 61 of file Object_KeyC.cpp.
: TAO::unbounded_value_sequence< CORBA::Octet > (max) {}
TAO::ObjectKey::ObjectKey | ( | CORBA::ULong | max, | |
CORBA::ULong | length, | |||
CORBA::Octet * | buffer, | |||
CORBA::Boolean | release = false | |||
) |
Definition at line 70 of file Object_KeyC.cpp.
: TAO::unbounded_value_sequence< CORBA::Octet > (max, length, buffer, release) {}
TAO::ObjectKey::ObjectKey | ( | const ObjectKey & | seq | ) |
Definition at line 82 of file Object_KeyC.cpp.
: TAO::unbounded_value_sequence< CORBA::Octet > (seq) {}
TAO::ObjectKey::~ObjectKey | ( | void | ) |
Definition at line 91 of file Object_KeyC.cpp.
{}
TAO::ObjectKey::ObjectKey | ( | CORBA::ULong | length, | |
const ACE_Message_Block * | mb | |||
) | [inline] |
Definition at line 109 of file Object_KeyC.h.
: 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 154 of file Object_KeyC.cpp.
{ if (str == 0) { seq.length (0); return; } size_t const str_len = ACE_OS::strlen (str); // Ensure sequence length value does not exceed maximum value for // sequence index type (CORBA::ULong). This is mostly an issue for // 64-bit MS Windows builds. CORBA::ULong const len = ACE_Utils::truncate_cast<CORBA::ULong> (str_len); char const * const eos = str + str_len; char const * cp = str; // Set the length of the sequence to be as long as we'll possibly // need...we'll reset it to the actual length later. seq.length (len); CORBA::ULong i = 0; for (; cp < eos && i < len; ++i) { if (*cp == '%' || *cp == '\\') { // This is an escaped non-printable, // so we decode the hex values into // the sequence's octet seq[i] = static_cast<CORBA::Octet> (ACE::hex2byte (cp[1]) << 4); seq[i] |= static_cast<CORBA::Octet> (ACE::hex2byte (cp[2])); cp += 3; } else // Copy it in seq[i] = *cp++; } // Set the length appropriately seq.length (i); }
CORBA::Boolean TAO::ObjectKey::demarshal_key | ( | TAO::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 203 of file Object_KeyC.cpp.
{ CORBA::ULong _tao_seq_len; if (strm >> _tao_seq_len) { // Add a check to the length of the sequence // to make sure it does not exceed the length // of the stream. (See bug 58.) if (_tao_seq_len > strm.length ()) { return 0; } // Set the length of the sequence. key.length (_tao_seq_len); // If length is 0 we return true. if (0 >= _tao_seq_len) { return 1; } // Retrieve all the elements. #if (TAO_NO_COPY_OCTET_SEQUENCES == 1) if (ACE_BIT_DISABLED (strm.start ()->flags (), ACE_Message_Block::DONT_DELETE)) { key.replace (_tao_seq_len, strm.start ()); key.mb ()->wr_ptr (key.mb()->rd_ptr () + _tao_seq_len); strm.skip_bytes (_tao_seq_len); return 1; } return strm.read_octet_array (key.get_buffer (), _tao_seq_len); #else /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */ return strm.read_octet_array (key.get_buffer (), key.length ()); #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */ } return 0; }
void TAO::ObjectKey::encode_sequence_to_string | ( | char *& | str, | |
TAO::unbounded_value_sequence< CORBA::Octet > const & | seq | |||
) | [static] |
Definition at line 97 of file Object_KeyC.cpp.
{ // We must allocate a buffer which is (gag) 3 times the length // of the sequence, which is the length required in the worst-case // scenario of all non-printable characters. // // There are two strategies here...we could allocate all that space here, // fill it up, then copy-allocate new space of just the right length. // OR, we could just return this space. The classic time-space tradeoff, // and for now we'll let time win out, which means that we only do the // allocation once. CORBA::ULong const seq_len = seq.length (); CORBA::ULong const len = 3 * seq_len; /* space for zero termination not needed */ str = CORBA::string_alloc (len); char * const eos = str + len; char * cp = str; for (CORBA::ULong i = 0; cp < eos && i < seq_len; ++i) { unsigned char bt = seq[i]; if (is_legal (bt)) { *cp++ = static_cast<char> (bt); continue; } *cp++ = '%'; *cp++ = static_cast<char> (ACE::nibble2hex ((bt >> 4) & 0x0f)); *cp++ = static_cast<char> (ACE::nibble2hex (bt & 0x0f)); } // Zero terminate *cp = '\0'; }
CORBA::Boolean TAO::ObjectKey::is_legal | ( | unsigned char | c | ) | [static] |
Definition at line 137 of file Object_KeyC.cpp.
{ if (isalnum (c)) { return true; } else { return ( c == ';' || c == '/' ||c == ':' || c == '?' || c == '@' || c == '&' ||c == '=' || c == '+' || c == '$' || c == ',' ||c == '_' || c == '.' || c == '!' || c == '~' ||c == '*' || c == '\'' || c == '-' || c == '(' || c == ')' ); } }