/*************************************************************************\ * Copyright (c) 2002 The University of Chicago, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * SPDX-License-Identifier: EPICS * EPICS Base is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ // // Author: Jeff Hill // #ifndef locationException_h #define locationException_h #include #include "cantProceed.h" #include "errlog.h" template class sourceFileLocation : public T { public: sourceFileLocation (const T &parm, const char *fileName, unsigned lineNumber); sourceFileLocation ( const sourceFileLocation & ); sourceFileLocation & operator = ( const sourceFileLocation & ); const char *fileName () const; unsigned lineNumber () const; private: const char *pFileName; unsigned lineNumberCopy; }; template inline sourceFileLocation::sourceFileLocation (const T &parm, const char *fileName, unsigned lineNumber) : T ( parm ), pFileName ( fileName ) , lineNumberCopy ( lineNumber ) {} template inline sourceFileLocation::sourceFileLocation ( const sourceFileLocation &in ) : T ( in ), pFileName ( in.pFileName ), lineNumberCopy ( in.lineNumberCopy ) { } template < class T > inline sourceFileLocation & sourceFileLocation::operator = ( const sourceFileLocation &in ) { this->pFileName = in.pFileName; this->lineNumberCopy = in.lineNumberCopy; return *this; } template < class T > inline unsigned sourceFileLocation::lineNumber () const { return this->lineNumberCopy; } template inline const char * sourceFileLocation::fileName () const { return this->pFileName; } #define throwWithLocation(parm) throwExceptionWithLocation (parm, __FILE__, __LINE__); template inline void throwExceptionWithLocation (const T &parm, const char *pFileName, unsigned lineNo) { throw sourceFileLocation (parm, pFileName, lineNo); } #endif // ifdef locationException_h