⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 base_exception.cpp

📁 270的linux说明
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*

Copyright (c) 2008, Intel Corporation. 

All rights reserved.

 

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:


    * Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation and/or 
other materials provided with the distribution.

    * Neither the name of Intel Corporation nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.

*///==============================================================================// base_Exception.cpp : Implementation of base class  IntelMobileException//==============================================================================#include "base_Exception.h"      #include <iostream>#include <fstream>using namespace Intel::Mobile::BaseAPI;//extern ExceptionMap gErrorMap;//ExceptionCollection gErrorCollection;extern int gExceptionInitlize = 0;IntelMobileString g_sPropertyFileDirectory = IntelMobileText("");IntelMobileString g_sFileName = IntelMobileText("IntelMobileErrorInfo.property");//==============================================================================// Default C-Tor()//==============================================================================/*IntelMobileException::IntelMobileException( const IntelMobileChar* pszMsg,                                  const IntelMobileChar* pszSource,                                  const IntelMobileChar* pszSite )               : m_sMessage    ( pszMsg    ),                 m_sSource     ( pszSource ),                 m_sTargetSite ( pszSite   ),				 m_sErrorCode  ( IntelMobileText("0")      ){}*///==============================================================================// Default C-Tor()//==============================================================================IntelMobileException::IntelMobileException( const IntelMobileChar* pszMsg,                                  const IntelMobileChar* pszSource,                                  const IntelMobileChar* pszSite,								  const LONG lErrorCode)               : m_sMessage    ( NULL    ),                 m_sSource     ( NULL ),                 m_sTargetSite ( NULL ),				 m_sErrorCode  ( NULL ),				 m_sErrorInfo  ( NULL ){	if ( pszMsg )    {#ifdef _UNICODE        m_sMessage = ::wcscpy( new IntelMobileChar[::wcslen(pszMsg)+1], pszMsg ); #else	m_sMessage = strcpy( new IntelMobileChar[::strlen(pszMsg)+1], pszMsg );#endif    }	else	{#ifdef _UNICODE		m_sMessage = ::wcscpy( new IntelMobileChar[1], IntelMobileText("") ); #else		m_sMessage = strcpy( new IntelMobileChar[1], IntelMobileText("") );#endif	}	if ( pszSource )    {#ifdef _UNICODE        m_sSource = ::wcscpy( new IntelMobileChar[::wcslen(pszSource)+1], pszSource ); #else	m_sSource = strcpy( new IntelMobileChar[::strlen(pszSource)+1], pszSource );#endif    }	else	{#ifdef _UNICODE		m_sSource = ::wcscpy( new IntelMobileChar[1], IntelMobileText("") ); #else		m_sSource = strcpy( new IntelMobileChar[1], IntelMobileText("") );#endif	}	if ( pszSite )    {#ifdef _UNICODE        m_sTargetSite = ::wcscpy( new IntelMobileChar[::wcslen(pszSite)+1], pszSite ); #else	m_sTargetSite = strcpy( new IntelMobileChar[::strlen(pszSite)+1], pszSite );#endif    }	else	{#ifdef _UNICODE		m_sTargetSite = ::wcscpy( new IntelMobileChar[1], IntelMobileText("") ); #else		m_sTargetSite = strcpy( new IntelMobileChar[1], IntelMobileText("") );#endif	}		m_sErrorCode = new IntelMobileChar[10];	IML2W( lErrorCode, m_sErrorCode );	Initialize();}//==============================================================================// String C-Tor()//==============================================================================IntelMobileException::IntelMobileException( const IntelMobileString& sMsg,                                  const IntelMobileString& sSource,                                  const IntelMobileString& sSite )               : m_sMessage    ( NULL    ),                 m_sSource     ( NULL ),                 m_sTargetSite ( NULL   ),				 m_sErrorInfo  ( NULL ),				 m_sErrorCode  ( IntelMobileText("0")){#ifdef _UNICODE    m_sMessage = ::wcscpy( new IntelMobileChar[::wcslen(sMsg.c_str())+1], sMsg.c_str() );     m_sSource = ::wcscpy( new IntelMobileChar[::wcslen(sSource.c_str())+1], sSource.c_str() );     m_sTargetSite = ::wcscpy( new IntelMobileChar[::wcslen(sSite.c_str())+1], sSite.c_str() ); #else	m_sMessage = strcpy( new IntelMobileChar[strlen(sMsg.c_str())+1], sMsg.c_str() );    m_sSource = strcpy( new IntelMobileChar[strlen(sSource.c_str())+1], sSource.c_str() );    m_sTargetSite = strcpy( new IntelMobileChar[strlen(sSite.c_str())+1], sSite.c_str() );#endif	Initialize();}//==============================================================================// String C-Tor()//==============================================================================IntelMobileException::IntelMobileException( const IntelMobileString& sMsg,                                  const IntelMobileString& sSource,                                  const IntelMobileString& sSite,								  const LONG lErrorCode)               : m_sMessage    ( NULL    ),                 m_sSource     ( NULL ),                 m_sTargetSite ( NULL ),				 m_sErrorCode  ( NULL ),				 m_sErrorInfo  ( NULL ){#ifdef _UNICODE	m_sMessage = ::wcscpy( new IntelMobileChar[::wcslen(sMsg.c_str())+1], sMsg.c_str() );     m_sSource = ::wcscpy( new IntelMobileChar[::wcslen(sSource.c_str())+1], sSource.c_str() );     m_sTargetSite = ::wcscpy( new IntelMobileChar[::wcslen(sSite.c_str())+1], sSite.c_str() ); #else	m_sMessage = strcpy( new IntelMobileChar[strlen(sMsg.c_str())+1], sMsg.c_str() );    m_sSource = strcpy( new IntelMobileChar[strlen(sSource.c_str())+1], sSource.c_str() );    m_sTargetSite = strcpy( new IntelMobileChar[strlen(sSite.c_str())+1], sSite.c_str() );#endif	m_sErrorCode = new IntelMobileChar[10];	IML2W( lErrorCode, m_sErrorCode );	Initialize();}//==============================================================================// Copy C-Tor()//==============================================================================IntelMobileException::IntelMobileException( const IntelMobileException& exception )               : m_sMessage    ( NULL ),                 m_sSource     ( NULL ),                 m_sTargetSite ( NULL ),				 m_sErrorCode  ( NULL ),				 m_sErrorInfo  ( NULL ){//	Initialize();	if ( exception.m_sMessage )	{#ifdef _UNICODE		m_sMessage = ::wcscpy( new IntelMobileChar[::wcslen(exception.m_sMessage)+1], exception.m_sMessage ); #else		m_sMessage = strcpy( new IntelMobileChar[strlen(exception.m_sMessage)+1], exception.m_sMessage ); #endif	}	else	{#ifdef _UNICODE		m_sMessage = ::wcscpy( new IntelMobileChar[1], IntelMobileText("")); #else		m_sMessage = strcpy( new IntelMobileChar[1], IntelMobileText("")); #endif	}		if ( exception.m_sSource )	{#ifdef _UNICODE		m_sSource = ::wcscpy( new IntelMobileChar[::wcslen(exception.m_sSource)+1], exception.m_sSource );#else		m_sSource = strcpy( new IntelMobileChar[::strlen(exception.m_sSource)+1], exception.m_sSource );#endif	}	else	{#ifdef _UNICODE		m_sSource = ::wcscpy( new IntelMobileChar[1], IntelMobileText("") ); #else		m_sSource = ::strcpy( new IntelMobileChar[1], IntelMobileText("") ); #endif	}	if ( exception.m_sTargetSite )	{#ifdef _UNICODE		m_sTargetSite = ::wcscpy( new IntelMobileChar[::wcslen(exception.m_sTargetSite)+1], exception.m_sTargetSite ); #else		m_sTargetSite = strcpy( new IntelMobileChar[strlen(exception.m_sTargetSite)+1], exception.m_sTargetSite ); #endif	}	else	{#ifdef _UNICODE		m_sTargetSite = ::wcscpy( new IntelMobileChar[1], IntelMobileText("") );#else		m_sTargetSite = strcpy( new IntelMobileChar[1], IntelMobileText("") );#endif	}	if ( exception.m_sErrorCode )	{#ifdef _UNICODE		m_sErrorCode = ::wcscpy( new IntelMobileChar[::wcslen(exception.m_sErrorCode)+1], exception.m_sErrorCode ); #else		m_sErrorCode = strcpy( new IntelMobileChar[strlen(exception.m_sErrorCode)+1], exception.m_sErrorCode ); #endif	}	else	{#ifdef _UNICODE		m_sErrorCode = ::wcscpy( new IntelMobileChar[1], IntelMobileText("") );#else		m_sErrorCode = strcpy( new IntelMobileChar[1], IntelMobileText("") );#endif	}	if ( exception.m_sErrorInfo )	{#ifdef _UNICODE		m_sErrorInfo = ::wcscpy( new IntelMobileChar[::wcslen(exception.m_sErrorInfo)+1], exception.m_sErrorInfo ); #else		m_sErrorInfo = strcpy( new IntelMobileChar[strlen(exception.m_sErrorInfo)+1], exception.m_sErrorInfo ); #endif	}	else	{#ifdef _UNICODE		m_sErrorInfo = ::wcscpy( new IntelMobileChar[1], IntelMobileText("") );#else		m_sErrorInfo = strcpy( new IntelMobileChar[1], IntelMobileText("") );#endif	}}//==============================================================================// D-Tor()//==============================================================================IntelMobileException::~IntelMobileException(){	if ( m_sMessage )		delete[] m_sMessage;	if ( m_sSource )		delete[] m_sSource;	if ( m_sTargetSite )		delete[] m_sTargetSite;	if ( m_sErrorCode )		delete[] m_sErrorCode;	if ( m_sErrorInfo )		delete[] m_sErrorInfo;}//==============================================================================// Initialize()//==============================================================================void IntelMobileException::Initialize(){	const IntelMobileChar* errorInfo = IntelMobileException::GetDetailErrorInfo( m_sErrorCode );	if ( m_sErrorInfo )		delete[] m_sErrorInfo;#ifdef _UNICODE    m_sErrorInfo = new IntelMobileChar[::wcslen(errorInfo)+1];#else    m_sErrorInfo = new IntelMobileChar[::strlen(errorInfo)+1];#endif    if ( m_sErrorInfo )    {#ifdef _UNICODE        ::wcscpy( m_sErrorInfo, errorInfo ); #else        strcpy( m_sErrorInfo, errorInfo ); #endif    }//	m_sErrorInfo = IntelMobileException::GetDetailErrorInfo( m_sErrorCode.c_str() ) ;}//==============================================================================// GetErrorInfo()//==============================================================================const IntelMobileChar* IntelMobileException::GetDetailErrorInfo() const{//	return const_cast<IntelMobileChar *>(m_sErrorInfo.c_str());//	return m_sErrorInfo.c_str();	return m_sErrorInfo;}//==============================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -