|
|
|||
File indexing completed on 2026-11-11 10:39:30
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_ProgramError.hxx> 0021 0022 #include <memory> 0023 0024 #if !defined No_Exception && !defined No_Standard_OutOfMemory 0025 #define Standard_OutOfMemory_Raise_if(CONDITION, MESSAGE) \ 0026 if (CONDITION) \ 0027 throw Standard_OutOfMemory(MESSAGE); 0028 #else 0029 #define Standard_OutOfMemory_Raise_if(CONDITION, MESSAGE) 0030 #endif 0031 0032 //! Standard_OutOfMemory exception is defined explicitly and not by 0033 //! macro DEFINE_STANDARD_EXCEPTION, to avoid necessity of dynamic 0034 //! memory allocations during throwing and stack unwinding: 0035 //! 0036 //! - message string is stored as field, not allocated dynamically 0037 //! (storable message length is limited by buffer size) 0038 //! 0039 //! The reason is that in out-of-memory condition any memory allocation can 0040 //! fail, thus use of operator new for allocation of new exception instance 0041 //! is dangerous (can cause recursion until stack overflow, see #24836). 0042 class Standard_OutOfMemory : public Standard_ProgramError 0043 { 0044 public: 0045 //! Constructor is kept public for backward compatibility. 0046 //! @param theMessage optional error message 0047 Standard_EXPORT Standard_OutOfMemory(const char* const theMessage = nullptr); 0048 0049 //! Returns error message (implements std::exception interface). 0050 Standard_EXPORT const char* what() const noexcept override; 0051 0052 //! Returns the exception type name. 0053 const char* ExceptionType() const noexcept override { return "Standard_OutOfMemory"; } 0054 0055 //! Sets error message. 0056 //! @param theMessage error message (can be nullptr) 0057 Standard_EXPORT void SetMessageString(const char* const theMessage); 0058 0059 private: 0060 char myBuffer[1024]; 0061 }; 0062 0063 #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 |
|