1 karl 1.12 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.8 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.8 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.12 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.12 //
|
21 mike 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_ConfigFile_h
35 #define Pegasus_ConfigFile_h
36
37 #include <Pegasus/Common/Config.h>
38 #include <Pegasus/Config/Linkage.h>
39 #include <Pegasus/Common/String.h>
|
40 kumpf 1.5 #include <Pegasus/Common/ArrayInternal.h>
|
41 kumpf 1.4 #include <Pegasus/Common/InternalException.h>
|
42 mike 1.2 #include <Pegasus/Config/ConfigExceptions.h>
43
44 PEGASUS_NAMESPACE_BEGIN
45
46 ////////////////////////////////////////////////////////////////////////////////
47 // ConfigFile Class
48 ////////////////////////////////////////////////////////////////////////////////
49
50 struct ConfigTable;
51
52 /**
|
53 david.dillard 1.11 This class provides methods to read/write configuration properties from the
|
54 mike 1.2 config file.
55 */
56 class PEGASUS_CONFIG_LINKAGE ConfigFile
57 {
58 public:
59
|
60 david.dillard 1.11 /**
61 Constructor.
|
62 mike 1.2
63 @exception FileNotReadable if the specified file is not readable.
64 */
65 ConfigFile(const String& fileName);
66
67
68 /** Destructor. */
|
69 david.dillard 1.11 ~ConfigFile();
|
70 mike 1.2
71
|
72 david.dillard 1.11 /**
|
73 mike 1.2 Get the name of the configuration file.
74
75 @return String name of the config file.
76 */
|
77 vijay.eli 1.10 String getFileName() const;
|
78 mike 1.2
79
|
80 david.dillard 1.11 /**
|
81 mike 1.2 Load the properties from the config file.
82
83 @param confTable hash table containing the config properties.
84 @exception ConfigFileSyntaxError if config file contains a syntax error.
85
|
86 david.dillard 1.11 Note: Original code was taken from OptionManager::mergeFile()
|
87 mike 1.2 */
88 void load(ConfigTable* confTable);
89
90
|
91 david.dillard 1.11 /**
|
92 mike 1.2 Save the properties to the config file.
93
94 @param confTable hash table containing the config properties.
|
95 david.dillard 1.11 @exception CannotRenameFile if failed to create the backup file.
96 @exception CannotOpenFile if failed to set permissions on the config file.
|
97 mike 1.2 */
98 void save(ConfigTable* confTable);
99
100
|
101 david.dillard 1.11 /**
|
102 mike 1.2 Replace the properties in the config file with the properties from
103 the given file
104
105 @param fileName the config file name to be copied.
106 @exception NoSuchFile if the specified file cannot be opened.
107 @exception FileNotReadable if the specified file is not readable.
108 @exception CannotRenameFile if failed to create the backup file.
|
109 david.dillard 1.11 @exception CannotOpenFile if failed to set permissions on the config file.
|
110 mike 1.2 */
111 void replace(const String& fileName);
112
113
114 private:
115 String _configFile;
116 String _configBackupFile;
117 };
118
119
120 PEGASUS_NAMESPACE_END
121
122 #endif /* Pegasus_ConfigFile_h */
|