00001 //============================================================================= 00002 /** 00003 * @file PG_Properties_Encoder.cpp 00004 * 00005 * PG_Properties_Encoder.cpp,v 1.7 2006/03/14 06:14:34 jtc Exp 00006 * 00007 * This file implements classes to help manage the Properties 00008 * defined in the Portable Object Group. 00009 * 00010 * @author Dale Wilson <wilson_d@ociweb.com> 00011 */ 00012 //============================================================================= 00013 #include "orbsvcs/PortableGroup/PG_Properties_Encoder.h" 00014 00015 00016 #if ! defined (__ACE_INLINE__) 00017 #include "orbsvcs/PortableGroup/PG_Properties_Encoder.inl" 00018 #endif /* ! __ACE_INLINE__ */ 00019 00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00021 00022 ////////// 00023 // Properties_Encoder 00024 TAO_PG::Properties_Encoder::Properties_Encoder () 00025 { 00026 } 00027 00028 TAO_PG::Properties_Encoder::~Properties_Encoder () 00029 { 00030 } 00031 00032 00033 void TAO_PG::Properties_Encoder::add ( 00034 const char * name, 00035 const PortableGroup::Value & value) 00036 { 00037 NamedValue nv(name, value); 00038 values_.push_back(nv); 00039 } 00040 00041 void TAO_PG::Properties_Encoder::encode ( 00042 PortableGroup::Properties * property_set) const 00043 { 00044 ACE_ASSERT (property_set != 0); 00045 size_t count = values_.size(); 00046 property_set->length(count); 00047 for( size_t nItem = 0; nItem < count; ++nItem ) 00048 { 00049 const NamedValue & nv = values_[nItem]; 00050 PortableGroup::Property & property = (*property_set)[nItem]; 00051 PortableGroup::Name & nsName = property.nam; 00052 PortableGroup::Value & anyValue = property.val; 00053 // assign the value 00054 anyValue = (nv.value_); 00055 00056 // assign the name 00057 // @@: This restricts the name to a single level with no "kind" 00058 // @@: remove this restriction (?) 00059 nsName.length(1); 00060 CosNaming::NameComponent & nc = nsName[0]; 00061 00062 nc.id = CORBA::string_dup (nv.name_.c_str()); 00063 // nc.kind defaults to empty. Leave it that way (for now) 00064 } 00065 } 00066 00067 TAO_END_VERSIONED_NAMESPACE_DECL