Added headers
[tpot/pegasus/.git] / src / Pegasus / Common / Exception.cpp
index 627e967f67250bc69d5f16c0b4096a513e707300..2752154bb11a0e7a81303b2e3b34ce02e3b5067b 100644 (file)
-//%/////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-//
-//==============================================================================
-//
-// Author: Mike Brasher (mbrasher@bmc.com)
-//
-// Modified By:
-//
-//%/////////////////////////////////////////////////////////////////////////////
-
-#include <cstdio>
-#include "Exception.h"
-
-PEGASUS_NAMESPACE_BEGIN
-
-Exception::Exception(const String& message) : _message(message) 
-{ 
-
-}
-
-Exception::Exception(const char* message) : _message(message) 
-{
-
-}
-
-Exception::~Exception()
-{
-
-}
-
-AssertionFailureException::AssertionFailureException(
-    const char* file, 
-    size_t line,
-    const String& message) : Exception(String())
-{
-    char lineStr[32];
-    sprintf(lineStr, "%d", line);
-
-    _message = file;
-    _message.append("(");
-    _message.append(lineStr);
-    _message.append("): ");
-    _message.append(message);
-}
-
-const char OutOfBounds::MSG[] = "out of bounds";
-
-const char AlreadyExists::MSG[] = "already exists: ";
-
-const char NullPointer::MSG[] = "null pointer";
-
-const char UnitializedHandle::MSG[] = "unitialized handle";
-
-const char IllegalName::MSG[] = "illegal CIM name";
-
-const char InvalidPropertyOverride::MSG[] = "invalid property override: ";
-
-const char InvalidMethodOverride::MSG[] = "invalid method override: ";
-
-const char UndeclaredQualifier::MSG[] = "undeclared qualifier: ";
-
-const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: ";
-
-const char BadQualifierOverride::MSG[] = "qualifier not overridable: ";
-
-const char BadQualifierType::MSG[] = 
-    "CIMType of qualifier different than its declaration: ";
-
-const char NullType::MSG[] = "type is null";
-
-const char AddedReferenceToClass::MSG[] = 
-    "attempted to add reference to a non-association class: ";
-
-const char ClassAlreadyResolved::MSG[] = 
-    "attempt to resolve a class that is already resolved: ";
-
-const char ClassNotResolved::MSG[] = 
-    "class is not yet resolved: ";
-
-const char InstanceAlreadyResolved::MSG[] = 
-    "attempted to resolve a instance that is already resolved";
-
-const char InstantiatedAbstractClass::MSG[] = 
-    "attempted to instantiated an abstract class";
-
-const char NoSuchProperty::MSG[] = "no such property: ";
-
-const char TruncatedCharacter::MSG[] = 
-    "truncated character during conversion from Char16 to char";
-
-const char ExpectedReferenceValue::MSG[] = 
-    "Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY "
-    "in this context";
-
-const char MissingReferenceClassName::MSG[] = "missing reference class name";
-
-const char IllegalTypeTag::MSG[] = "illegal type tag";
-
-const char TypeMismatch::MSG[] = "type mismatch";
-
-const char NoSuchFile::MSG[] = "no such file: ";
-
-const char CannotBindToAddress::MSG[] = "cannot bind to address: ";
-
-const char NoSuchDirectory::MSG[] = "no such directory: ";
-
-const char ChangeDirectoryFailed::MSG[] = "cannot change directory: ";
-
-const char CannotCreateDirectory::MSG[] = "cannot create directory: ";
-
-const char NoSuchNameSpace::MSG[] = "no such namespace: ";
-
-const char CannotOpenFile::MSG[] = "cannot open file: ";
-
-const char NotImplemented::MSG[] = "not implemented: ";
-
-const char CannotRemoveDirectory::MSG[] = "cannot remove directory: ";
-
-const char CannotRemoveFile::MSG[] = "cannot remove file: ";
-
-const char CannotRenameFile::MSG[] = "cannot rename file: ";
-
-const char StackUnderflow::MSG[] = "stack overflow";
-
-const char BadFormat::MSG[] = "bad format passed to Formatter::format()";
-
-const char BadDateTimeFormat::MSG[] = "bad datetime format";
-
-const char IncompatibleTypes::MSG[] = "incompatible types";
-
-const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";
-
-const char IllformedObjectName::MSG[] = "illformed object name: ";
-
-const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";
-
-const char DynamicLookupFailed::MSG[] = 
-    "lookup of symbol in dynamic library failed: ";
-
-const char CannotOpenDirectory::MSG[] = "cannot open directory: ";
-
-const char CorruptFile::MSG[] = "corrupt file: ";
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// CIMException
-//
-////////////////////////////////////////////////////////////////////////////////
-
-static const char* _cimMessages[] =
-{
-    "SUCCESS: successful",
-
-    "FAILED: A general error occurred that is not covered by a more specific "
-    "error code",
-
-    "ACCESS_DENIED: Access to a CIM resource was not available to the client",
-
-    "INVALID_NAMESPACE: The target namespace does not exist",
-
-    "INVALID_PARAMETER: One or more parameter values passed to the method "
-    "were invalid",
-
-    "INVALID_CLASS: The specified class does not exist",
-
-    "NOT_FOUND: The requested object could not be found",
-
-    "NOT_SUPPORTED: The requested operation is not supported",
-
-    "CLASS_HAS_CHILDREN: Operation cannot be carried out on this class since "
-    "it has subclasses",
-
-    "CLASS_HAS_INSTANCES: Operation cannot be carried out on this class since "
-    "it has instances",
-
-    "INVALID_SUPERCLASS: Operation cannot be carried out since the specified "
-    "superclass does not exist",
-
-    "ALREADY_EXISTS: Operation cannot be carried out because an object already "
-    "exists",
-
-    "NO_SUCH_PROPERTY: The specified property does not exist",
-
-    "TYPE_MISMATCH: The value supplied is incompatible with the type",
-
-    "QUERY_LANGUAGE_NOT_SUPPORTED: The query language is not recognized or "
-    "supported",
-
-    "INVALID_QUERY: The query is not valid for the specified query language",
-
-    "METHOD_NOT_AVAILABLE: The extrinsic method could not be executed",
-
-    "METHOD_NOT_FOUND: The specified extrinsic method does not exist"
-};
-
-static String _makeCIMExceptionMessage(
-    CIMException::Code code, 
-    const char* file,
-    Uint32 line,
-    const String& extraMessage)
-{
-    String tmp = file;
-    tmp.append("(");
-    char buffer[32];
-    sprintf(buffer, "%d", line);
-    tmp.append(buffer);
-    tmp.append("): ");
-
-    tmp.append(_cimMessages[Uint32(code)]);
-    tmp.append(": \"");
-    tmp.append(extraMessage);
-    tmp.append("\"");
-    return tmp;
-}
-
-CIMException::CIMException(
-    CIMException::Code code, 
-    const char* file,
-    Uint32 line,
-    const String& extraMessage)
-    : Exception(_makeCIMExceptionMessage(code, file, line, extraMessage)),
-    _code(code)
-{
-
-}
-
-const char* CIMException::codeToString(CIMException::Code code)
-{
-    return _cimMessages[Uint32(code)];
-}
-
-void ThrowUnitializedHandle()
-{
-    throw UnitializedHandle();
-}
-
-PEGASUS_NAMESPACE_END
+//%/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining a copy\r
+// of this software and associated documentation files (the "Software"), to \r
+// deal in the Software without restriction, including without limitation the \r
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or \r
+// sell copies of the Software, and to permit persons to whom the Software is\r
+// furnished to do so, subject to the following conditions:\r
+// \r
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN \r
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED\r
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT\r
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR \r
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT \r
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN \r
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+//==============================================================================\r
+//\r
+// Author: Mike Brasher (mbrasher@bmc.com)\r
+//\r
+// Modified By:\r
+//\r
+//%/////////////////////////////////////////////////////////////////////////////\r
+\r
+#include <cstdio>\r
+#include "Exception.h"\r
+\r
+PEGASUS_NAMESPACE_BEGIN\r
+\r
+Exception::Exception(const String& message) : _message(message) \r
+{ \r
+\r
+}\r
+\r
+Exception::Exception(const char* message) : _message(message) \r
+{\r
+\r
+}\r
+\r
+Exception::~Exception()\r
+{\r
+\r
+}\r
+\r
+AssertionFailureException::AssertionFailureException(\r
+    const char* file, \r
+    size_t line,\r
+    const String& message) : Exception(String())\r
+{\r
+    char lineStr[32];\r
+    sprintf(lineStr, "%d", line);\r
+\r
+    _message = file;\r
+    _message.append("(");\r
+    _message.append(lineStr);\r
+    _message.append("): ");\r
+    _message.append(message);\r
+}\r
+\r
+const char OutOfBounds::MSG[] = "out of bounds";\r
+\r
+const char AlreadyExists::MSG[] = "already exists: ";\r
+\r
+const char NullPointer::MSG[] = "null pointer";\r
+\r
+const char UnitializedHandle::MSG[] = "unitialized handle";\r
+\r
+const char IllegalName::MSG[] = "illegal CIM name";\r
+\r
+const char InvalidPropertyOverride::MSG[] = "invalid property override: ";\r
+\r
+const char InvalidMethodOverride::MSG[] = "invalid method override: ";\r
+\r
+const char UndeclaredQualifier::MSG[] = "undeclared qualifier: ";\r
+\r
+const char BadQualifierScope::MSG[] = "qualifier invalid in this scope: ";\r
+\r
+const char BadQualifierOverride::MSG[] = "qualifier not overridable: ";\r
+\r
+const char BadQualifierType::MSG[] = \r
+    "CIMType of qualifier different than its declaration: ";\r
+\r
+const char NullType::MSG[] = "type is null";\r
+\r
+const char AddedReferenceToClass::MSG[] = \r
+    "attempted to add reference to a non-association class: ";\r
+\r
+const char ClassAlreadyResolved::MSG[] = \r
+    "attempt to resolve a class that is already resolved: ";\r
+\r
+const char ClassNotResolved::MSG[] = \r
+    "class is not yet resolved: ";\r
+\r
+const char InstanceAlreadyResolved::MSG[] = \r
+    "attempted to resolve a instance that is already resolved";\r
+\r
+const char InstantiatedAbstractClass::MSG[] = \r
+    "attempted to instantiated an abstract class";\r
+\r
+const char NoSuchProperty::MSG[] = "no such property: ";\r
+\r
+const char TruncatedCharacter::MSG[] = \r
+    "truncated character during conversion from Char16 to char";\r
+\r
+const char ExpectedReferenceValue::MSG[] = \r
+    "Expected CIMValue object to be CIMType::REFERENCE or CIMType::REFERENCE_ARRAY "\r
+    "in this context";\r
+\r
+const char MissingReferenceClassName::MSG[] = "missing reference class name";\r
+\r
+const char IllegalTypeTag::MSG[] = "illegal type tag";\r
+\r
+const char TypeMismatch::MSG[] = "type mismatch";\r
+\r
+const char NoSuchFile::MSG[] = "no such file: ";\r
+\r
+const char CannotBindToAddress::MSG[] = "cannot bind to address: ";\r
+\r
+const char NoSuchDirectory::MSG[] = "no such directory: ";\r
+\r
+const char ChangeDirectoryFailed::MSG[] = "cannot change directory: ";\r
+\r
+const char CannotCreateDirectory::MSG[] = "cannot create directory: ";\r
+\r
+const char NoSuchNameSpace::MSG[] = "no such namespace: ";\r
+\r
+const char CannotOpenFile::MSG[] = "cannot open file: ";\r
+\r
+const char NotImplemented::MSG[] = "not implemented: ";\r
+\r
+const char CannotRemoveDirectory::MSG[] = "cannot remove directory: ";\r
+\r
+const char CannotRemoveFile::MSG[] = "cannot remove file: ";\r
+\r
+const char CannotRenameFile::MSG[] = "cannot rename file: ";\r
+\r
+const char StackUnderflow::MSG[] = "stack overflow";\r
+\r
+const char BadFormat::MSG[] = "bad format passed to Formatter::format()";\r
+\r
+const char BadDateTimeFormat::MSG[] = "bad datetime format";\r
+\r
+const char IncompatibleTypes::MSG[] = "incompatible types";\r
+\r
+const char BadlyFormedCGIQueryString::MSG[] = "badly formed CGI query string";\r
+\r
+const char IllformedObjectName::MSG[] = "illformed object name: ";\r
+\r
+const char DynamicLoadFailed::MSG[] = "load of dynamic library failed: ";\r
+\r
+const char DynamicLookupFailed::MSG[] = \r
+    "lookup of symbol in dynamic library failed: ";\r
+\r
+const char CannotOpenDirectory::MSG[] = "cannot open directory: ";\r
+\r
+const char CorruptFile::MSG[] = "corrupt file: ";\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// CIMException\r
+//\r
+////////////////////////////////////////////////////////////////////////////////\r
+\r
+static const char* _cimMessages[] =\r
+{\r
+    "SUCCESS: successful",\r
+\r
+    "FAILED: A general error occurred that is not covered by a more specific "\r
+    "error code",\r
+\r
+    "ACCESS_DENIED: Access to a CIM resource was not available to the client",\r
+\r
+    "INVALID_NAMESPACE: The target namespace does not exist",\r
+\r
+    "INVALID_PARAMETER: One or more parameter values passed to the method "\r
+    "were invalid",\r
+\r
+    "INVALID_CLASS: The specified class does not exist",\r
+\r
+    "NOT_FOUND: The requested object could not be found",\r
+\r
+    "NOT_SUPPORTED: The requested operation is not supported",\r
+\r
+    "CLASS_HAS_CHILDREN: Operation cannot be carried out on this class since "\r
+    "it has subclasses",\r
+\r
+    "CLASS_HAS_INSTANCES: Operation cannot be carried out on this class since "\r
+    "it has instances",\r
+\r
+    "INVALID_SUPERCLASS: Operation cannot be carried out since the specified "\r
+    "superclass does not exist",\r
+\r
+    "ALREADY_EXISTS: Operation cannot be carried out because an object already "\r
+    "exists",\r
+\r
+    "NO_SUCH_PROPERTY: The specified property does not exist",\r
+\r
+    "TYPE_MISMATCH: The value supplied is incompatible with the type",\r
+\r
+    "QUERY_LANGUAGE_NOT_SUPPORTED: The query language is not recognized or "\r
+    "supported",\r
+\r
+    "INVALID_QUERY: The query is not valid for the specified query language",\r
+\r
+    "METHOD_NOT_AVAILABLE: The extrinsic method could not be executed",\r
+\r
+    "METHOD_NOT_FOUND: The specified extrinsic method does not exist"\r
+};\r
+\r
+static String _makeCIMExceptionMessage(\r
+    CIMException::Code code, \r
+    const char* file,\r
+    Uint32 line,\r
+    const String& extraMessage)\r
+{\r
+    String tmp = file;\r
+    tmp.append("(");\r
+    char buffer[32];\r
+    sprintf(buffer, "%d", line);\r
+    tmp.append(buffer);\r
+    tmp.append("): ");\r
+\r
+    tmp.append(_cimMessages[Uint32(code)]);\r
+    tmp.append(": \"");\r
+    tmp.append(extraMessage);\r
+    tmp.append("\"");\r
+    return tmp;\r
+}\r
+\r
+CIMException::CIMException(\r
+    CIMException::Code code, \r
+    const char* file,\r
+    Uint32 line,\r
+    const String& extraMessage)\r
+    : Exception(_makeCIMExceptionMessage(code, file, line, extraMessage)),\r
+    _code(code)\r
+{\r
+\r
+}\r
+\r
+const char* CIMException::codeToString(CIMException::Code code)\r
+{\r
+    return _cimMessages[Uint32(code)];\r
+}\r
+\r
+void ThrowUnitializedHandle()\r
+{\r
+    throw UnitializedHandle();\r
+}\r
+\r
+PEGASUS_NAMESPACE_END\r