1 martin 1.28 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.29 //
|
3 martin 1.28 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.29 //
|
10 martin 1.28 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.29 //
|
17 martin 1.28 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.29 //
|
20 martin 1.28 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.29 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.29 //
|
28 martin 1.28 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.10 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 //
33 // implementation of cimmofMessages class
34
35 #include "cimmofMessages.h"
36 #include <cstdio>
37 #include <iostream> // for debug only
|
38 kumpf 1.22 #include <Pegasus/Common/MessageLoader.h>
|
39 mike 1.10
40 PEGASUS_NAMESPACE_BEGIN
41 PEGASUS_USING_STD;
42
43 const cimmofMessages::arglist cimmofMessages::EMPTYLIST;
44
|
45 kumpf 1.27 static const char* _cimmofMessages[] =
|
46 karl 1.23 {
47 "OK", //CIM_ERR_SUCCESS
48 "$0:$1: $2 before '$3'", //PARSER_SYNTAX_ERROR
49 "Error applying parameter $0 to method $1: $2", //APPLY_PARAMETER_ERROR
50 "Error creating new CIMParameter object $0: $1", //NEW_PARAMETER_ERROR
51 //UNINTIALIZED_PARAMETER_ERROR
52 "Internal Error: Uninitialized parameter handle $0 in class $1",
53 //METHOD_ALREADY_EXISTS_WARNING
54 "Warning: CIMMethod $0 already exists for CIMClass $1",
55 "Error applying method $0 to CIMClass $1: $2:", //APPLY_METHOD_ERROR
56 "Error creating new CIMMethod $0: $1", //NEW_METHOD_ERROR
57 "ADD QUALIFIER: ", //ADD_QUALIFIER
58 "[Trace]", //TRACE
59 "Error adding qualifier declaration $0: $1", //ADD_QUALIFIER_DECL_ERROR
60 "\tOK", //TAB_OK
61 "Error creating new Qualifier $0: $1", //NEW_QUALIFIER_ERROR
62 "Error adding new Qualifier $0: $1", //ADD_QUALIFIER_ERROR
63 //NEW_QUALIFIER_DECLARATION_ERROR
64 "Error creating new Qualifier Declaration $0: $1",
65 // GET_QUALIFIER_DECL_ERROR
66 "Could not find declaration for Qualifier named $0",
67 karl 1.23 "ADD INSTANCE: ", //ADD_INSTANCE
68 //UNINITIALIZED_PROPERTY_ERROR
69 "Internal Error: Uninitialized parameter $1 in class $0",
70 //PROPERTY_ALREADY_EXISTS_WARNING
71 "Warning: Property $1 already exists in class $0",
72 "Error applying property $1 to class $0: $2", //APPLYING_PROPERTY_ERROR
73 "Error creating new Property $0: $1", //NEW_PROPERTY_ERROR
74 "Error creating new Class Declaration $0: $1", //NEW_CLASS_ERROR
75 "ADD CLASS: ", //ADD_CLASS
76 "Warning: Class $0 already exists in the repository",//CLASS_EXISTS_WARNING
77 "Error adding class $0 to the repository: $1", //ADD_CLASS_ERROR
78 //SETREPOSITORY_NO_COMPILER_OPTIONS
79 "Internal Error: Compiler options not set before setting repository",
80 //SETREPOSITORY_BLANK_NAME
81 "Internal Error: No repository name was specified to setRepository",
82 //NAMESPACE_CREATE_ERROR
83 "Error trying to create repository name space $0: $1",
84 // REPOSITORY_CREATE_ERROR
85 "Error trying to create Repository in path $0: $1",
86 // NEW_REFERENCE_ERROR
87 "Error trying to create a reference to object $0: $1",
88 karl 1.23 //FIND_CLASS_OF_INSTANCE_ERROR
89 "Error looking for class of current instance while looking up property"
90 " $0: $1",
91 // FIND_PROPERTY_VALUE_ERROR
92 "Error looking up value of property $2 in class $1 (namespace $0): $3",
93 "Error cloning property $0: $1", // CLONING_PROPERTY_ERROR
94 // APPLY_INSTANCE_PROPERTY_ERROR
95 "Error applying property $0 to an instance of class $1: $2",
96 // GET_INSTANCE_PROPERTY_ERROR
97 "Error getting property $0 from an instance: $1",
|
98 runfang.zhou 1.24 "Error getting class $0 from namespace $1: $2", //GET_CLASS_ERROR
|
99 karl 1.23 "Error getting value of property $0: $1", //GET_PROPERTY_VALUE_ERROR
100 "Error creating new instance of class $0: $1", // NEW_INSTANCE_ERROR
101 // INSTANCE_PROPERTY_EXISTS_WARNING
102 "Warning: property $1 already exists for this instance of class $0",
103 // INSTANCE_EXISTS_WARNING
104 "Warning: the instance already exists.\nIn this"
105 " implementation, that means it cannot be changed.",
106 "Error adding an instance: $0", // ADD_INSTANCE_ERROR
107 "Error: $0", // GENERAL_ERROR
108 "Warning: Class $0 was not added or updated: $1", //CLASS_NOT_UPDATED
109 "Class has the same version", //SAME_VERSION
110 // NO_EXPERIMENTAL_UPDATE
111 "Experimental update not allowed (set appropriate compiler option)",
112 //NO_VERSION_UPDATE
113 "Version update not allowed (set appropriate compiler option)",
114 //NO_CLASS_UPDATE
115 "Class update not allowed (set appropriate compiler option)",
116 //INVALID_VERSION_FORMAT
117 "Invalid version format in mof class or repository class"
118 " (valid format is m.n.u)", //INVALID_VERSION_FORMAT
|
119 kumpf 1.25 "Invalid $0 value: $1", // INVALID_LITERAL_VALUE
|
120 karl 1.29.8.1 "Class alias $0 found for class $1. This function not implemented",
121 "Class $1 not found for instance alias $0",
122 "Warning: Pragma \"$0\" not implemented by the compiler. Ignored",
123 "Warning: Pragma locale value \"$0\" not defined by compiler. Ignored",
|
124 karl 1.23 ""
|
125 mike 1.10 };
|
126 kumpf 1.27
127 static const char* _cimmofMessagesKeys [] =
|
128 kumpf 1.22 {
|
129 humberto 1.16 "Compiler.cimmofMessages.CIM_ERR_SUCCESS",
130 "Compiler.cimmofMessages.PARSER_SYNTAX_ERROR",
131 "Compiler.cimmofMessages.APPLY_PARAMETER_ERROR",
132 "Compiler.cimmofMessages.NEW_PARAMETER_ERROR",
133 "Compiler.cimmofMessages.UNINITIALIZED_PARAMETER_ERROR",
134 "Compiler.cimmofMessages.METHOD_ALREADY_EXISTS_WARNING",
135 "Compiler.cimmofMessages.APPLY_METHOD_ERROR",
136 "Compiler.cimmofMessages.NEW_METHOD_ERROR",
137 "Compiler.cimmofMessages.ADD_QUALIFIER",
138 "Compiler.cimmofMessages.TRACE",
139 "Compiler.cimmofMessages.ADD_QUALIFIER_DECL_ERROR",
140 "Compiler.cimmofMessages.TAB_OK",
141 "Compiler.cimmofMessages.NEW_QUALIFIER_ERROR",
142 "Compiler.cimmofMessages.ADD_QUALIFIER_ERROR",
143 "Compiler.cimmofMessages.NEW_QUALIFIER_DECLARATION_ERROR",
144 "Compiler.cimmofMessages.GET_QUALIFIER_DECL_ERROR",
145 "Compiler.cimmofMessages.ADD_INSTANCE",
146 "Compiler.cimmofMessages.UNINITIALIZED_PROPERTY_ERROR",
147 "Compiler.cimmofMessages.PROPERTY_ALREADY_EXISTS_WARNING",
148 "Compiler.cimmofMessages.APPLYING_PROPERTY_ERROR",
149 "Compiler.cimmofMessages.NEW_PROPERTY_ERROR",
150 humberto 1.16 "Compiler.cimmofMessages.NEW_CLASS_ERROR",
151 "Compiler.cimmofMessages.ADD_CLASS",
152 "Compiler.cimmofMessages.CLASS_EXISTS_WARNING",
153 "Compiler.cimmofMessages.ADD_CLASS_ERROR",
154 "Compiler.cimmofMessages.SETREPOSITORY_NO_COMPILER_OPTIONS",
155 "Compiler.cimmofMessages.SETREPOSITORY_BLANK_NAME",
156 "Compiler.cimmofMessages.NAMESPACE_CREATE_ERROR",
157 "Compiler.cimmofMessages.REPOSITORY_CREATE_ERROR",
158 "Compiler.cimmofMessages.NEW_REFERENCE_ERROR",
159 "Compiler.cimmofMessages.FIND_CLASS_OF_INSTANCE_ERROR",
160 "Compiler.cimmofMessages.FIND_PROPERTY_VALUE_ERROR",
161 "Compiler.cimmofMessages.CLONING_PROPERTY_ERROR",
162 "Compiler.cimmofMessages.APPLY_INSTANCE_PROPERTY_ERROR",
163 "Compiler.cimmofMessages.GET_INSTANCE_PROPERTY_ERROR",
|
164 chuck 1.18 "Compiler.cimmofMessages.GET_CLASS_ERROR",
|
165 humberto 1.16 "Compiler.cimmofMessages.GET_PROPERTY_VALUE_ERROR",
166 "Compiler.cimmofMessages.NEW_INSTANCE_ERROR",
167 "Compiler.cimmofMessages.INSTANCE_PROPERTY_EXISTS_WARNING",
168 "Compiler.cimmofMessages.INSTANCE_EXISTS_WARNING",
169 "Compiler.cimmofMessages.ADD_INSTANCE_ERROR",
170 "Compiler.cimmofMessages.GENERAL_ERROR",
171 "Compiler.cimmofMessages.CLASS_NOT_UPDATED",
172 "Compiler.cimmofMessages.SAME_VERSION",
173 "Compiler.cimmofMessages.NO_EXPERIMENTAL_UPDATE",
174 "Compiler.cimmofMessages.NO_VERSION_UPDATE",
175 "Compiler.cimmofMessages.NO_CLASS_UPDATE",
176 "Compiler.cimmofMessages.INVALID_VERSION_FORMAT",
|
177 kumpf 1.25 "Compiler.cimmofMessages.INVALID_LITERAL_VALUE",
|
178 karl 1.29.8.1 "Compiler.cimmofMessages::CLASS_ALIAS_FOUND",
179 "Compiler.cimmofMessages::INSTANCE_ALIAS_CLASS_NOT_FOUND",
180 "Compiler.cimmofMessages::PRAGMA_NOT_IMPLEMENTED_WARNING",
181 "Compiler.commofMessages::LOCALE_NOT_IMPLEMENTED_WARNING",
|
182 karl 1.23 "Compiler.cimmofMessages.END"
|
183 humberto 1.16 };
184
|
185 mike 1.10
|
186 kumpf 1.27 const char* cimmofMessages::msgCodeToString(MsgCode code)
|
187 karl 1.23 {
188 return _cimmofMessages[(unsigned int)code];
|
189 mike 1.10 }
190
|
191 karl 1.23 void cimmofMessages::getMessage(String &out, MsgCode code, const arglist &args)
|
192 mike 1.10 {
|
193 karl 1.23 Array<String> _args;
194 for (unsigned int i = 0; i < 10; i++)
195 {
196 if(i < args.size())
197 _args.append(args[i]);
198 else
199 _args.append("");
200 }
201
202 MessageLoaderParms parms(_cimmofMessagesKeys[(unsigned int)code],
203 _cimmofMessages[(unsigned int)code],
204 _args[0],_args[1],_args[2],_args[3],_args[4],
205 _args[5],_args[6],_args[7],_args[8],_args[9]);
206
207 out = MessageLoader::getMessage(parms);
|
208 mike 1.10 }
209
210 PEGASUS_NAMESPACE_END
|