diff options
author | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
commit | 26b5e033ffde3d161382fc9addbfa99738379641 (patch) | |
tree | a344f369ca32945f787a02dee35c3dbe342bed7e /dep/ACE_wrappers/ace/Registry.cpp | |
parent | f21f47005dcb6b76e1abc9f35fbcd03eed191bff (diff) |
*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget
--HG--
branch : trunk
Diffstat (limited to 'dep/ACE_wrappers/ace/Registry.cpp')
-rw-r--r-- | dep/ACE_wrappers/ace/Registry.cpp | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/dep/ACE_wrappers/ace/Registry.cpp b/dep/ACE_wrappers/ace/Registry.cpp index 897df00a9af..ff41103b724 100644 --- a/dep/ACE_wrappers/ace/Registry.cpp +++ b/dep/ACE_wrappers/ace/Registry.cpp @@ -1,16 +1,11 @@ // $Id: Registry.cpp 82435 2008-07-28 11:53:42Z johnnyw $ - #include "ace/Registry.h" - ACE_RCSID (ace, Registry, "$Id: Registry.cpp 82435 2008-07-28 11:53:42Z johnnyw $") - #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY) - # include "ace/os_include/os_netdb.h" # include "ace/OS_NS_unistd.h" - // Funky macro to deal with strange error passing semantics // of Win32 Reg*() functions #define ACE_REGISTRY_CALL_RETURN(X) \ @@ -24,11 +19,8 @@ ACE_RCSID (ace, return 0; \ } while (0) - ACE_BEGIN_VERSIONED_NAMESPACE_DECL - ACE_TCHAR const ACE_Registry::STRING_SEPARATOR[] = ACE_TEXT ("\\"); - bool ACE_Registry::Name_Component::operator== (const Name_Component &rhs) const { @@ -36,13 +28,11 @@ ACE_Registry::Name_Component::operator== (const Name_Component &rhs) const rhs.id_ == this->id_ && rhs.kind_ == this->kind_; } - bool ACE_Registry::Name_Component::operator!= (const Name_Component &rhs) const { return !this->operator== (rhs); } - // Simple binding constructor ACE_Registry::Binding::Binding () : name_ (), @@ -50,7 +40,6 @@ ACE_Registry::Binding::Binding () { } - // Binding constructor // (Name version) ACE_Registry::Binding::Binding (const Name &name, @@ -60,7 +49,6 @@ ACE_Registry::Binding::Binding (const Name &name, { } - // Binding constructor // (String version) ACE_Registry::Binding::Binding (const ACE_TString &name, @@ -70,7 +58,6 @@ ACE_Registry::Binding::Binding (const ACE_TString &name, { } - bool ACE_Registry::Binding::operator== (const Binding &rhs) const { @@ -78,13 +65,11 @@ ACE_Registry::Binding::operator== (const Binding &rhs) const rhs.name_ == this->name_ && rhs.type_ == this->type_; } - bool ACE_Registry::Binding::operator!= (const Binding &rhs) const { return !this->operator== (rhs); } - // Name accessor // (Name version) void @@ -93,7 +78,6 @@ ACE_Registry::Binding::name (Name &name) name = ACE_Registry::make_name (this->name_); } - // Name accessors // (String version) void @@ -102,7 +86,6 @@ ACE_Registry::Binding::name (ACE_TString &name) name = this->name_; } - // Name accessors // (String version) ACE_TString @@ -111,7 +94,6 @@ ACE_Registry::Binding::name (void) return this->name_; } - // Type accessor ACE_Registry::Binding_Type ACE_Registry::Binding::type (void) @@ -119,7 +101,6 @@ ACE_Registry::Binding::type (void) return this->type_; } - // Simple object constructor ACE_Registry::Object::Object (void *data, u_long size, @@ -129,7 +110,6 @@ ACE_Registry::Object::Object (void *data, type_ (type) { } - // Object accessors and set methods void ACE_Registry::Object::data (void *data) @@ -137,42 +117,36 @@ ACE_Registry::Object::data (void *data) this->data_ = data; } - void * ACE_Registry::Object::data (void) const { return this->data_; } - void ACE_Registry::Object::size (u_long size) { this->size_ = size; } - u_long ACE_Registry::Object::size (void) const { return this->size_; } - void ACE_Registry::Object::type (u_long type) { this->type_ = type; } - u_long ACE_Registry::Object::type (void) const { return this->type_; } - // Simple context constructor ACE_Registry::Naming_Context::Naming_Context (void) : key_ ((HKEY) 0), @@ -181,7 +155,6 @@ ACE_Registry::Naming_Context::Naming_Context (void) { } - // Context constructor ACE_Registry::Naming_Context::Naming_Context (const HKEY &key) : key_ (key), @@ -190,7 +163,6 @@ ACE_Registry::Naming_Context::Naming_Context (const HKEY &key) { } - ACE_Registry::Naming_Context::Naming_Context (const Naming_Context &rhs) : key_ (rhs.key_), parent_key_ (rhs.parent_key_), @@ -201,24 +173,20 @@ ACE_Registry::Naming_Context::Naming_Context (const Naming_Context &rhs) // But since this is private (and not used), I don't care much } - const ACE_Registry::Naming_Context & ACE_Registry::Naming_Context::operator= (const Naming_Context &rhs) { ACE_UNUSED_ARG(rhs); - // Not implemented return *this; } - // Destructor ACE_Registry::Naming_Context::~Naming_Context () { this->close (); } - // Insert <object> with <name> into <this> context // (Name version) int @@ -228,7 +196,6 @@ ACE_Registry::Naming_Context::bind_new (const Name &name, return this->bind_new (ACE_Registry::make_string (name), object); } - // Insert <object> with <name> into <this> context // (String version) int @@ -247,7 +214,6 @@ ACE_Registry::Naming_Context::bind_new (const ACE_TString &name, return result; } - // Insert or update <object> with <name> into <this> context // (Name version) int @@ -257,7 +223,6 @@ ACE_Registry::Naming_Context::bind (const Name &name, return this->bind (ACE_Registry::make_string (name), object); } - // Insert or update <object> with <name> into <this> context // (String version) int @@ -273,7 +238,6 @@ ACE_Registry::Naming_Context::bind (const ACE_TString &name, ACE_REGISTRY_CALL_RETURN (result); } - // Update <object> with <name> in <this> context // (Name version) int @@ -283,7 +247,6 @@ ACE_Registry::Naming_Context::rebind (const Name &name, return this->rebind (ACE_Registry::make_string (name), new_object); } - // Update <object> with <name> in <this> context // (String version) int @@ -299,7 +262,6 @@ ACE_Registry::Naming_Context::rebind (const ACE_TString &name, return result; } - // Find <object> with <name> in <this> context // (Name version) int @@ -309,7 +271,6 @@ ACE_Registry::Naming_Context::resolve (const Name &name, return this->resolve (ACE_Registry::make_string (name), object); } - // Find <object> with <name> in <this> context // (String version) int @@ -320,7 +281,6 @@ ACE_Registry::Naming_Context::resolve (const ACE_TString &name, u_long type; void *data = object.data (); u_long size = object.size (); - long result = ACE_TEXT_RegQueryValueEx (this->key_, name.c_str (), 0, @@ -334,11 +294,9 @@ ACE_Registry::Naming_Context::resolve (const ACE_TString &name, object.type (type); object.size (size); } - ACE_REGISTRY_CALL_RETURN (result); } - // Remove object with <name> in <this> context // (Name version) int @@ -347,7 +305,6 @@ ACE_Registry::Naming_Context::unbind (const Name &name) return this->unbind (ACE_Registry::make_string (name)); } - // Remove object with <name> in <this> context // (String version) int @@ -355,11 +312,9 @@ ACE_Registry::Naming_Context::unbind (const ACE_TString &name) { long result = ACE_TEXT_RegDeleteValue (this->key_, name.c_str ()); - ACE_REGISTRY_CALL_RETURN (result); } - // Create new <naming_context> relative to <this> context // This method may not mean a lot in this implementation int @@ -369,7 +324,6 @@ ACE_Registry::Naming_Context::new_context (Naming_Context &naming_context) return naming_context.close (); } - // Insert <naming_context> with <name> relative to <this> context // (Name version) int @@ -386,7 +340,6 @@ ACE_Registry::Naming_Context::bind_new_context (const Name &name, security_attributes); } - // Insert <naming_context> with <name> relative to <this> context // (String version) int @@ -397,7 +350,6 @@ ACE_Registry::Naming_Context::bind_new_context (const ACE_TString &name, LPSECURITY_ATTRIBUTES security_attributes) { u_long reason; - long result = ACE_TEXT_RegCreateKeyEx (this->key_, name.c_str (), 0, @@ -430,11 +382,9 @@ ACE_Registry::Naming_Context::bind_new_context (const ACE_TString &name, naming_context.key_ = (HKEY) 0; } } - ACE_REGISTRY_CALL_RETURN (result); } - // Insert or update <naming_context> with <name> relative to <this> context // (Name version) int @@ -451,7 +401,6 @@ ACE_Registry::Naming_Context::bind_context (const Name &name, security_attributes); } - // Insert or update <naming_context> with <name> relative to <this> context // (String version) int @@ -462,7 +411,6 @@ ACE_Registry::Naming_Context::bind_context (const ACE_TString &name, LPSECURITY_ATTRIBUTES security_attributes) { u_long reason; - long result = ACE_TEXT_RegCreateKeyEx (this->key_, name.c_str (), 0, @@ -479,11 +427,9 @@ ACE_Registry::Naming_Context::bind_context (const ACE_TString &name, // Set the correct name naming_context.name (name); } - ACE_REGISTRY_CALL_RETURN (result); } - // Rename <naming_context> to <name> // (Name version) int @@ -494,7 +440,6 @@ ACE_Registry::Naming_Context::rebind_context (const Name &name, new_naming_context); } - // Rename <naming_context> to <name> // (String version) int @@ -520,7 +465,6 @@ ACE_Registry::Naming_Context::rebind_context (const ACE_TString &name, return result; } - // Remove naming_context with <name> from <this> context // (Name version) int @@ -529,7 +473,6 @@ ACE_Registry::Naming_Context::unbind_context (const Name &name) return this->unbind_context (ACE_Registry::make_string (name)); } - // Remove naming_context with <name> from <this> context // (String version) int @@ -537,11 +480,9 @@ ACE_Registry::Naming_Context::unbind_context (const ACE_TString &name) { long result = ACE_TEXT_RegDeleteKey (this->key_, name.c_str ()); - ACE_REGISTRY_CALL_RETURN (result); } - // Find <naming_context> with <name> in <this> context // (Name version) int @@ -554,7 +495,6 @@ ACE_Registry::Naming_Context::resolve_context (const Name &name, security_access); } - // Find <naming_context> with <name> in <this> context // (String version) int @@ -574,11 +514,9 @@ ACE_Registry::Naming_Context::resolve_context (const ACE_TString &name, // set the correct name naming_context.name (name); } - ACE_REGISTRY_CALL_RETURN (result); } - // Same as unbind_context() with <this> as naming_context int ACE_Registry::Naming_Context::destroy (void) @@ -586,11 +524,9 @@ ACE_Registry::Naming_Context::destroy (void) // hopefully the parent_key_ is still open long result = ACE_TEXT_RegDeleteKey (this->parent_key_, this->name_.c_str ()); - ACE_REGISTRY_CALL_RETURN (result); } - // Sync content of context to disk int ACE_Registry::Naming_Context::flush (void) @@ -599,7 +535,6 @@ ACE_Registry::Naming_Context::flush (void) ACE_REGISTRY_CALL_RETURN (result); } - // Close the handle of the context int ACE_Registry::Naming_Context::close (void) @@ -608,14 +543,12 @@ ACE_Registry::Naming_Context::close (void) ACE_REGISTRY_CALL_RETURN (result); } - // Convert a <name> to a <string> ACE_TString ACE_Registry::make_string (const Name &const_name) { ACE_TString string; Name &name = const_cast<Name &> (const_name); - // Iterator through the components of name for (Name::iterator iterator = name.begin (); iterator != name.end (); @@ -628,11 +561,9 @@ ACE_Registry::make_string (const Name &const_name) // Add to string string += component.id_; } - return string; } - // Convert a <string> to a <name> ACE_Registry::Name ACE_Registry::make_name (const ACE_TString &string) @@ -640,7 +571,6 @@ ACE_Registry::make_name (const ACE_TString &string) ACE_TString::size_type new_position = 0; ACE_TString::size_type last_position = 0; Name name; - // Rememeber: NPOS is -1 while (new_position != ACE_TString::npos) { @@ -667,11 +597,9 @@ ACE_Registry::make_name (const ACE_TString &string) // Insert component into name name.insert (component); } - return name; } - // Set key void ACE_Registry::Naming_Context::key (HKEY key) @@ -679,7 +607,6 @@ ACE_Registry::Naming_Context::key (HKEY key) this->key_ = key; } - // Get key HKEY ACE_Registry::Naming_Context::key (void) @@ -687,7 +614,6 @@ ACE_Registry::Naming_Context::key (void) return this->key_; } - // Set parent void ACE_Registry::Naming_Context::parent (HKEY parent) @@ -695,7 +621,6 @@ ACE_Registry::Naming_Context::parent (HKEY parent) this->parent_key_ = parent; } - // Get parent HKEY ACE_Registry::Naming_Context::parent (void) @@ -703,7 +628,6 @@ ACE_Registry::Naming_Context::parent (void) return this->parent_key_; } - // Set name // (Name version) void @@ -712,7 +636,6 @@ ACE_Registry::Naming_Context::name (const Name &name) this->name_ = ACE_Registry::make_string (name); } - // Get name // (Name version) void @@ -721,7 +644,6 @@ ACE_Registry::Naming_Context::name (Name &name) name = ACE_Registry::make_name (this->name_); } - // Set name // (String version) void @@ -730,7 +652,6 @@ ACE_Registry::Naming_Context::name (const ACE_TString &name) this->name_ = name; } - // Get name // (String version) ACE_TString @@ -739,7 +660,6 @@ ACE_Registry::Naming_Context::name (void) return this->name_; } - // Get name // (String version) void @@ -747,10 +667,8 @@ ACE_Registry::Naming_Context::name (ACE_TString &name) { name = this->name_; } - // Empty list static const ACE_Registry::Binding_List ace_binding_empty_list; - // listing function: iterator creator // This is useful when there are many objects and contexts // in <this> context and you only want to look at a few entries @@ -762,21 +680,16 @@ ACE_Registry::Naming_Context::list (u_long how_many, { // Make sure that the list is empty list = ace_binding_empty_list; - // Correctly initalize the iterator iter.reset (); - // Make sure that the iterator uses <this> naming context iter.naming_context (*this); - // Start iterations from the objects iter.current_enumeration (iter.object_iteration_); - // Get the next <how_many> values return iter.next_n (how_many, list); } - // listing function: iterator creator // This gives back a listing of all entries in <this> context. int @@ -784,16 +697,12 @@ ACE_Registry::Naming_Context::list (Binding_List &list) { // Make sure that the list is empty list = ace_binding_empty_list; - // Create an iterator ACE_Registry::Binding_Iterator iterator; - // Make sure that the iterator uses <this> naming context iterator.naming_context (*this); - // Start iterations from the objects iterator.current_enumeration (iterator.object_iteration_); - long result = 0; while (1) { @@ -807,7 +716,6 @@ ACE_Registry::Naming_Context::list (Binding_List &list) return 0; } - // Default constructor ACE_Registry::Binding_Iterator::Binding_Iterator () { @@ -817,7 +725,6 @@ ACE_Registry::Binding_Iterator::Binding_Iterator () this->reset (); } - void ACE_Registry::Binding_Iterator::reset () { @@ -827,45 +734,37 @@ ACE_Registry::Binding_Iterator::reset () this->context_iteration_.reset (); } - void ACE_Registry::Binding_Iterator::Iteration_State::reset () { this->index_ = 0; } - void ACE_Registry::Binding_Iterator::Iteration_State::iterator (Binding_Iterator *iter) { this->parent_ = iter; } - ACE_Registry::Binding_Iterator::Iteration_State::Iteration_State () : index_ (0) { } - // Next entry int ACE_Registry::Binding_Iterator::next_one (Binding &binding) { u_long how_many = 1; Binding_List list; - // Get next n (where n is one) long result = this->next_n (how_many, list); - if (result == 0) // Success binding = (*list.begin ()); - return result; } - // Next <how_many> entries int ACE_Registry::Binding_Iterator::next_n (u_long how_many, @@ -873,11 +772,9 @@ ACE_Registry::Binding_Iterator::next_n (u_long how_many, { // Make sure that the list is empty list = ace_binding_empty_list; - return this->current_enumeration_->next_n (how_many, list); } - // Destroy iterator int ACE_Registry::Binding_Iterator::destroy (void) @@ -886,7 +783,6 @@ ACE_Registry::Binding_Iterator::destroy (void) return 0; } - // Set/Get naming_context void ACE_Registry::Binding_Iterator::naming_context (Naming_Context &naming_context) @@ -894,14 +790,12 @@ ACE_Registry::Binding_Iterator::naming_context (Naming_Context &naming_context) this->naming_context_ = &naming_context; } - ACE_Registry::Naming_Context & ACE_Registry::Binding_Iterator::naming_context (void) { return *this->naming_context_; } - // Set/Get current enumeration void ACE_Registry::Binding_Iterator::current_enumeration (Iteration_State ¤t_enumeration) @@ -909,21 +803,18 @@ ACE_Registry::Binding_Iterator::current_enumeration (Iteration_State ¤t_en this->current_enumeration_ = ¤t_enumeration; } - ACE_Registry::Binding_Iterator::Iteration_State & ACE_Registry::Binding_Iterator::current_enumeration (void) { return *this->current_enumeration_; } - int ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many, Binding_List &list) { // Make a copy u_long requested = how_many; - // While there are more entries to be added to the list while (how_many > 0) { @@ -945,7 +836,6 @@ ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many, // Readjust counters this->index_++; how_many--; - // Add to list // Create binding Binding binding (string, OBJECT); @@ -954,12 +844,10 @@ ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many, } // Continue to add to list break; - case ERROR_NO_MORE_ITEMS: // Enumeration of objects complete // Reset index this->index_ = 0; - // Current enumeration will become CONTEXTS this->parent_->current_enumeration (this->parent_->context_iteration_); result = this->parent_->current_enumeration ().next_n (how_many, @@ -969,7 +857,6 @@ ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many, return 0; else return result; - default: // Strange error // Reset index @@ -986,14 +873,12 @@ ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many, return 0; } - int ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many, Binding_List &list) { // Make a copy u_long requested = how_many; - // While there are more entries to be added to the list while (how_many > 0) { @@ -1015,7 +900,6 @@ ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many, // Readjust counters this->index_++; how_many--; - // Add to list // Create binding Binding binding (string, CONTEXT); @@ -1024,20 +908,15 @@ ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many, } // Continue to add to list break; - case ERROR_NO_MORE_ITEMS: // Enumeration of objects complete - /* FALL THROUGH */ - default: // Strange error - // Reset index this->index_ = 0; // Current enumeration will become CONTEXTS this->parent_->current_enumeration (this->parent_->iteration_complete_); - // If we were able to add contexts if (requested != how_many) return 0; @@ -1051,19 +930,16 @@ ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many, return 0; } - int ACE_Registry::Binding_Iterator::Iteration_Complete::next_n (u_long how_many, Binding_List &list) { ACE_UNUSED_ARG(list); ACE_UNUSED_ARG(how_many); - // No more values return -1; } - // Factory method to connect to predefined registries // This method works for both remote and local machines // However, for remote machines CLASSES_ROOT and CURRENT_USER @@ -1078,10 +954,8 @@ ACE_Predefined_Naming_Contexts::connect (ACE_Registry::Naming_Context &naming_co return -1; #else long result = -1; - if (machine_name != 0 && ACE_OS::strcmp (ACE_TEXT ("localhost"), machine_name) == 0) machine_name = 0; - if (predefined == HKEY_LOCAL_MACHINE || predefined == HKEY_USERS) result = ACE_TEXT_RegConnectRegistry (const_cast<ACE_TCHAR *> (machine_name), @@ -1097,11 +971,9 @@ ACE_Predefined_Naming_Contexts::connect (ACE_Registry::Naming_Context &naming_co } else result = -1; - ACE_REGISTRY_CALL_RETURN (result); #endif // ACE_HAS_WINCE } - // Check if <machine_name> is the local host /* static */ int @@ -1115,8 +987,6 @@ ACE_Predefined_Naming_Contexts::is_local_host (const ACE_TCHAR *machine_name) result = 0; return result; } - ACE_END_VERSIONED_NAMESPACE_DECL - #endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */ |