|
||||
File indexing completed on 2025-01-18 10:04:59
0001 // Created on: 1991-09-05 0002 // Created by: J.P. TIRAUlt 0003 // Copyright (c) 1991-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Standard_OutOfMemory_HeaderFile 0018 #define _Standard_OutOfMemory_HeaderFile 0019 0020 #include <Standard_Type.hxx> 0021 #include <Standard_ProgramError.hxx> 0022 0023 class Standard_OutOfMemory; 0024 DEFINE_STANDARD_HANDLE(Standard_OutOfMemory, Standard_ProgramError) 0025 0026 #if !defined No_Exception && !defined No_Standard_OutOfMemory 0027 #define Standard_OutOfMemory_Raise_if(CONDITION, MESSAGE) \ 0028 if (CONDITION) throw Standard_OutOfMemory(MESSAGE); 0029 #else 0030 #define Standard_OutOfMemory_Raise_if(CONDITION, MESSAGE) 0031 #endif 0032 0033 //! Standard_OutOfMemory exception is defined explicitly and not by 0034 //! macro DEFINE_STANDARD_EXCEPTION, to avoid necessity of dynamic 0035 //! memory allocations during throwing and stack unwinding: 0036 //! 0037 //! - method NewInstance() returns static instance (singleton) 0038 //! - method Raise() raises copy of that singleton, resetting 0039 //! its message string 0040 //! - message string is stored as field, not allocated dynamically 0041 //! (storable message length is limited by buffer size) 0042 //! 0043 //! The reason is that in out-of-memory condition any memory allocation can 0044 //! fail, thus use of operator new for allocation of new exception instance 0045 //! is dangerous (can cause recursion until stack overflow, see #24836). 0046 0047 class Standard_OutOfMemory : public Standard_ProgramError 0048 { 0049 Standard_EXPORT void Throw () const Standard_OVERRIDE; 0050 0051 public: 0052 0053 //! Constructor is kept public for backward compatibility 0054 Standard_EXPORT Standard_OutOfMemory(const Standard_CString theMessage = 0); 0055 0056 //! Returns error message 0057 Standard_EXPORT Standard_CString GetMessageString() const Standard_OVERRIDE; 0058 0059 //! Sets error message 0060 Standard_EXPORT void SetMessageString (const Standard_CString aMessage) Standard_OVERRIDE; 0061 0062 //! Raises exception with specified message string 0063 Standard_EXPORT static void Raise(const Standard_CString theMessage = ""); 0064 0065 //! Raises exception with specified message string 0066 Standard_EXPORT static void Raise(Standard_SStream& theMessage); 0067 0068 //! Returns global instance of exception 0069 Standard_EXPORT static Handle(Standard_OutOfMemory) NewInstance (Standard_CString theMessage = ""); 0070 0071 //! Returns global instance of exception 0072 Standard_EXPORT static Handle(Standard_OutOfMemory) NewInstance (Standard_CString theMessage, 0073 Standard_CString theStackTrace); 0074 0075 DEFINE_STANDARD_RTTIEXT(Standard_OutOfMemory,Standard_ProgramError) 0076 0077 protected: 0078 char myBuffer[1024]; 0079 }; 0080 0081 #endif // _Standard_OutOfMemory_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |