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

  1 martin 1.21 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.22 //
  3 martin 1.21 // 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.22 //
 10 martin 1.21 // 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.22 //
 17 martin 1.21 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.22 //
 20 martin 1.21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.22 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.21 // 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.22 //
 28 martin 1.21 //////////////////////////////////////////////////////////////////////////
 29 mike   1.1  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32 kumpf  1.16 #include <Pegasus/Common/MessageLoader.h>
 33 mike   1.1  #include "CIMStatusCode.h"
 34             
 35             PEGASUS_NAMESPACE_BEGIN
 36             
 37             static const char* _cimMessages[] =
 38             {
 39 kumpf  1.19     "CIM_ERR_SUCCESS",
 40                 "CIM_ERR_FAILED",
 41                 "CIM_ERR_ACCESS_DENIED",
 42                 "CIM_ERR_INVALID_NAMESPACE",
 43                 "CIM_ERR_INVALID_PARAMETER",
 44                 "CIM_ERR_INVALID_CLASS",
 45                 "CIM_ERR_NOT_FOUND",
 46                 "CIM_ERR_NOT_SUPPORTED",
 47                 "CIM_ERR_CLASS_HAS_CHILDREN",
 48                 "CIM_ERR_CLASS_HAS_INSTANCES",
 49                 "CIM_ERR_INVALID_SUPERCLASS",
 50                 "CIM_ERR_ALREADY_EXISTS",
 51                 "CIM_ERR_NO_SUCH_PROPERTY",
 52                 "CIM_ERR_TYPE_MISMATCH",
 53                 "CIM_ERR_QUERY_LANGUAGE_NOT_SUPPORTED",
 54                 "CIM_ERR_INVALID_QUERY",
 55                 "CIM_ERR_METHOD_NOT_AVAILABLE",
 56                 "CIM_ERR_METHOD_NOT_FOUND"
 57 chuck  1.6  };
 58             
 59 kumpf  1.10 // l10n TODO - the first func should go away when all Pegasus is globalized
 60 chuck  1.5  
 61 kumpf  1.4  const char* cimStatusCodeToString(CIMStatusCode code)
 62 mike   1.1  {
 63 kumpf  1.19     if (Uint32(code) < (sizeof(_cimMessages)/sizeof(_cimMessages[0])))
 64                 {
 65 kumpf  1.17         return _cimMessages[Uint32(code)];
 66 kumpf  1.19     }
 67 mike   1.1  
 68 kumpf  1.2      return "Unrecognized CIM status code";
 69 chuck  1.5  }
 70             
 71             
 72 kumpf  1.17 String cimStatusCodeToString(
 73                 CIMStatusCode code,
 74                 const ContentLanguageList& contentLanguages)
 75 chuck  1.5  {
 76 kumpf  1.19     if (Uint32(code) < (sizeof(_cimMessages)/sizeof(_cimMessages[0])))
 77 kumpf  1.10     {
 78 kumpf  1.19         return _cimMessages[Uint32(code)];
 79 kumpf  1.10     }
 80 kumpf  1.19 
 81                 MessageLoaderParms parms(
 82                     "Common.CIMStatusCode.UNRECOGNIZED_STATUS_CODE",
 83 kumpf  1.20         "Unrecognized CIM status code \"$0\"", (Uint32)code);
 84 kumpf  1.10 
 85                 if (contentLanguages.size() > 0)
 86                 {
 87 kumpf  1.14         //build AcceptLanguageList from contentLanguages, use in getMessage
 88 kumpf  1.13         parms.acceptlanguages.clear();
 89                     parms.acceptlanguages.insert(contentLanguages.getLanguageTag(0), 1.0);
 90 kumpf  1.10     }
 91 chuck  1.9  
 92                 return MessageLoader::getMessage(parms);
 93 chuck  1.5  }
 94             
 95 kumpf  1.14 ContentLanguageList cimStatusCodeToString_Thread(
 96                 String & message,
 97                 CIMStatusCode code)
 98 chuck  1.5  {
 99 kumpf  1.19     if (Uint32(code) < (sizeof(_cimMessages)/sizeof(_cimMessages[0])))
100 kumpf  1.10     {
101 kumpf  1.19         message = _cimMessages[Uint32(code)];
102                     return ContentLanguageList();
103 kumpf  1.10     }
104 kumpf  1.19 
105                 MessageLoaderParms parms(
106                     "Common.CIMStatusCode.UNRECOGNIZED_STATUS_CODE",
107 kumpf  1.20         "Unrecognized CIM status code \"$0\"", (Uint32)code);
108 kumpf  1.10 
109                 //parms.useThreadLocale = true;
110                 message = MessageLoader::getMessage(parms);
111                 return parms.contentlanguages;
112 mike   1.1  }
113             
114             PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2