(file) Return to cimmofMessages.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Compiler

  1 karl  1.21 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.10 //
  3 karl  1.19 // 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.17 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.19 // 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.20 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.21 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 mike  1.10 //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15 kumpf 1.13 // 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 mike  1.10 // 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            // 
 21 kumpf 1.13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 mike  1.10 // 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 kumpf 1.13 // 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 mike  1.10 // 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: Bob Blair (bblair@bmc.com)
 33            //
 34 gerarda 1.15 // Modified By:  Gerarda Marquez (gmarquez@us.ibm.com)
 35              //               -- PEP 43 changes
 36 mike    1.10 //
 37              //%/////////////////////////////////////////////////////////////////////////////
 38              
 39              
 40              //
 41              // implementation of cimmofMessages class
 42              
 43              #include "cimmofMessages.h"
 44              #include <cstdio>
 45              #include <iostream> // for debug only
 46 humberto 1.16 #include <Pegasus/Common/MessageLoader.h> //l10n
 47               #include <Pegasus/Common/Formatter.h> //l10n
 48 mike     1.10 
 49               PEGASUS_NAMESPACE_BEGIN
 50               PEGASUS_USING_STD;
 51               
 52               const cimmofMessages::arglist cimmofMessages::EMPTYLIST;
 53               
 54 humberto 1.16 //l10n replaced % sprintf style substitution with $ Formatter style substitution
 55 mike     1.10 static String _cimmofMessages[] = {
 56                 "OK", //CIM_ERR_SUCCESS
 57 humberto 1.16   "$0:$1: $2 before '$3'", //PARSER_SYNTAX_ERROR
 58                 "Error applying parameter $0 to method $1: $2", //APPLY_PARAMETER_ERROR
 59                 "Error creating new CIMParameter object $0: $1", //NEW_PARAMETER_ERROR
 60 mike     1.10                                                  //UNINTIALIZED_PARAMETER_ERROR
 61 humberto 1.16   "Internal Error: Uninitialized parameter handle $0 in class $1",
 62 mike     1.10                                                 //METHOD_ALREADY_EXISTS_WARNING
 63 humberto 1.16   "Warning: CIMMethod $0 already exists for CIMClass $1",
 64                 "Error applying method $0 to CIMClass $1: $2:", //APPLY_METHOD_ERROR
 65                 "Error creating new CIMMethod $0: $1", //NEW_METHOD_ERROR
 66 mike     1.10   "ADD QUALIFIER: ", //ADD_QUALIFIER
 67                 "[Trace]", //TRACE
 68 humberto 1.16   "Error adding qualifier declaration $0: $1", //ADD_QUALIFIER_DECL_ERROR
 69 mike     1.10   "\tOK", //TAB_OK
 70 humberto 1.16   "Error creating new Qualifier $0: $1", //NEW_QUALIFIER_ERROR
 71                 "Error adding new Qualifier $0: $1", //ADD_QUALIFIER_ERROR
 72 mike     1.10                                               //NEW_QUALIFIER_DECLARATION_ERROR
 73 humberto 1.16   "Error creating new Qualifier Declaration $0: $1",
 74 bob      1.11                                               // GET_QUALIFIER_DECL_ERROR
 75 humberto 1.16   "Could not find declaration for Qualifier named $0",
 76 mike     1.10   "ADD INSTANCE: ",  //ADD_INSTANCE
 77                                                                //UNINITIALIZED_PROPERTY_ERROR
 78 humberto 1.16   "Internal Error: Uninitialized parameter $1 in class $0",
 79 mike     1.10                                               //PROPERTY_ALREADY_EXISTS_WARNING
 80 humberto 1.16   "Warning:  Property $1 already exists in class $0",
 81                 "Error applying property $1 to class $0: $2", //APPLYING_PROPERTY_ERROR
 82                 "Error creating new Property $0: $1", //NEW_PROPERTY_ERROR
 83                 "Error creating new Class Declaration $0: $1", //NEW_CLASS_ERROR
 84 mike     1.10   "ADD CLASS: ", //ADD_CLASS
 85 humberto 1.16   "Warning:  Class $0 already exists in the repository", //CLASS_EXISTS_WARNING
 86                 "Error adding class $0 to the repository: $1", //ADD_CLASS_ERROR
 87 mike     1.10                                             //SETREPOSITORY_NO_COMPILER_OPTIONS
 88                 "Internal Error: Compiler options not set before setting repository",
 89                                                                    //SETREPOSITORY_BLANK_NAME
 90                 "Internal Error: No repository name was specified to setRepository",
 91                                                                      //NAMESPACE_CREATE_ERROR
 92 humberto 1.16   "Error trying to create repository name space $0: $1",
 93                 "Error trying to create Repository in path $0: $1", //REPOSITORY_CREATE_ERROR
 94                 "Error trying to create a reference to object $0: $1", //NEW_REFERENCE_ERROR
 95 mike     1.10                                               //FIND_CLASS_OF_INSTANCE_ERROR
 96 humberto 1.16   "Error looking for class of current instance while looking up property $0: $1",
 97 mike     1.10                                               // FIND_PROPERTY_VALUE_ERROR
 98 humberto 1.16   "Error looking up value of property $2 in class $1 (namespace $0): $3",
 99                 "Error cloning property $0: $1",            // CLONING_PROPERTY_ERROR
100 mike     1.10                                            // APPLY_INSTANCE_PROPERTY_ERROR
101 humberto 1.16   "Error applying property $0 to an instance of class $1: $2",
102 mike     1.10 	                                  // GET_INSTANCE_PROPERTY_ERROR
103 humberto 1.16   "Error getting property $0 from an instance: $1", 
104 chuck    1.18   "Error getting class $0 from name space $1: $2", //GET_CLASS_ERROR
105 humberto 1.16   "Error getting value of property $0: $1", //GET_PROPERTY_VALUE_ERROR
106                 "Error creating new instance of class $0: $1", // NEW_INSTANCE_ERROR
107 mike     1.10                                           // INSTANCE_PROPERTY_EXISTS_WARNING
108 humberto 1.16   "Warning: property $1 already exists for this instance of class $0",
109 mike     1.10 	                                  // INSTANCE_EXISTS_WARNING
110 kumpf    1.12   "Warning: the instance already exists.\nIn this"
111 mike     1.10   " implementation, that means it cannot be changed.",
112 humberto 1.16   "Error adding an instance: $0", // ADD_INSTANCE_ERROR
113                 "Error: $0", // GENERAL_ERROR
114                 "Warning:  Class $0 was not added or updated: $1",                    //CLASS_NOT_UPDATED   
115 gerarda  1.15   "Class has the same version",											//SAME_VERSION
116                 "Experimental update not allowed (set appropriate compiler option)",	//NO_EXPERIMENTAL_UPDATE
117                 "Version update not allowed (set appropriate compiler option)",		//NO_VERSION_UPDATE
118                 "Class update not allowed (set appropriate compiler option)",		    //NO_CLASS_UPDATE
119                 "Invalid version format in mof class or repository class (valid format is m.n.u)", //INVALID_VERSION_FORMAT
120 mike     1.10   ""
121               };
122 humberto 1.16 //l10n
123               static String _cimmofMessagesKeys [] = {
124               	
125                   "Compiler.cimmofMessages.CIM_ERR_SUCCESS",
126                   "Compiler.cimmofMessages.PARSER_SYNTAX_ERROR",
127                   "Compiler.cimmofMessages.APPLY_PARAMETER_ERROR",
128                   "Compiler.cimmofMessages.NEW_PARAMETER_ERROR",
129                   "Compiler.cimmofMessages.UNINITIALIZED_PARAMETER_ERROR",
130                   "Compiler.cimmofMessages.METHOD_ALREADY_EXISTS_WARNING",
131                   "Compiler.cimmofMessages.APPLY_METHOD_ERROR",
132                   "Compiler.cimmofMessages.NEW_METHOD_ERROR",
133                   "Compiler.cimmofMessages.ADD_QUALIFIER",
134                   "Compiler.cimmofMessages.TRACE",
135                   "Compiler.cimmofMessages.ADD_QUALIFIER_DECL_ERROR",
136                   "Compiler.cimmofMessages.TAB_OK",
137                   "Compiler.cimmofMessages.NEW_QUALIFIER_ERROR",
138                   "Compiler.cimmofMessages.ADD_QUALIFIER_ERROR",
139                   "Compiler.cimmofMessages.NEW_QUALIFIER_DECLARATION_ERROR",
140                   "Compiler.cimmofMessages.GET_QUALIFIER_DECL_ERROR",
141                   "Compiler.cimmofMessages.ADD_INSTANCE",
142                   "Compiler.cimmofMessages.UNINITIALIZED_PROPERTY_ERROR",
143 humberto 1.16     "Compiler.cimmofMessages.PROPERTY_ALREADY_EXISTS_WARNING",
144                   "Compiler.cimmofMessages.APPLYING_PROPERTY_ERROR",
145                   "Compiler.cimmofMessages.NEW_PROPERTY_ERROR",
146                   "Compiler.cimmofMessages.NEW_CLASS_ERROR",
147                   "Compiler.cimmofMessages.ADD_CLASS",
148                   "Compiler.cimmofMessages.CLASS_EXISTS_WARNING",
149                   "Compiler.cimmofMessages.ADD_CLASS_ERROR",
150                   "Compiler.cimmofMessages.SETREPOSITORY_NO_COMPILER_OPTIONS",
151                   "Compiler.cimmofMessages.SETREPOSITORY_BLANK_NAME",
152                   "Compiler.cimmofMessages.NAMESPACE_CREATE_ERROR",
153                   "Compiler.cimmofMessages.REPOSITORY_CREATE_ERROR",
154                   "Compiler.cimmofMessages.NEW_REFERENCE_ERROR",
155                   "Compiler.cimmofMessages.FIND_CLASS_OF_INSTANCE_ERROR",
156                   "Compiler.cimmofMessages.FIND_PROPERTY_VALUE_ERROR",
157                   "Compiler.cimmofMessages.CLONING_PROPERTY_ERROR",
158                   "Compiler.cimmofMessages.APPLY_INSTANCE_PROPERTY_ERROR",
159                   "Compiler.cimmofMessages.GET_INSTANCE_PROPERTY_ERROR",
160 chuck    1.18     "Compiler.cimmofMessages.GET_CLASS_ERROR",
161 humberto 1.16     "Compiler.cimmofMessages.GET_PROPERTY_VALUE_ERROR",
162                   "Compiler.cimmofMessages.NEW_INSTANCE_ERROR",
163                   "Compiler.cimmofMessages.INSTANCE_PROPERTY_EXISTS_WARNING",
164                   "Compiler.cimmofMessages.INSTANCE_EXISTS_WARNING",
165                   "Compiler.cimmofMessages.ADD_INSTANCE_ERROR",
166                   "Compiler.cimmofMessages.GENERAL_ERROR",
167                   "Compiler.cimmofMessages.CLASS_NOT_UPDATED",
168                   "Compiler.cimmofMessages.SAME_VERSION",
169                   "Compiler.cimmofMessages.NO_EXPERIMENTAL_UPDATE",
170                   "Compiler.cimmofMessages.NO_VERSION_UPDATE",
171                   "Compiler.cimmofMessages.NO_CLASS_UPDATE",
172                   "Compiler.cimmofMessages.INVALID_VERSION_FORMAT",
173                   "Compiler.cimmofMessages.END"	
174               	
175               };
176               
177 mike     1.10 
178               const String &
179               cimmofMessages::msgCodeToString(MsgCode code)
180 humberto 1.16 {	
181                   return _cimmofMessages[(unsigned int)code];   
182 mike     1.10 }
183               
184               static int
185               find(const String &haystack, const String &needle)
186               {
187                 unsigned int size = haystack.size();
188                 unsigned int npos = 0;
189                 unsigned int nsize = needle.size();
190                 for (unsigned int i = 0; i < size; i++) {
191                   if (haystack[i] == '\\')
192                     i++;
193                   if (haystack[i] == needle[npos]) {
194                     npos++;
195                     if (npos >= nsize)
196               	return ( (int)(i - nsize + 1) );
197                   } else {
198                     npos = 0;
199                   }
200                 }
201                 return -1;
202               }
203 mike     1.10 
204               static void 
205               replace(String &s, unsigned int pos, unsigned int len, const String &r)
206               {
207                 String s1 = s.subString(0, pos) + r + s.subString(pos  + len);
208                 s = s1;
209               }
210               
211               void
212               cimmofMessages::getMessage(String &out, MsgCode code, const arglist &args)
213               {
214 humberto 1.16   //l10n
215                 Array<String> _args;
216                 for (unsigned int i = 0; i < 10; i++) {
217                 	if(i < args.size())
218                 		_args.append(args[i]);
219                 	else
220                 		_args.append("");
221 mike     1.10   }
222 humberto 1.16   
223                 MessageLoaderParms parms(_cimmofMessagesKeys[(unsigned int)code],
224                 						   _cimmofMessages[(unsigned int)code],
225                 						   _args[0],_args[1],_args[2],_args[3],_args[4],
226                 						   _args[5],_args[6],_args[7],_args[8],_args[9]);
227                 						   
228                 out = MessageLoader::getMessage(parms);
229                 
230                 //String s = msgCodeToString(code);
231                 //out = s;
232                 //int pos;
233                 //for (unsigned int i = 0; i < args.size(); i++) {
234                   //int state = 0;
235                   //char buf[40];
236                   //sprintf(buf, "%d", i + 1);
237                   //String srchstr = "%";
238                   //srchstr.append(buf);
239                   //if ( (pos = find(out, srchstr)) != -1 ) {
240                     //replace(out, pos, srchstr.size(), args[i]);
241                   //}
242                 //}
243 mike     1.10 }
244               
245               PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2