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

  1 mike  1.10 //%/////////////////////////////////////////////////////////////////////////////
  2            //
  3 kumpf 1.13 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4            // The Open Group, Tivoli Systems
  5 mike  1.10 //
  6            // Permission is hereby granted, free of charge, to any person obtaining a copy
  7 kumpf 1.13 // of this software and associated documentation files (the "Software"), to
  8            // deal in the Software without restriction, including without limitation the
  9            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10 mike  1.10 // sell copies of the Software, and to permit persons to whom the Software is
 11            // furnished to do so, subject to the following conditions:
 12            // 
 13 kumpf 1.13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14 mike  1.10 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16 kumpf 1.13 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19 mike  1.10 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21            //
 22            //==============================================================================
 23            //
 24            // Author: Bob Blair (bblair@bmc.com)
 25            //
 26 gerarda 1.15 // Modified By:  Gerarda Marquez (gmarquez@us.ibm.com)
 27              //               -- PEP 43 changes
 28 mike    1.10 //
 29              //%/////////////////////////////////////////////////////////////////////////////
 30              
 31              
 32              //
 33              // implementation of cimmofMessages class
 34              
 35              #include "cimmofMessages.h"
 36              #include <cstdio>
 37              #include <iostream> // for debug only
 38              
 39              PEGASUS_NAMESPACE_BEGIN
 40              PEGASUS_USING_STD;
 41              
 42              const cimmofMessages::arglist cimmofMessages::EMPTYLIST;
 43              
 44              static String _cimmofMessages[] = {
 45                "OK", //CIM_ERR_SUCCESS
 46                "%1:%2: %3 before '%4'", //PARSER_SYNTAX_ERROR
 47                "Error applying parameter %1 to method %2: %3", //APPLY_PARAMETER_ERROR
 48                "Error creating new CIMParameter object %1: %2", //NEW_PARAMETER_ERROR
 49 mike    1.10                                                  //UNINTIALIZED_PARAMETER_ERROR
 50                "Internal Error: Uninitialized parameter handle %1 in class %2",
 51                                                              //METHOD_ALREADY_EXISTS_WARNING
 52                "Warning: CIMMethod %1 already exists for CIMClass %2",
 53                "Error applying method %1 to CIMClass %2: %3:", //APPLY_METHOD_ERROR
 54                "Error creating new CIMMethod %1: %2", //NEW_METHOD_ERROR
 55                "ADD QUALIFIER: ", //ADD_QUALIFIER
 56                "[Trace]", //TRACE
 57                "Error adding qualifier declaration %1: %2", //ADD_QUALIFIER_DECL_ERROR
 58                "\tOK", //TAB_OK
 59                "Error creating new Qualifier %1: %2", //NEW_QUALIFIER_ERROR
 60                "Error adding new Qualifier %1: %2", //ADD_QUALIFIER_ERROR
 61                                                            //NEW_QUALIFIER_DECLARATION_ERROR
 62                "Error creating new Qualifier Declaration %1: %2",
 63 bob     1.11                                               // GET_QUALIFIER_DECL_ERROR
 64                "Could not find declaration for Qualifier named %1",
 65 mike    1.10   "ADD INSTANCE: ",  //ADD_INSTANCE
 66                                                               //UNINITIALIZED_PROPERTY_ERROR
 67                "Internal Error: Uninitialized parameter %2 in class %1",
 68                                                            //PROPERTY_ALREADY_EXISTS_WARNING
 69                "Warning:  Property %2 already exists in class %1",
 70                "Error applying property %2 to class %1: %3", //APPLYING_PROPERTY_ERROR
 71                "Error creating new Property %1: %2", //NEW_PROPERTY_ERROR
 72                "Error creating new Class Declaration %1: %2", //NEW_CLASS_ERROR
 73                "ADD CLASS: ", //ADD_CLASS
 74                "Warning:  Class %1 already exists in the repository", //CLASS_EXISTS_WARNING
 75                "Error adding class %1 to the repository: %2", //ADD_CLASS_ERROR
 76                                                          //SETREPOSITORY_NO_COMPILER_OPTIONS
 77                "Internal Error: Compiler options not set before setting repository",
 78                                                                   //SETREPOSITORY_BLANK_NAME
 79                "Internal Error: No repository name was specified to setRepository",
 80                                                                     //NAMESPACE_CREATE_ERROR
 81                "Error trying to create repository name space %1: %2",
 82                "Error trying to create Repository in path %1: %2", //REPOSITORY_CREATE_ERROR
 83                "Error trying to create a reference to object %1: %2", //NEW_REFERENCE_ERROR
 84                                                            //FIND_CLASS_OF_INSTANCE_ERROR
 85                "Error looking for class of current instance while looking up property %1: %2",
 86 mike    1.10                                               // FIND_PROPERTY_VALUE_ERROR
 87                "Error looking up value of property %3 in class %2 (namespace %1): %4",
 88                "Error cloning property %1: %2",            // CLONING_PROPERTY_ERROR
 89                                                         // APPLY_INSTANCE_PROPERTY_ERROR
 90                "Error applying property %1 to an instance of class %2: %3",
 91              	                                  // GET_INSTANCE_PROPERTY_ERROR
 92                "Error getting property %1 from an instance: %2", 
 93                "Error getting property %1 from class %2: %4", //GET_CLASS_PROPERTY_ERROR
 94                "Error getting value of property %1: %2", //GET_PROPERTY_VALUE_ERROR
 95                "Error creating new instance of class %1: %2", // NEW_INSTANCE_ERROR
 96                                                        // INSTANCE_PROPERTY_EXISTS_WARNING
 97                "Warning: property %2 already exists for this instance of class %1",
 98              	                                  // INSTANCE_EXISTS_WARNING
 99 kumpf   1.12   "Warning: the instance already exists.\nIn this"
100 mike    1.10   " implementation, that means it cannot be changed.",
101 kumpf   1.12   "Error adding an instance: %1", // ADD_INSTANCE_ERROR
102 kumpf   1.14   "Error: %1", // GENERAL_ERROR
103 gerarda 1.15   "Warning:  Class %1 was not added or updated: %2",                    //CLASS_NOT_UPDATED   
104                "Class has the same version",											//SAME_VERSION
105                "Experimental update not allowed (set appropriate compiler option)",	//NO_EXPERIMENTAL_UPDATE
106                "Version update not allowed (set appropriate compiler option)",		//NO_VERSION_UPDATE
107                "Class update not allowed (set appropriate compiler option)",		    //NO_CLASS_UPDATE
108                "Invalid version format in mof class or repository class (valid format is m.n.u)", //INVALID_VERSION_FORMAT
109 mike    1.10   ""
110              };
111              
112              const String &
113              cimmofMessages::msgCodeToString(MsgCode code)
114              {
115                return _cimmofMessages[(unsigned int)code];
116              }
117              
118              static int
119              find(const String &haystack, const String &needle)
120              {
121                unsigned int size = haystack.size();
122                unsigned int npos = 0;
123                unsigned int nsize = needle.size();
124                for (unsigned int i = 0; i < size; i++) {
125                  if (haystack[i] == '\\')
126                    i++;
127                  if (haystack[i] == needle[npos]) {
128                    npos++;
129                    if (npos >= nsize)
130 mike    1.10 	return ( (int)(i - nsize + 1) );
131                  } else {
132                    npos = 0;
133                  }
134                }
135                return -1;
136              }
137              
138              static void 
139              replace(String &s, unsigned int pos, unsigned int len, const String &r)
140              {
141                String s1 = s.subString(0, pos) + r + s.subString(pos  + len);
142                s = s1;
143              }
144              
145              void
146              cimmofMessages::getMessage(String &out, MsgCode code, const arglist &args)
147              {
148                String s = msgCodeToString(code);
149                out = s;
150                int pos;
151 mike    1.10   for (unsigned int i = 0; i < args.size(); i++) {
152                  int state = 0;
153                  char buf[40];
154                  sprintf(buf, "%d", i + 1);
155                  String srchstr = "%";
156                  srchstr.append(buf);
157                  if ( (pos = find(out, srchstr)) != -1 ) {
158                    replace(out, pos, srchstr.size(), args[i]);
159                  }
160                }
161              }
162              
163              PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2