WinRegistryConfiguration.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // WinRegistryConfiguration.h
  3. //
  4. // Library: Util
  5. // Package: Windows
  6. // Module: WinRegistryConfiguration
  7. //
  8. // Definition of the WinRegistryConfiguration class.
  9. //
  10. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef Util_WinRegistryConfiguration_INCLUDED
  16. #define Util_WinRegistryConfiguration_INCLUDED
  17. #include "Poco/Util/Util.h"
  18. #include "Poco/Util/AbstractConfiguration.h"
  19. #include "Poco/String.h"
  20. namespace Poco {
  21. namespace Util {
  22. class Util_API WinRegistryConfiguration: public AbstractConfiguration
  23. /// An implementation of AbstractConfiguration that stores configuration data
  24. /// in the Windows registry.
  25. ///
  26. /// Removing key is not supported. An attempt to remove a key results
  27. /// in a NotImplementedException being thrown.
  28. {
  29. public:
  30. WinRegistryConfiguration(const std::string& rootPath, REGSAM extraSam = 0);
  31. /// Creates the WinRegistryConfiguration.
  32. /// The rootPath must start with one of the root key names
  33. /// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
  34. /// All further keys are relative to the root path and can be
  35. /// dot separated, e.g. the path MyService.ServiceName will be converted to
  36. /// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\ServiceName.
  37. /// The extraSam parameter will be passed along to WinRegistryKey, to control
  38. /// registry virtualization for example.
  39. protected:
  40. ~WinRegistryConfiguration();
  41. /// Destroys the WinRegistryConfiguration.
  42. bool getRaw(const std::string& key, std::string& value) const;
  43. void setRaw(const std::string& key, const std::string& value);
  44. void enumerate(const std::string& key, Keys& range) const;
  45. void removeRaw(const std::string& key);
  46. std::string convertToRegFormat(const std::string& key, std::string& keyName) const;
  47. /// Takes a key in the format of A.B.C and converts it to
  48. /// registry format A\B\C, the last entry is the keyName, the rest is returned as path
  49. friend class WinConfigurationTest;
  50. private:
  51. std::string _rootPath;
  52. REGSAM _extraSam;
  53. };
  54. } } // namespace Poco::Util
  55. #endif // Util_WinRegistryConfiguration_INCLUDED