summaryrefslogtreecommitdiff
path: root/ace/Registry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ace/Registry.cpp')
-rw-r--r--ace/Registry.cpp310
1 files changed, 155 insertions, 155 deletions
diff --git a/ace/Registry.cpp b/ace/Registry.cpp
index a83b9d5fbbd..5396c6330d8 100644
--- a/ace/Registry.cpp
+++ b/ace/Registry.cpp
@@ -3,7 +3,7 @@
#define ACE_BUILD_DLL
#include "ace/Registry.h"
-
+
ACE_RCSID(ace, Registry, "$Id$")
#if defined (ACE_WIN32)
@@ -22,19 +22,19 @@ ACE_RCSID(ace, Registry, "$Id$")
} while (0)
-// Separator for components in a name
+// Separator for components in a name
/* static */
LPCTSTR ACE_Registry::STRING_SEPARATOR = ACE_TEXT ("\\");
-int
+int
ACE_Registry::Name_Component::operator== (const Name_Component &rhs) const
{
- return
+ return
rhs.id_ == this->id_ &&
rhs.kind_ == this->kind_;
}
-int
+int
ACE_Registry::Name_Component::operator!= (const Name_Component &rhs) const
{
return !this->operator== (rhs);
@@ -68,15 +68,15 @@ ACE_Registry::Binding::Binding (const Istring &name,
}
-int
+int
ACE_Registry::Binding::operator== (const Binding &rhs) const
{
- return
+ return
rhs.name_ == this->name_ &&
rhs.type_ == this->type_;
}
-int
+int
ACE_Registry::Binding::operator!= (const Binding &rhs) const
{
return !this->operator== (rhs);
@@ -84,7 +84,7 @@ ACE_Registry::Binding::operator!= (const Binding &rhs) const
// Name accessor
// (Name version)
-void
+void
ACE_Registry::Binding::name (Name &name)
{
name = ACE_Registry::make_name (this->name_);
@@ -93,7 +93,7 @@ ACE_Registry::Binding::name (Name &name)
// Name accessors
// (String version)
-void
+void
ACE_Registry::Binding::name (Istring &name)
{
name = this->name_;
@@ -102,7 +102,7 @@ ACE_Registry::Binding::name (Istring &name)
// Name accessors
// (String version)
-ACE_Registry::Istring
+ACE_Registry::Istring
ACE_Registry::Binding::name (void)
{
return this->name_;
@@ -118,8 +118,8 @@ ACE_Registry::Binding::type (void)
// Simple object constructor
-ACE_Registry::Object::Object (void *data,
- u_long size,
+ACE_Registry::Object::Object (void *data,
+ u_long size,
u_long type)
: data_ (data),
size_ (size),
@@ -142,7 +142,7 @@ ACE_Registry::Object::data (void) const
}
-void
+void
ACE_Registry::Object::size (u_long size)
{
this->size_ = size;
@@ -193,7 +193,7 @@ ACE_Registry::Naming_Context::Naming_Context (const Naming_Context &rhs)
parent_key_ (rhs.parent_key_),
name_ (rhs.name_)
{
- // This is incorrect.
+ // This is incorrect.
// Rather than copying key, we should call ::DuplicateHandle()
// But since this is private (and not used), I don't care much
}
@@ -208,7 +208,7 @@ ACE_Registry::Naming_Context::operator= (const Naming_Context &rhs)
return *this;
}
-
+
// Destructor
ACE_Registry::Naming_Context::~Naming_Context ()
{
@@ -219,7 +219,7 @@ ACE_Registry::Naming_Context::~Naming_Context ()
// Insert <object> with <name> into <this> context
// (Name version)
int
-ACE_Registry::Naming_Context::bind_new (const Name &name,
+ACE_Registry::Naming_Context::bind_new (const Name &name,
const Object &object)
{
return this->bind_new (ACE_Registry::make_string (name), object);
@@ -229,11 +229,11 @@ ACE_Registry::Naming_Context::bind_new (const Name &name,
// Insert <object> with <name> into <this> context
// (String version)
int
-ACE_Registry::Naming_Context::bind_new (const Istring &name,
+ACE_Registry::Naming_Context::bind_new (const Istring &name,
const Object &object)
{
- // temporary object
- Object temp;
+ // temporary object
+ Object temp;
long result = this->resolve (name, temp);
if (result == 0)
// resolve succeeded
@@ -248,7 +248,7 @@ ACE_Registry::Naming_Context::bind_new (const Istring &name,
// Insert or update <object> with <name> into <this> context
// (Name version)
int
-ACE_Registry::Naming_Context::bind (const Name &name,
+ACE_Registry::Naming_Context::bind (const Name &name,
const Object &object)
{
return this->bind (ACE_Registry::make_string (name), object);
@@ -258,7 +258,7 @@ ACE_Registry::Naming_Context::bind (const Name &name,
// Insert or update <object> with <name> into <this> context
// (String version)
int
-ACE_Registry::Naming_Context::bind (const Istring &name,
+ACE_Registry::Naming_Context::bind (const Istring &name,
const Object &object)
{
long result = ::RegSetValueEx (this->key_,
@@ -273,8 +273,8 @@ ACE_Registry::Naming_Context::bind (const Istring &name,
// Update <object> with <name> in <this> context
// (Name version)
-int
-ACE_Registry::Naming_Context::rebind (const Name &name,
+int
+ACE_Registry::Naming_Context::rebind (const Name &name,
const Object &new_object)
{
return this->rebind (ACE_Registry::make_string (name), new_object);
@@ -283,15 +283,15 @@ ACE_Registry::Naming_Context::rebind (const Name &name,
// Update <object> with <name> in <this> context
// (String version)
-int
-ACE_Registry::Naming_Context::rebind (const Istring &name,
+int
+ACE_Registry::Naming_Context::rebind (const Istring &name,
const Object &new_object)
{
Object old_object;
// find the old one first
long result = this->resolve (name, old_object);
if (result == 0)
- // no need to delete first
+ // no need to delete first
result = this->bind (name, new_object);
return result;
}
@@ -299,31 +299,31 @@ ACE_Registry::Naming_Context::rebind (const Istring &name,
// Find <object> with <name> in <this> context
// (Name version)
-int
-ACE_Registry::Naming_Context::resolve (const Name &name,
+int
+ACE_Registry::Naming_Context::resolve (const Name &name,
Object &object)
{
return this->resolve (ACE_Registry::make_string (name), object);
}
-
+
// Find <object> with <name> in <this> context
// (String version)
-int
-ACE_Registry::Naming_Context::resolve (const Istring &name,
+int
+ACE_Registry::Naming_Context::resolve (const Istring &name,
Object &object)
{
// Get object state
u_long type;
void *data = object.data ();
u_long size = object.size ();
-
+
long result = ::RegQueryValueEx (this->key_,
name.c_str (),
0,
&type,
(BYTE *)data,
- &size);
+ &size);
if (result == ERROR_SUCCESS)
{
// Reset object state
@@ -335,10 +335,10 @@ ACE_Registry::Naming_Context::resolve (const Istring &name,
ACE_REGISTRY_CALL_RETURN (result);
}
-
+
// Remove object with <name> in <this> context
// (Name version)
-int
+int
ACE_Registry::Naming_Context::unbind (const Name &name)
{
return this->unbind (ACE_Registry::make_string (name));
@@ -347,7 +347,7 @@ ACE_Registry::Naming_Context::unbind (const Name &name)
// Remove object with <name> in <this> context
// (String version)
-int
+int
ACE_Registry::Naming_Context::unbind (const Istring &name)
{
long result = ::RegDeleteValue (this->key_,
@@ -359,14 +359,14 @@ ACE_Registry::Naming_Context::unbind (const Istring &name)
// Create new <naming_context> relative to <this> context
// This method may not mean a lot in this implementation
-int
+int
ACE_Registry::Naming_Context::new_context (Naming_Context &naming_context)
{
// Make sure that we reset the state and close keys
return naming_context.close ();
}
-
+
// Insert <naming_context> with <name> relative to <this> context
// (Name version)
int
@@ -395,10 +395,10 @@ ACE_Registry::Naming_Context::bind_new_context (const Istring &name,
{
u_long reason;
- long result = ::RegCreateKeyEx (this->key_,
- name.c_str (),
- 0,
- 0,
+ long result = ::RegCreateKeyEx (this->key_,
+ name.c_str (),
+ 0,
+ 0,
persistence,
security_access,
security_attributes,
@@ -422,9 +422,9 @@ ACE_Registry::Naming_Context::bind_new_context (const Istring &name,
// reset result to failure
result = -1;
// Close the key first
- ::RegCloseKey (naming_context.key_);
+ ::RegCloseKey (naming_context.key_);
// Reset key
- naming_context.key_ = (HKEY) 0;
+ naming_context.key_ = (HKEY) 0;
}
}
@@ -434,8 +434,8 @@ ACE_Registry::Naming_Context::bind_new_context (const Istring &name,
// Insert or update <naming_context> with <name> relative to <this> context
// (Name version)
-int
-ACE_Registry::Naming_Context::bind_context (const Name &name,
+int
+ACE_Registry::Naming_Context::bind_context (const Name &name,
/* const */ Naming_Context &naming_context,
u_long persistence,
u_long security_access,
@@ -451,8 +451,8 @@ ACE_Registry::Naming_Context::bind_context (const Name &name,
// Insert or update <naming_context> with <name> relative to <this> context
// (String version)
-int
-ACE_Registry::Naming_Context::bind_context (const Istring &name,
+int
+ACE_Registry::Naming_Context::bind_context (const Istring &name,
/* const */ Naming_Context &naming_context,
u_long persistence,
u_long security_access,
@@ -460,10 +460,10 @@ ACE_Registry::Naming_Context::bind_context (const Istring &name,
{
u_long reason;
- long result = ::RegCreateKeyEx (this->key_,
- name.c_str (),
- 0,
- 0,
+ long result = ::RegCreateKeyEx (this->key_,
+ name.c_str (),
+ 0,
+ 0,
persistence,
security_access,
security_attributes,
@@ -480,11 +480,11 @@ ACE_Registry::Naming_Context::bind_context (const Istring &name,
ACE_REGISTRY_CALL_RETURN (result);
}
-
-// Rename <naming_context> to <name>
+
+// Rename <naming_context> to <name>
// (Name version)
-int
-ACE_Registry::Naming_Context::rebind_context (const Name &name,
+int
+ACE_Registry::Naming_Context::rebind_context (const Name &name,
/* const */ Naming_Context &new_naming_context)
{
return this->rebind_context (ACE_Registry::make_string (name),
@@ -492,20 +492,20 @@ ACE_Registry::Naming_Context::rebind_context (const Name &name,
}
-// Rename <naming_context> to <name>
+// Rename <naming_context> to <name>
// (String version)
-int
-ACE_Registry::Naming_Context::rebind_context (const Istring &name,
+int
+ACE_Registry::Naming_Context::rebind_context (const Istring &name,
/* const */ Naming_Context &new_naming_context)
{
Naming_Context old_naming_context;
// find the old one first
- long result = this->resolve_context (name,
+ long result = this->resolve_context (name,
old_naming_context);
if (result == 0)
{
// naming_context is found: delete entry
- result = this->unbind_context (name);
+ result = this->unbind_context (name);
if (result == 0)
{
// successful deletion; rebind
@@ -517,10 +517,10 @@ ACE_Registry::Naming_Context::rebind_context (const Istring &name,
return result;
}
-
+
// Remove naming_context with <name> from <this> context
// (Name version)
-int
+int
ACE_Registry::Naming_Context::unbind_context (const Name &name)
{
return this->unbind_context (ACE_Registry::make_string (name));
@@ -529,20 +529,20 @@ ACE_Registry::Naming_Context::unbind_context (const Name &name)
// Remove naming_context with <name> from <this> context
// (String version)
-int
+int
ACE_Registry::Naming_Context::unbind_context (const Istring &name)
{
- long result = ::RegDeleteKey (this->key_,
+ long result = ::RegDeleteKey (this->key_,
name.c_str ());
ACE_REGISTRY_CALL_RETURN (result);
}
-
+
// Find <naming_context> with <name> in <this> context
// (Name version)
-int
-ACE_Registry::Naming_Context::resolve_context (const Name &name,
+int
+ACE_Registry::Naming_Context::resolve_context (const Name &name,
Naming_Context &naming_context,
u_long security_access)
{
@@ -554,14 +554,14 @@ ACE_Registry::Naming_Context::resolve_context (const Name &name,
// Find <naming_context> with <name> in <this> context
// (String version)
-int
-ACE_Registry::Naming_Context::resolve_context (const Istring &name,
+int
+ACE_Registry::Naming_Context::resolve_context (const Istring &name,
Naming_Context &naming_context,
u_long security_access)
{
- long result = ::RegOpenKeyEx (this->key_,
- name.c_str (),
- 0,
+ long result = ::RegOpenKeyEx (this->key_,
+ name.c_str (),
+ 0,
security_access,
&naming_context.key_);
if (result == ERROR_SUCCESS)
@@ -569,7 +569,7 @@ ACE_Registry::Naming_Context::resolve_context (const Istring &name,
// set the correct parent
naming_context.parent (this->key_);
// set the correct name
- naming_context.name (name);
+ naming_context.name (name);
}
ACE_REGISTRY_CALL_RETURN (result);
@@ -577,19 +577,19 @@ ACE_Registry::Naming_Context::resolve_context (const Istring &name,
// Same as unbind_context() with <this> as naming_context
-int
+int
ACE_Registry::Naming_Context::destroy (void)
{
// hopefully the parent_key_ is still open
- long result = ::RegDeleteKey (this->parent_key_,
+ long result = ::RegDeleteKey (this->parent_key_,
this->name_.c_str ());
ACE_REGISTRY_CALL_RETURN (result);
}
-
+
// Sync content of context to disk
-int
+int
ACE_Registry::Naming_Context::flush (void)
{
long result = ::RegFlushKey (this->key_);
@@ -598,16 +598,16 @@ ACE_Registry::Naming_Context::flush (void)
// Close the handle of the context
-int
+int
ACE_Registry::Naming_Context::close (void)
{
- long result = this->key_ ? ::RegCloseKey (this->key_) : ERROR_SUCCESS;
+ long result = ::RegCloseKey (this->key_);
ACE_REGISTRY_CALL_RETURN (result);
}
// Convert a <name> to a <string>
-ACE_Registry::Istring
+ACE_Registry::Istring
ACE_Registry::make_string (const Name &const_name)
{
Istring string;
@@ -631,7 +631,7 @@ ACE_Registry::make_string (const Name &const_name)
// Convert a <string> to a <name>
-ACE_Registry::Name
+ACE_Registry::Name
ACE_Registry::make_name (const Istring &string)
{
int new_position = 0;
@@ -648,17 +648,17 @@ ACE_Registry::make_name (const Istring &string)
// If we have not gone past the end
{
// Get the substring
- component.id_ = string.substr (last_position,
- new_position - last_position);
+ component.id_ = string.substr (last_position,
+ new_position - last_position);
// Skip past the seperator
new_position += ACE_OS::strlen (ACE_Registry::STRING_SEPARATOR);
}
- else
+ else
{
// Get the last substring
- component.id_ = string.substr (last_position);
+ component.id_ = string.substr (last_position);
}
- // Update positions
+ // Update positions
last_position = new_position;
// Insert component into name
name.insert (component);
@@ -746,12 +746,12 @@ ACE_Registry::Naming_Context::name (Istring &name)
// 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
+// This is useful when there are many objects and contexts
+// in <this> context and you only want to look at a few entries
// at a time
-int
-ACE_Registry::Naming_Context::list (u_long how_many,
- Binding_List &list,
+int
+ACE_Registry::Naming_Context::list (u_long how_many,
+ Binding_List &list,
Binding_Iterator &iter)
{
// Empty list
@@ -759,12 +759,12 @@ ACE_Registry::Naming_Context::list (u_long how_many,
// Make sure that the list is empty
list = empty_list;
- // Correctly initalize the iterator
- iter.reset ();
+ // 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_);
@@ -777,7 +777,7 @@ ACE_Registry::Naming_Context::list (u_long how_many,
// listing function: iterator creator
// This gives back a listing of all entries in <this> context.
-int
+int
ACE_Registry::Naming_Context::list (Binding_List &list)
{
// Empty list
@@ -797,11 +797,11 @@ ACE_Registry::Naming_Context::list (Binding_List &list)
long result = 0;
while (1)
{
- ACE_Registry::Binding binding;
+ ACE_Registry::Binding binding;
result = iterator.next_one (binding);
if (result == 0)
list.insert (binding);
- else
+ else
break;
}
return 0;
@@ -818,7 +818,7 @@ ACE_Registry::Binding_Iterator::Binding_Iterator ()
}
-void
+void
ACE_Registry::Binding_Iterator::reset ()
{
this->current_enumeration_ = &this->iteration_complete_;
@@ -828,7 +828,7 @@ ACE_Registry::Binding_Iterator::reset ()
}
-void
+void
ACE_Registry::Binding_Iterator::Iteration_State::reset ()
{
this->index_ = 0;
@@ -841,19 +841,19 @@ ACE_Registry::Binding_Iterator::Iteration_State::Iteration_State (Binding_Iterat
{
}
-
+
ACE_Registry::Binding_Iterator::Object_Iteration::Object_Iteration (Binding_Iterator &iter)
: Iteration_State (iter)
{
}
-
+
ACE_Registry::Binding_Iterator::Context_Iteration::Context_Iteration (Binding_Iterator &iter)
: Iteration_State (iter)
{
}
-
+
ACE_Registry::Binding_Iterator::Iteration_Complete::Iteration_Complete (Binding_Iterator &iter)
: Iteration_State (iter)
{
@@ -861,7 +861,7 @@ ACE_Registry::Binding_Iterator::Iteration_Complete::Iteration_Complete (Binding_
// Next entry
-int
+int
ACE_Registry::Binding_Iterator::next_one (Binding &binding)
{
u_long how_many = 1;
@@ -869,18 +869,18 @@ ACE_Registry::Binding_Iterator::next_one (Binding &binding)
// Get next n (where n is one)
long result = this->next_n (how_many, list);
-
+
if (result == 0)
// Success
- binding = (*list.begin ());
-
+ binding = (*list.begin ());
+
return result;
}
// Next <how_many> entries
-int
-ACE_Registry::Binding_Iterator::next_n (u_long how_many,
+int
+ACE_Registry::Binding_Iterator::next_n (u_long how_many,
Binding_List &list)
{
// Empty list
@@ -891,18 +891,18 @@ ACE_Registry::Binding_Iterator::next_n (u_long how_many,
return this->current_enumeration_->next_n (how_many, list);
}
-
-// Destroy iterator
-int
+
+// Destroy iterator
+int
ACE_Registry::Binding_Iterator::destroy (void)
{
this->reset ();
return 0;
}
-
+
// Set/Get naming_context
-void
+void
ACE_Registry::Binding_Iterator::naming_context (Naming_Context &naming_context)
{
this->naming_context_ = &naming_context;
@@ -917,7 +917,7 @@ ACE_Registry::Binding_Iterator::naming_context (void)
// Set/Get current enumeration
-void
+void
ACE_Registry::Binding_Iterator::current_enumeration (Iteration_State &current_enumeration)
{
this->current_enumeration_ = &current_enumeration;
@@ -931,8 +931,8 @@ ACE_Registry::Binding_Iterator::current_enumeration (void)
}
-int
-ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many,
+int
+ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many,
Binding_List &list)
{
// Make a copy
@@ -945,19 +945,19 @@ ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many,
u_long size = sizeof string / sizeof (TCHAR);
long result = ::RegEnumValue (this->parent_->naming_context (). key(),
this->index_,
- string,
+ string,
&size,
0,
0,
0,
0);
switch (result)
- {
+ {
case ERROR_SUCCESS:
// Object found
{
// Readjust counters
- this->index_++;
+ this->index_++;
how_many--;
// Add to list
@@ -967,47 +967,47 @@ ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many,
list.insert (binding);
}
// Continue to add to list
- break;
-
+ break;
+
case ERROR_NO_MORE_ITEMS:
// Enumeration of objects complete
- // Reset index
- this->index_ = 0;
+ // Reset index
+ this->index_ = 0;
// Current enumeration will become CONTEXTS
- this->parent_->current_enumeration (this->parent_->context_iteration_);
+ this->parent_->current_enumeration (this->parent_->context_iteration_);
result = this->parent_->current_enumeration ().next_n (how_many,
list);
// If we were able to add objects
if (requested != how_many)
return 0;
- else
+ else
return result;
-
+
default:
- // Strange error
- // Reset index
- this->index_ = 0;
+ // Strange error
+ // Reset index
+ this->index_ = 0;
// Current enumeration will become COMPLETE
- this->parent_->current_enumeration (this->parent_->iteration_complete_);
- // strange error
+ this->parent_->current_enumeration (this->parent_->iteration_complete_);
+ // strange error
return -1;
}
- }
+ }
// If we reach here, all of <how_many> pairs were added to the list
- // Since more entries may be available
+ // Since more entries may be available
// current enumeration will remain OBJECTS
return 0;
}
-int
-ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many,
+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,19 +1015,19 @@ ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many,
u_long size = sizeof string / sizeof (TCHAR);
long result = ::RegEnumKeyEx (this->parent_->naming_context (). key (),
this->index_,
- string,
+ string,
&size,
0,
0,
0,
0);
switch (result)
- {
+ {
case ERROR_SUCCESS:
// Object found
{
// Readjust counters
- this->index_++;
+ this->index_++;
how_many--;
// Add to list
@@ -1037,7 +1037,7 @@ ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many,
list.insert (binding);
}
// Continue to add to list
- break;
+ break;
case ERROR_NO_MORE_ITEMS:
// Enumeration of objects complete
@@ -1045,29 +1045,29 @@ ACE_Registry::Binding_Iterator::Context_Iteration::next_n (u_long how_many,
/* FALL THROUGH */
default:
- // Strange error
+ // Strange error
- // Reset index
- this->index_ = 0;
+ // Reset index
+ this->index_ = 0;
// Current enumeration will become CONTEXTS
- this->parent_->current_enumeration (this->parent_->iteration_complete_);
+ this->parent_->current_enumeration (this->parent_->iteration_complete_);
// If we were able to add contexts
if (requested != how_many)
return 0;
- else
+ else
return -1;
}
}
// If we reach here, all of <how_many> pairs were added to the list
- // Since more entries may be available
+ // Since more entries may be available
// current enumeration will remain CONTEXTS
return 0;
}
-int
-ACE_Registry::Binding_Iterator::Iteration_Complete::next_n (u_long how_many,
+int
+ACE_Registry::Binding_Iterator::Iteration_Complete::next_n (u_long how_many,
Binding_List &list)
{
ACE_UNUSED_ARG(list);
@@ -1099,18 +1099,18 @@ ACE_Predefined_Naming_Contexts::connect (ACE_Registry::Naming_Context &naming_co
&naming_context.key_);
if (predefined == HKEY_CURRENT_USER || predefined == HKEY_CLASSES_ROOT)
// Make sure that for these types, the machine is local
- if (machine_name == 0 ||
+ if (machine_name == 0 ||
ACE_Predefined_Naming_Contexts::is_local_host (machine_name))
{
naming_context.key_ = predefined;
result = 0;
}
- else
+ else
result = -1;
-
+
ACE_REGISTRY_CALL_RETURN (result);
}
-
+
// Check if <machine_name> is the local host
/* static */
int
@@ -1124,5 +1124,5 @@ ACE_Predefined_Naming_Contexts::is_local_host (LPCTSTR machine_name)
result = 0;
return result;
}
-
+
#endif /* ACE_WIN32 */