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 // Author: Nag Boranna (nagaraja_boranna@hp.com)
33 //
|
34 vijay.eli 1.10 // Modified By: Vijay Eli, IBM (vijayeli@in.ibm.com), bug#3608.
|
35 david.dillard 1.11 // David Dillard, VERITAS Software Corp.
36 // (david.dillard@veritas.com)
|
37 mike 1.2 //
38 //%/////////////////////////////////////////////////////////////////////////////
39
40 #ifndef Pegasus_ConfigFile_h
41 #define Pegasus_ConfigFile_h
42
43 #include <Pegasus/Common/Config.h>
44 #include <Pegasus/Config/Linkage.h>
45 #include <Pegasus/Common/String.h>
|
46 kumpf 1.5 #include <Pegasus/Common/ArrayInternal.h>
|
47 kumpf 1.4 #include <Pegasus/Common/InternalException.h>
|
48 mike 1.2 #include <Pegasus/Config/ConfigExceptions.h>
49
50 PEGASUS_NAMESPACE_BEGIN
51
52 ////////////////////////////////////////////////////////////////////////////////
53 // ConfigFile Class
54 ////////////////////////////////////////////////////////////////////////////////
55
56 struct ConfigTable;
57
58 /**
|
59 david.dillard 1.11 This class provides methods to read/write configuration properties from the
|
60 mike 1.2 config file.
61 */
62 class PEGASUS_CONFIG_LINKAGE ConfigFile
63 {
64 public:
65
|
66 david.dillard 1.11 /**
67 Constructor.
|
68 mike 1.2
69 @exception FileNotReadable if the specified file is not readable.
70 */
71 ConfigFile(const String& fileName);
72
73
74 /** Destructor. */
|
75 david.dillard 1.11 ~ConfigFile();
|
76 mike 1.2
77
|
78 david.dillard 1.11 /**
|
79 mike 1.2 Get the name of the configuration file.
80
81 @return String name of the config file.
82 */
|
83 vijay.eli 1.10 String getFileName() const;
|
84 mike 1.2
85
|
86 david.dillard 1.11 /**
|
87 mike 1.2 Load the properties from the config file.
88
89 @param confTable hash table containing the config properties.
90 @exception ConfigFileSyntaxError if config file contains a syntax error.
91
|
92 david.dillard 1.11 Note: Original code was taken from OptionManager::mergeFile()
|
93 mike 1.2 */
94 void load(ConfigTable* confTable);
95
96
|
97 david.dillard 1.11 /**
|
98 mike 1.2 Save the properties to the config file.
99
100 @param confTable hash table containing the config properties.
|
101 david.dillard 1.11 @exception CannotRenameFile if failed to create the backup file.
102 @exception CannotOpenFile if failed to set permissions on the config file.
|
103 mike 1.2 */
104 void save(ConfigTable* confTable);
105
106
|
107 david.dillard 1.11 /**
|
108 mike 1.2 Replace the properties in the config file with the properties from
109 the given file
110
111 @param fileName the config file name to be copied.
112 @exception NoSuchFile if the specified file cannot be opened.
113 @exception FileNotReadable if the specified file is not readable.
114 @exception CannotRenameFile if failed to create the backup file.
|
115 david.dillard 1.11 @exception CannotOpenFile if failed to set permissions on the config file.
|
116 mike 1.2 */
117 void replace(const String& fileName);
118
119
120 private:
121 String _configFile;
122 String _configBackupFile;
123 };
124
125
126 PEGASUS_NAMESPACE_END
127
128 #endif /* Pegasus_ConfigFile_h */
|