00001
00002
00003 #ifndef ACE_LOCAL_NAME_SPACE_T_CPP
00004 #define ACE_LOCAL_NAME_SPACE_T_CPP
00005
00006 #include "ace/ACE.h"
00007
00008 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00009 # pragma once
00010 #endif
00011
00012 #include "ace/Local_Name_Space.h"
00013 #include "ace/Auto_Ptr.h"
00014 #include "ace/Guard_T.h"
00015 #include "ace/OS_NS_regex.h"
00016 #include "ace/OS_NS_string.h"
00017 #include "ace/OS_NS_unistd.h"
00018
00019 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 template <class ALLOCATOR>
00022 ACE_Name_Space_Map<ALLOCATOR>::ACE_Name_Space_Map (ALLOCATOR *alloc)
00023 : MAP_MANAGER (alloc)
00024 {
00025 ACE_TRACE ("ACE_Name_Space_Map::ACE_Name_Space_Map");
00026 }
00027
00028 template <class ALLOCATOR> int
00029 ACE_Name_Space_Map<ALLOCATOR>::close (ALLOCATOR *alloc)
00030 {
00031 ACE_TRACE ("ACE_Name_Space_Map::close");
00032
00033 this->table_allocator_ = alloc;
00034 this->entry_allocator_ = alloc;
00035 return this->close_i ();
00036 }
00037
00038 template <class ALLOCATOR> int
00039 ACE_Name_Space_Map<ALLOCATOR>::bind (const ACE_NS_String &ext_id,
00040 const ACE_NS_Internal &int_id,
00041 ALLOCATOR *alloc)
00042 {
00043 ACE_TRACE ("ACE_Name_Space_Map::bind");
00044
00045 this->table_allocator_ = alloc;
00046 this->entry_allocator_ = alloc;
00047 return this->bind_i (ext_id, int_id);
00048 }
00049
00050 template <class ALLOCATOR> int
00051 ACE_Name_Space_Map<ALLOCATOR>::unbind (const ACE_NS_String &ext_id,
00052 ACE_NS_Internal &int_id,
00053 ALLOCATOR *alloc)
00054 {
00055 ACE_TRACE ("ACE_Name_Space_Map::unbind");
00056
00057 this->table_allocator_ = alloc;
00058 this->entry_allocator_ = alloc;
00059 return this->unbind_i (ext_id, int_id);
00060 }
00061
00062 template <class ALLOCATOR> int
00063 ACE_Name_Space_Map<ALLOCATOR>::rebind (const ACE_NS_String &ext_id,
00064 const ACE_NS_Internal &int_id,
00065 ACE_NS_String &old_ext_id,
00066 ACE_NS_Internal &old_int_id,
00067 ALLOCATOR *alloc)
00068 {
00069 ACE_TRACE ("ACE_Name_Space_Map::rebind");
00070
00071 this->table_allocator_ = alloc;
00072 this->entry_allocator_ = alloc;
00073 return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id);
00074 }
00075
00076 template <class ALLOCATOR> int
00077 ACE_Name_Space_Map<ALLOCATOR>::find (const ACE_NS_String &ext_id,
00078 ACE_NS_Internal &int_id,
00079 ALLOCATOR *alloc)
00080 {
00081 ACE_TRACE ("ACE_Name_Space_Map::find");
00082
00083 this->table_allocator_ = alloc;
00084 this->entry_allocator_ = alloc;
00085 return this->find_i (ext_id, int_id);
00086 }
00087
00088 #if defined (ACE_WIN32)
00089 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00090 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::remap (EXCEPTION_POINTERS *ep)
00091 {
00092 ACE_TRACE ("ACE_Local_Name_Space::remap");
00093
00094 void *addr = (void *) ep->ExceptionRecord->ExceptionInformation[1];
00095
00096
00097
00098
00099 if (this->allocator_->alloc ().memory_pool ().remap (addr) == -1)
00100
00101 return EXCEPTION_CONTINUE_SEARCH;
00102
00103 #if __X86__
00104
00105 ep->ContextRecord->Edi = (DWORD) addr;
00106 #elif __MIPS__
00107 ep->ContextRecord->IntA0 =
00108 ep->ContextRecord->IntV0 = (DWORD) addr;
00109 ep->ContextRecord->IntT5 = ep->ContextRecord->IntA0 + 3;
00110 #endif
00111
00112 return EXCEPTION_CONTINUE_EXECUTION;
00113 }
00114 #endif
00115
00116 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00117 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::shared_bind (
00118 const ACE_NS_WString &name,
00119 const ACE_NS_WString &value,
00120 const char *type,
00121 int rebind)
00122 {
00123
00124
00125
00126 int result = 0;
00127 ACE_SEH_TRY
00128 {
00129 result = this->shared_bind_i (name, value, type, rebind);
00130 }
00131 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
00132 {
00133 }
00134 return result;
00135 }
00136
00137 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00138 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::shared_bind_i (
00139 const ACE_NS_WString &name,
00140 const ACE_NS_WString &value,
00141 const char *type,
00142 int rebind)
00143 {
00144
00145 ACE_TRACE ("ACE_Local_Name_Space::shared_bind_i");
00146 const size_t name_len = (name.length () + 1) * sizeof (ACE_WCHAR_T);
00147 const size_t value_len = (value.length () + 1) * sizeof (ACE_WCHAR_T);
00148 const size_t type_len = ACE_OS::strlen (type) + 1;
00149 const size_t total_len = name_len + value_len + type_len;
00150 char *ptr = (char *) this->allocator_->malloc (total_len);
00151
00152 if (ptr == 0)
00153 return -1;
00154 else
00155 {
00156
00157
00158 ACE_WCHAR_T *value_rep = (ACE_WCHAR_T *) (ptr);
00159 ACE_WCHAR_T *name_rep = (ACE_WCHAR_T *) (ptr + value_len);
00160 char *new_type = (char *) (ptr + value_len + name_len);
00161
00162 ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> name_urep (name.rep ());
00163 ACE_Auto_Basic_Array_Ptr<ACE_WCHAR_T> value_urep (value.rep ());
00164 ACE_NS_String new_name (name_rep, name_urep.get (), name_len);
00165 ACE_NS_String new_value (value_rep, value_urep.get (), value_len);
00166
00167 ACE_OS::strcpy (new_type, type);
00168 ACE_NS_Internal new_internal (new_value, new_type);
00169 int result = -1;
00170
00171 if (rebind == 0)
00172 {
00173
00174
00175 result = this->name_space_map_->bind (new_name,
00176 new_internal,
00177 this->allocator_);
00178
00179 if (result == 1)
00180 {
00181
00182
00183 this->allocator_->free ((void *) ptr);
00184 return result;
00185 }
00186 }
00187 else
00188 {
00189
00190
00191
00192 ACE_NS_String old_name;
00193 ACE_NS_Internal old_internal;
00194
00195 result = this->name_space_map_->rebind (new_name, new_internal,
00196 old_name, old_internal,
00197 this->allocator_);
00198 if (result == 1)
00199 {
00200
00201
00202
00203
00204 this->allocator_->free ((void *) (old_internal.value ()).fast_rep ());
00205 }
00206 }
00207
00208 if (result == -1)
00209
00210 this->allocator_->free ((void *) ptr);
00211 else
00212
00213
00214
00215 this->allocator_->sync (ptr, total_len);
00216
00217 return result;
00218 }
00219 }
00220
00221 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00222 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::unbind (
00223 const ACE_NS_WString &name)
00224 {
00225
00226
00227
00228 int result = 0;
00229 ACE_SEH_TRY
00230 {
00231 result = this->unbind_i (name);
00232 }
00233 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
00234 {
00235 }
00236 return result;
00237
00238 }
00239
00240 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00241 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::unbind_i (
00242 const ACE_NS_WString &name)
00243 {
00244 ACE_TRACE ("ACE_Local_Name_Space::unbind_i");
00245
00246 ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00247 ACE_NS_String ns_name (name);
00248 ACE_NS_Internal ns_internal;
00249 if (this->name_space_map_->unbind (ns_name,
00250 ns_internal,
00251 this->allocator_) != 0)
00252 return -1;
00253
00254
00255
00256
00257
00258 this->allocator_->free ((void *) (ns_internal.value ()).fast_rep ());
00259 return 0;
00260 }
00261
00262 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00263 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::bind (
00264 const ACE_NS_WString &name,
00265 const ACE_NS_WString &value,
00266 const char *type)
00267 {
00268 ACE_TRACE ("ACE_Local_Name_Space::bind");
00269 ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00270
00271 return this->shared_bind (name, value, type, 0);
00272 }
00273
00274 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00275 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::rebind (
00276 const ACE_NS_WString &name,
00277 const ACE_NS_WString &value,
00278 const char *type)
00279 {
00280 ACE_TRACE ("ACE_Local_Name_Space::rebind");
00281 ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00282
00283 return this->shared_bind (name, value, type, 1);
00284 }
00285
00286 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00287 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::resolve (
00288 const ACE_NS_WString &name,
00289 ACE_NS_WString &value,
00290 char *&type)
00291 {
00292
00293
00294
00295 int result = 0;
00296 ACE_SEH_TRY
00297 {
00298 result = this->resolve_i (name, value, type);
00299 }
00300 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
00301 {
00302 }
00303 return result;
00304 }
00305
00306
00307 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00308 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::resolve_i (
00309 const ACE_NS_WString &name,
00310 ACE_NS_WString &value,
00311 char *&type)
00312 {
00313 ACE_TRACE ("ACE_Local_Name_Space::resolve_i");
00314 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00315
00316 ACE_NS_String ns_name (name);
00317 ACE_NS_Internal ns_internal;
00318 ACE_NS_String nbc_string;
00319
00320 if (this->name_space_map_->find (ns_name,
00321 ns_internal,
00322 this->allocator_) != 0)
00323 return -1;
00324
00325
00326
00327
00328 nbc_string = ns_internal.value ();
00329 value = nbc_string;
00330
00331
00332
00333 const char *temp = ns_internal.type ();
00334
00335 size_t len = ACE_OS::strlen (ns_internal.type ());
00336
00337
00338 char *new_type = 0;
00339 ACE_NEW_RETURN (new_type,
00340 char [len + 1],
00341 -1);
00342
00343 ACE_OS::strsncpy (new_type, temp, len + 1);
00344 type = new_type;
00345 return 0;
00346 }
00347
00348 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00349 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::open (
00350 ACE_Naming_Context::Context_Scope_Type scope_in)
00351 {
00352 ACE_TRACE ("ACE_Local_Name_Space::open");
00353 this->ns_scope_ = scope_in;
00354
00355 return this->create_manager ();
00356 }
00357
00358 template <ACE_MEM_POOL_1, class ACE_LOCK>
00359 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Local_Name_Space (void)
00360 : allocator_ (0),
00361 name_space_map_ (0),
00362 name_options_ (0)
00363 {
00364 ACE_TRACE ("ACE_Local_Name_Space::ACE_Local_Name_Space");
00365 }
00366
00367 template <ACE_MEM_POOL_1, class ACE_LOCK>
00368 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Local_Name_Space (
00369 ACE_Naming_Context::Context_Scope_Type scope_in,
00370 ACE_Name_Options *name_options)
00371 : name_options_ (name_options)
00372 {
00373 ACE_TRACE ("ACE_Local_Name_Space::ACE_Local_Name_Space");
00374 if (this->open (scope_in) == -1)
00375 ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("%p\n"), ACE_LIB_TEXT ("ACE_Local_Name_Space::ACE_Local_Name_Space")));
00376 }
00377
00378 template <ACE_MEM_POOL_1, class ACE_LOCK>
00379 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::~ACE_Local_Name_Space (void)
00380 {
00381 ACE_TRACE ("ACE_Local_Name_Space::~ACE_Local_Name_Space");
00382
00383
00384 delete this->allocator_;
00385 delete this->lock_;
00386 }
00387
00388 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00389 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::create_manager (void)
00390 {
00391
00392
00393
00394 int result = 0;
00395 ACE_SEH_TRY
00396 {
00397 result = this->create_manager_i ();
00398 }
00399 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
00400 {
00401 }
00402 return result;
00403 }
00404
00405
00406 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00407 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::create_manager_i (void)
00408 {
00409 ACE_TRACE ("ACE_Local_Name_Space::create_manager_i");
00410
00411 const ACE_TCHAR *dir = this->name_options_->namespace_dir ();
00412 const ACE_TCHAR *database = this->name_options_->database ();
00413
00414
00415 size_t len = ACE_OS::strlen (dir);
00416 len += ACE_OS::strlen (ACE_DIRECTORY_SEPARATOR_STR);
00417 len += ACE_OS::strlen (database) + 1;
00418
00419 if (len >= MAXNAMELEN + MAXPATHLEN)
00420 {
00421 errno = ENAMETOOLONG;
00422 return -1;
00423 }
00424
00425 ACE_OS::strcpy (this->context_file_, dir);
00426 ACE_OS::strcat (this->context_file_, ACE_DIRECTORY_SEPARATOR_STR);
00427 ACE_OS::strcat (this->context_file_, database);
00428
00429 ACE_MEM_POOL_OPTIONS options (this->name_options_->base_address ());
00430
00431 ACE_TCHAR lock_name_for_local_name_space [MAXNAMELEN + MAXPATHLEN];
00432 ACE_TCHAR lock_name_for_backing_store [MAXPATHLEN + MAXNAMELEN];
00433 const ACE_TCHAR *postfix = database;
00434
00435 size_t length = 0;
00436 length = sizeof lock_name_for_local_name_space / sizeof (ACE_TCHAR);
00437 ACE_OS::strsncpy (lock_name_for_local_name_space,
00438 dir,
00439 length);
00440
00441 ACE_OS::strncat (lock_name_for_local_name_space,
00442 ACE_DIRECTORY_SEPARATOR_STR,
00443 length - ACE_OS::strlen (lock_name_for_local_name_space));
00444 ACE_OS::strncat (lock_name_for_local_name_space,
00445 ACE_LIB_TEXT ("name_space_"),
00446 length - ACE_OS::strlen (lock_name_for_local_name_space));
00447 ACE_OS::strncat (lock_name_for_local_name_space,
00448 postfix,
00449 length - ACE_OS::strlen (lock_name_for_local_name_space));
00450
00451 length = sizeof lock_name_for_backing_store / sizeof (ACE_TCHAR);
00452 ACE_OS::strsncpy (lock_name_for_backing_store,
00453 dir,
00454 length);
00455 ACE_OS::strncat (lock_name_for_backing_store,
00456 ACE_DIRECTORY_SEPARATOR_STR,
00457 length - ACE_OS::strlen (lock_name_for_backing_store));
00458 ACE_OS::strncat (lock_name_for_backing_store,
00459 ACE_LIB_TEXT ("backing_store_"),
00460 length - ACE_OS::strlen (lock_name_for_backing_store));
00461 ACE_OS::strncat (lock_name_for_backing_store,
00462 postfix,
00463 length - ACE_OS::strlen (ACE_LIB_TEXT ("backing_store_")));
00464
00465
00466 ACE_NEW_RETURN (this->allocator_,
00467 ALLOCATOR (this->context_file_,
00468 lock_name_for_backing_store,
00469 &options), -1);
00470
00471 if (ACE_LOG_MSG->op_status ())
00472 ACE_ERROR_RETURN ((LM_ERROR,
00473 ACE_LIB_TEXT ("Allocator::Allocator\n")),
00474 -1);
00475
00476 ACE_NEW_RETURN (this->lock_,
00477 ACE_LOCK (lock_name_for_local_name_space),
00478 -1);
00479
00480 #if !defined (ACE_LACKS_ACCESS)
00481
00482 if (ACE_OS::access (this->context_file_, F_OK) != 0)
00483 ACE_ERROR_RETURN ((LM_ERROR,
00484 ACE_LIB_TEXT ("create_manager\n")),
00485 -1);
00486 #endif
00487
00488 void *ns_map = 0;
00489
00490
00491
00492 if (this->allocator_->find (ACE_NAME_SERVER_MAP, ns_map) == 0)
00493 {
00494 this->name_space_map_ = (ACE_Name_Space_Map <ALLOCATOR> *) ns_map;
00495 if (ACE::debug ())
00496 ACE_DEBUG ((LM_DEBUG,
00497 ACE_LIB_TEXT ("name_space_map_ = %d, ns_map = %d\n"),
00498 this->name_space_map_, ns_map));
00499 }
00500
00501
00502
00503 else
00504 {
00505 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00506
00507
00508
00509 if (this->allocator_->find (ACE_NAME_SERVER_MAP, ns_map) == 0)
00510 {
00511 this->name_space_map_ = (ACE_Name_Space_Map <ALLOCATOR> *) ns_map;
00512 if (ACE::debug ())
00513 ACE_DEBUG ((LM_DEBUG,
00514 ACE_LIB_TEXT ("name_space_map_ = %d, ns_map = %d\n"),
00515 this->name_space_map_, ns_map));
00516 }
00517 else
00518 {
00519 size_t map_size = sizeof *this->name_space_map_;
00520 ns_map = this->allocator_->malloc (map_size);
00521
00522
00523 this->name_space_map_ =
00524 new (ns_map) ACE_Name_Space_Map <ALLOCATOR> (this->allocator_);
00525
00526 if (this->allocator_->bind (ACE_NAME_SERVER_MAP, ns_map) == -1)
00527 ACE_ERROR_RETURN ((LM_ERROR,
00528 ACE_LIB_TEXT ("create_manager\n")), -1);
00529 }
00530
00531 if (ACE::debug ())
00532 ACE_DEBUG ((LM_DEBUG,
00533 ACE_LIB_TEXT ("name_space_map_ = %d, ns_map = %d\n"),
00534 this->name_space_map_, ns_map));
00535 }
00536
00537 return 0;
00538 }
00539
00540 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00541 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_names_i (
00542 ACE_WSTRING_SET &set,
00543 const ACE_NS_WString &pattern)
00544 {
00545 ACE_TRACE ("ACE_Local_Name_Space::list_names_i");
00546 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00547
00548 MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
00549 MAP_MANAGER::ENTRY *map_entry;
00550
00551 int result = 1;
00552
00553 for (map_entry = 0;
00554 map_iterator.next (map_entry) != 0;
00555 map_iterator.advance())
00556 {
00557 if (map_entry->ext_id_.strstr (pattern) != -1)
00558 {
00559 ACE_NS_WString entry (map_entry->ext_id_ );
00560
00561 if (set.insert (entry) == -1)
00562 {
00563 result = -1;
00564 break;
00565 }
00566 else
00567 result = 0;
00568 }
00569 }
00570
00571 return result;
00572 }
00573
00574 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00575 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_values_i (
00576 ACE_WSTRING_SET &set,
00577 const ACE_NS_WString &pattern)
00578 {
00579 ACE_TRACE ("ACE_Local_Name_Space::list_values_i");
00580 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00581
00582 MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
00583 MAP_MANAGER::ENTRY *map_entry;
00584
00585 int result = 1;
00586
00587 for (map_entry = 0;
00588 map_iterator.next (map_entry) != 0;
00589 map_iterator.advance ())
00590 {
00591 if (map_entry->int_id_.value ().strstr (pattern) != -1)
00592 {
00593 ACE_NS_WString entry (map_entry->int_id_.value ());
00594
00595 if (set.insert (entry) == -1)
00596 {
00597 result = -1;
00598 break;
00599 }
00600 else
00601 result = 0;
00602 }
00603 }
00604
00605 return result;
00606 }
00607
00608 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00609 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_types_i (
00610 ACE_WSTRING_SET &set,
00611 const ACE_NS_WString &pattern)
00612 {
00613 ACE_TRACE ("ACE_Local_Name_Space::list_types_i");
00614 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00615
00616 MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
00617 MAP_MANAGER::ENTRY *map_entry;
00618
00619 char *compiled_regexp = 0;
00620
00621
00622 char *pattern_rep = pattern.char_rep ();
00623
00624
00625 if (ACE_OS::strcmp ("", pattern_rep) == 0)
00626 ACE_ALLOCATOR_RETURN (compiled_regexp,
00627 ACE_OS::strdup (""),
00628 -1);
00629 else
00630
00631
00632 #if defined (ACE_HAS_REGEX)
00633 compiled_regexp = ACE_OS::compile (pattern_rep, 0, 0);
00634 #else
00635
00636
00637 compiled_regexp = pattern_rep;
00638 #endif
00639
00640 int result = 1;
00641
00642 for (map_entry = 0;
00643 map_iterator.next (map_entry) != 0;
00644 map_iterator.advance ())
00645 {
00646
00647 const char *type = map_entry->int_id_.type ();
00648
00649
00650 if (ACE_OS::strcmp ("", pattern_rep) == 0
00651 #if defined (ACE_HAS_REGEX)
00652 || ACE_OS::step (type, compiled_regexp) != 0)
00653 #else
00654
00655
00656 || ACE_OS::strstr (type, compiled_regexp) != 0)
00657 #endif
00658
00659 {
00660 ACE_NS_WString entry (type);
00661
00662 if (set.insert (entry) == -1)
00663 {
00664 result = -1;
00665 break;
00666 }
00667 else
00668 result = 0;
00669 }
00670 }
00671 #if defined (ACE_HAS_REGEX)
00672 if (compiled_regexp)
00673 ACE_OS::free ((void *) compiled_regexp);
00674 #endif
00675 delete [] pattern_rep;
00676 return result;
00677 }
00678
00679 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00680 ACE_Local_Name_Space <ACE_MEM_POOL_2, ACE_LOCK>::list_name_entries_i (
00681 ACE_BINDING_SET &set,
00682 const ACE_NS_WString &pattern)
00683 {
00684 ACE_TRACE ("ACE_Local_Name_Space::list_name_entries_i");
00685 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00686
00687 MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
00688 MAP_MANAGER::ENTRY *map_entry;
00689
00690 for (map_entry = 0;
00691 map_iterator.next (map_entry) != 0;
00692 map_iterator.advance())
00693 {
00694 if (map_entry->ext_id_.strstr (pattern) != -1)
00695 {
00696 ACE_Name_Binding entry (map_entry->ext_id_,
00697 map_entry->int_id_.value (),
00698 map_entry->int_id_.type ());
00699
00700 if (set.insert (entry) == -1)
00701 return -1;
00702 }
00703 }
00704
00705 return 0;
00706 }
00707
00708 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00709 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_value_entries_i (
00710 ACE_BINDING_SET &set,
00711 const ACE_NS_WString &pattern)
00712 {
00713 ACE_TRACE ("ACE_Local_Name_Space::list_value_entries_i");
00714 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00715
00716 MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
00717 MAP_MANAGER::ENTRY *map_entry;
00718
00719 for (map_entry = 0;
00720 map_iterator.next (map_entry) != 0;
00721 map_iterator.advance ())
00722 {
00723 if (map_entry->int_id_.value ().strstr (pattern) != -1)
00724 {
00725 ACE_Name_Binding entry (map_entry->ext_id_,
00726 map_entry->int_id_.value (),
00727 map_entry->int_id_.type ());
00728
00729 if (set.insert (entry) == -1)
00730 return -1;
00731 }
00732 }
00733 return 0;
00734 }
00735
00736 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00737 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_type_entries_i (
00738 ACE_BINDING_SET &set,
00739 const ACE_NS_WString &pattern)
00740 {
00741 ACE_TRACE ("ACE_Local_Name_Space::list_type_entries_i");
00742 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00743
00744 MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
00745 MAP_MANAGER::ENTRY *map_entry;
00746
00747 char *compiled_regexp = 0;
00748
00749 char *pattern_rep = pattern.char_rep ();
00750
00751
00752 if (ACE_OS::strcmp ("", pattern_rep) == 0)
00753 compiled_regexp = ACE_OS::strdup ("");
00754 else
00755
00756
00757 #if defined (ACE_HAS_REGEX)
00758 compiled_regexp = ACE_OS::compile (pattern_rep, 0, 0);
00759 #else
00760
00761 compiled_regexp = pattern_rep;
00762 #endif
00763
00764 for (map_entry = 0;
00765 map_iterator.next (map_entry) != 0;
00766 map_iterator.advance ())
00767 {
00768
00769 const char *type = map_entry->int_id_.type ();
00770
00771 if (ACE_OS::strcmp ("", pattern_rep) == 0
00772
00773 #if defined (ACE_HAS_REGEX)
00774 || ACE_OS::step (type, compiled_regexp) != 0)
00775 #else
00776
00777 || ACE_OS::strstr (type, compiled_regexp) != 0)
00778 #endif
00779 {
00780 ACE_Name_Binding entry (map_entry->ext_id_,
00781 map_entry->int_id_.value (),
00782 map_entry->int_id_.type ());
00783
00784 if (set.insert (entry) == -1)
00785 return -1;
00786 }
00787 }
00788 #if defined (ACE_HAS_REGEX)
00789 if (compiled_regexp)
00790 ACE_OS::free ((void *) compiled_regexp);
00791 #endif
00792 delete [] pattern_rep;
00793 return 0;
00794 }
00795
00796 template <ACE_MEM_POOL_1, class ACE_LOCK> void
00797 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::dump_i (void) const
00798 {
00799 ACE_TRACE ("ACE_Local_Name_Space::dump_i");
00800
00801 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00802
00803 MAP_MANAGER::ITERATOR map_iterator (*this->name_space_map_);
00804 MAP_MANAGER::ENTRY *map_entry;
00805
00806 for (map_entry = 0;
00807 map_iterator.next (map_entry) != 0;
00808 map_iterator.advance())
00809 {
00810 char *key = map_entry->ext_id_.char_rep ();
00811 char *value = map_entry->int_id_.value ().char_rep ();
00812 #if !defined (ACE_NLOGGING)
00813 const char *type = map_entry->int_id_.type ();
00814 #endif
00815
00816 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("key=%s\nvalue=%s\ntype=%s\n"),
00817 ACE_TEXT_CHAR_TO_TCHAR (key), ACE_TEXT_CHAR_TO_TCHAR (value), ACE_TEXT_CHAR_TO_TCHAR (type)));
00818
00819
00820 delete [] key;
00821 delete [] value;
00822 }
00823
00824 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00825 }
00826
00827 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00828 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_names (
00829 ACE_WSTRING_SET &set,
00830 const ACE_NS_WString &pattern)
00831 {
00832
00833
00834
00835 int result = 0;
00836 ACE_SEH_TRY
00837 {
00838 result = this->list_names_i (set, pattern);
00839 }
00840 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
00841 {
00842 }
00843 return result;
00844 }
00845
00846 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00847 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_values (
00848 ACE_WSTRING_SET &set,
00849 const ACE_NS_WString &pattern)
00850 {
00851
00852
00853
00854 int result = 0;
00855 ACE_SEH_TRY
00856 {
00857 result = this->list_values_i (set, pattern);
00858 }
00859 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
00860 {
00861 }
00862 return result;
00863 }
00864
00865 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00866 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_types (
00867 ACE_WSTRING_SET &set,
00868 const ACE_NS_WString &pattern)
00869 {
00870
00871
00872
00873 int result = 0;
00874 ACE_SEH_TRY
00875 {
00876 result = this->list_types_i (set, pattern);
00877 }
00878 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
00879 {
00880 }
00881 return result;
00882 }
00883
00884 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00885 ACE_Local_Name_Space <ACE_MEM_POOL_2, ACE_LOCK>::list_name_entries (
00886 ACE_BINDING_SET &set,
00887 const ACE_NS_WString &pattern)
00888 {
00889
00890
00891
00892 int result = 0;
00893 ACE_SEH_TRY
00894 {
00895 result = this->list_name_entries_i (set, pattern);
00896 }
00897 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
00898 {
00899 }
00900 return result;
00901 }
00902
00903 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00904 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_value_entries (
00905 ACE_BINDING_SET &set,
00906 const ACE_NS_WString &pattern)
00907 {
00908
00909
00910
00911 int result = 0;
00912 ACE_SEH_TRY
00913 {
00914 result = this->list_value_entries_i (set, pattern);
00915 }
00916 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
00917 {
00918 }
00919 return result;
00920 }
00921
00922 template <ACE_MEM_POOL_1, class ACE_LOCK> int
00923 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_type_entries (
00924 ACE_BINDING_SET &set,
00925 const ACE_NS_WString &pattern)
00926 {
00927
00928
00929
00930 int result = 0;
00931 ACE_SEH_TRY
00932 {
00933 result = this->list_type_entries_i (set, pattern);
00934 }
00935 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
00936 {
00937 }
00938 return result;
00939 }
00940
00941 template <ACE_MEM_POOL_1, class ACE_LOCK> void
00942 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::dump (void) const
00943 {
00944 #if defined (ACE_HAS_DUMP)
00945
00946
00947
00948
00949
00950 ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK> *fake_this =
00951 (ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK> *) this;
00952 ACE_UNUSED_ARG (fake_this);
00953
00954 ACE_SEH_TRY
00955 {
00956 this->dump_i ();
00957 }
00958 ACE_SEH_EXCEPT (fake_this->remap (GetExceptionInformation ()))
00959 {
00960 }
00961 #endif
00962 }
00963
00964 ACE_END_VERSIONED_NAMESPACE_DECL
00965
00966 #endif