const_iterator find(Key const& key) const { rbtree_node* n = find_impl(key); if (!n) return end(); return const_iterator(n); }
variant& bag::at(const std::string& key) { container_type::iterator it(find_impl(key)); if ( it==m_value.end() ) { boost::throw_exception(variant_error(std::string("Item '") + key + "' not found in Bag")); } return it->second; }
bool remove(Key const& key) { rbtree_node* n = find_impl(key); if (!n) return false; n->remove(&_root); return true; }
T& find() const { // First see if the pointer is still loaded in the cache. if(!m_cache.isNull()) { return *safe_cast<T*>(m_cache.data()); } else // Load it by hand { auto ptr = safe_cast<typename std::remove_const<T>::type*>(find_impl()); m_cache = ptr; return *ptr; } }
data_phone data_phonebook_find(data_phonebook obj, data_name arg, CORBA_Environment *ev) { impl_node impl = find_impl(obj, ev); data_phone result; int i; /* If we failed to find the implementation, return. */ if (ev->_major != CORBA_NO_EXCEPTION) return; /* Find the name `arg' in the phonebook. */ for (i = 0; i < impl->pb_size; ++i) if (impl->pb[i] && !strcmp(impl->pb[i]->n, arg)) break; if (i >= impl->pb_size) { /* * We didn't find the name. Raise a `data_notfound' * exception. */ CORBA_BOA_set_exception(boa, ev, CORBA_USER_EXCEPTION, ex_data_notfound, 0); return; } /* Allocate and return the located phone number. */ result = (CORBA_char *) CORBA_alloc(sizeof(CORBA_char) * (strlen(impl->pb[i]->p) + 1)); if (!result) { signal_no_memory(ev); return; } strcpy(result, impl->pb[i]->p); /* Success! */ return result; }
void data_phonebook_remove(data_phonebook obj, data_name arg, CORBA_Environment *ev) { impl_node impl = find_impl(obj, ev); int i; /* If we failed to find the implementation, return. */ if (ev->_major != CORBA_NO_EXCEPTION) return; /* Find the name `arg' in the phonebook. */ for (i = 0; i < impl->pb_size; ++i) if (impl->pb[i] && !strcmp(impl->pb[i]->n, arg)) break; if (i >= impl->pb_size) { /* * We didn't find the name. Raise a `data_notfound' * exception. */ CORBA_BOA_set_exception(boa, ev, CORBA_USER_EXCEPTION, ex_data_notfound, 0); return; } /* Clear the entry. */ free(impl->pb[i]->n); free(impl->pb[i]->p); free(impl->pb[i]); impl->pb[i] = 0; /* Decrement the number of entries in our phonebook. */ impl->pb_elems--; /* Success! */ return; }
bool find(uint32_t value) const { return find_impl(0, 0, value); }
bool bag::has_key(const std::string& key) const { return (find_impl(key)!=m_value.end()); }
/*! * The method finds the attribute value by name. * * \param key Attribute name. Must not be NULL, must point to a zero-terminated string. * \return Iterator to the found element or \c end() if the attribute with such name is not found. */ const_iterator find(const char_type* key) const { typedef std::char_traits< char_type > traits_type; return find_impl(key, traits_type::length(key)); }
/*! * The method finds the attribute value by name. * * \param key Attribute name. * \return Iterator to the found element or \c end() if the attribute with such name is not found. */ const_iterator find(string_type const& key) const { return find_impl(key.data(), key.size()); }
void data_phonebook_add(data_phonebook obj, data_entry *arg, CORBA_Environment *ev) { impl_node impl = find_impl(obj, ev); int i; /* If we failed to find the implementation, return. */ if (ev->_major != CORBA_NO_EXCEPTION) return; /* See if this entry is already in the phonebook. */ for (i = 0; i < impl->pb_size; ++i) { if (impl->pb[i] && !strcmp(impl->pb[i]->n, arg->n)) { /* * We found a duplicate! Raise a `data_duplicate' * exception. */ data_duplicate *d = (data_duplicate *) CORBA_alloc(sizeof(data_duplicate)); if (!d) { signal_no_memory(ev); return; } d->p = (CORBA_char *) CORBA_alloc(strlen(impl->pb[i]->p) + 1); if (!d->p) { CORBA_free(d); signal_no_memory(ev); return; } strcpy(d->p, impl->pb[i]->p); CORBA_BOA_set_exception(boa, ev, CORBA_USER_EXCEPTION, ex_data_duplicate, d); return; } } /* Find an empty entry in `impl'; grow the phonebook if necessary. */ i = find_empty_entry(impl, ev); if (ev->_major != CORBA_NO_EXCEPTION) return; /* * Allocate memory for the new entry. Note that we have to copy the * `arg' data because CORBA says we can't keep pointers into `in' data * after this function has returned. */ impl->pb[i] = (data_entry *) malloc(sizeof(data_entry)); if (!impl->pb[i]) { signal_no_memory(ev); return; } impl->pb[i]->n = (char *) malloc(sizeof(char) * (strlen(arg->n) + 1)); impl->pb[i]->p = (char *) malloc(sizeof(char) * (strlen(arg->p) + 1)); if (!(impl->pb[i]->n) || !(impl->pb[i]->p)) { /* Free what we have allocated and signal an exception. */ if (impl->pb[i]->n) free(impl->pb[i]->n); if (impl->pb[i]->p) free(impl->pb[i]->p); free(impl->pb[i]); impl->pb[i] = 0; signal_no_memory(ev); return; } /* Copy the `arg' information into our phonebook. */ strcpy(impl->pb[i]->n, arg->n); strcpy(impl->pb[i]->p, arg->p); /* Increment the number of entries in our phonebook. */ impl->pb_elems++; /* Success! */ return; }