1 #ifndef REGISTRY_CONFIGURATOR_CLASS
2 #define REGISTRY_CONFIGURATOR_CLASS
5 * Name : registry_configurator *
6 * Author : Chris Koeritz *
8 * Copyright (c) 2004-$now By Author. This program is free software; you can *
9 * redistribute it and/or modify it under the terms of the GNU General Public *
10 * License as published by the Free Software Foundation; either version 2 of *
11 * the License or (at your option) any later version. This is online at: *
12 * http://www.fsf.org/copyleft/gpl.html *
13 * Please send any updates to: fred@gruntose.com *
16 #include <basis/contracts.h>
17 #include <configuration/configurator.h>
18 #include <filesystem/byte_filer.h>
19 #include <filesystem/filename.h>
21 namespace configuration {
23 //! Supports the configurator class interface on the windows registry.
25 class registry_configurator : public configurator
28 //! the hives are major partitions of the registry.
35 // abbreviations for the above sections...
36 HKCR = hkey_classes_root,
37 HKCU = hkey_current_user,
38 HKLM = hkey_local_machine,
40 HKCC = hkey_current_config
43 registry_configurator(registry_hives hive, treatment_of_defaults behavior);
44 //!< creates a registry_configurator that stores entries into the "hive".
45 /*!< applies the "behavior" to items that are not found. */
47 virtual ~registry_configurator();
49 DEFINE_CLASS_NAME("registry_configurator");
51 virtual bool get(const basis::astring §ion, const basis::astring &entry,
52 basis::astring &found);
53 //!< implements the configurator retrieval function.
54 /*!< note that for registry based retrieval, an empty "entry" is allowed,
55 and that specifies the default item in the "section". */
57 virtual bool section_exists(const basis::astring §ion);
58 //!< returns true if the "section" was found in the file.
60 virtual bool put(const basis::astring §ion, const basis::astring &entry,
61 const basis::astring &to_store);
62 //!< implements the configurator storage function.
63 /*!< put interprets an empty string for "entry" as pointing at the
64 default item in the "section". */
66 virtual bool delete_section(const basis::astring §ion);
67 //!< removes the entire "section" specified.
69 virtual bool delete_entry(const basis::astring §ion, const basis::astring &entry);
70 //!< removes the entry specified by the "section" and "entry" name.
72 virtual bool get_section(const basis::astring §ion, structures::string_table &info);
73 //!< reads the entire "section" into a table called "info".
74 /*!< on win-9x, this will fail if the section's data exceeds 32K. */
76 virtual bool put_section(const basis::astring §ion, const structures::string_table &info);
77 //!< writes a table called "info" into the "section" in the INI file.
78 /*!< any existing data for that section is wiped out. on win-9x, this will
79 fail if the section's data exceeds 32K. */
81 void *translate_hive(registry_hives hive);
82 //!< translates from our enum to the windows specific type for hives.
84 basis::astring fix_section(const basis::astring §ion);
85 //!< repairs malformed section names.
86 /*!< translates a section name that might use forward slashes into the
87 form required for windows that uses backslashes. */
90 registry_hives _hive; //!< which hive our entries are stored in.
93 registry_configurator(const registry_configurator &);
94 registry_configurator &operator =(const registry_configurator &);
96 static const basis::astring ®_str_fake_default();