|
|
|||
File indexing completed on 2026-06-22 08:30:41
0001 // Copyright (c) 2016 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _Standard_ArrayStreamBuffer_HeaderFile 0015 #define _Standard_ArrayStreamBuffer_HeaderFile 0016 0017 #include <Standard_Type.hxx> 0018 0019 #include <fstream> 0020 0021 // Suppress VC9 warning on xsputn() function 0022 #ifdef _MSC_VER 0023 #pragma warning(push) 0024 #pragma warning(disable : 4996) 0025 #endif 0026 0027 //! Custom buffer object implementing STL interface std::streambuf for streamed reading from 0028 //! allocated memory block. Implements minimal sub-set of methods for passing buffer to 0029 //! std::istream, including seek support. 0030 //! 0031 //! This class can be used for creating a seekable input stream in cases, 0032 //! when the source data does not satisfies Reader requirements (non-seekable stream, compressed 0033 //! data) or represents an in-memory resource. 0034 //! 0035 //! The memory itself is NOT managed by this class - it is up to the caller to ensure that passed 0036 //! memory pointer is not released during Standard_ArrayStreamBuffer lifetime. 0037 //! 0038 //! Usage example: 0039 //! @code 0040 //! const char* theBuffer; 0041 //! const size_t theBufferLength; 0042 //! Standard_ArrayStreamBuffer aStreamBuffer (theBuffer, theBufferLength); 0043 //! std::istream aStream (&aStreamBuffer); 0044 //! TopoDS_Shape aShape; 0045 //! BRep_Builder aBuilder; 0046 //! BRepTools::Read (aShape, aStream, aBuilder); 0047 //! @endcode 0048 class Standard_ArrayStreamBuffer : public std::streambuf 0049 { 0050 public: 0051 //! Main constructor. 0052 //! Passed pointer is stored as is (memory is NOT copied nor released with destructor). 0053 //! @param theBegin pointer to the beginning of pre-allocated buffer 0054 //! @param theSize length of pre-allocated buffer 0055 Standard_EXPORT Standard_ArrayStreamBuffer(const char* theBegin, const size_t theSize); 0056 0057 //! Destructor. 0058 Standard_EXPORT virtual ~Standard_ArrayStreamBuffer(); 0059 0060 //! (Re)-initialize the stream. 0061 //! Passed pointer is stored as is (memory is NOT copied nor released with destructor). 0062 //! @param theBegin pointer to the beginning of pre-allocated buffer 0063 //! @param theSize length of pre-allocated buffer 0064 Standard_EXPORT virtual void Init(const char* theBegin, const size_t theSize); 0065 0066 protected: 0067 //! Get character on underflow. 0068 //! Virtual function called by other member functions to get the current character 0069 //! in the controlled input sequence without changing the current position. 0070 Standard_EXPORT virtual int_type underflow() Standard_OVERRIDE; 0071 0072 //! Get character on underflow and advance position. 0073 //! Virtual function called by other member functions to get the current character 0074 //! in the controlled input sequence and then advance the position indicator to the next 0075 //! character. 0076 Standard_EXPORT virtual int_type uflow() Standard_OVERRIDE; 0077 0078 //! Put character back in the case of backup underflow. 0079 //! Virtual function called by other member functions to put a character back 0080 //! into the controlled input sequence and decrease the position indicator. 0081 Standard_EXPORT virtual int_type pbackfail(int_type ch) Standard_OVERRIDE; 0082 0083 //! Get number of characters available. 0084 //! Virtual function (to be read s-how-many-c) called by other member functions 0085 //! to get an estimate on the number of characters available in the associated input sequence. 0086 Standard_EXPORT virtual std::streamsize showmanyc() Standard_OVERRIDE; 0087 0088 //! Seek to specified position. 0089 Standard_EXPORT virtual pos_type seekoff(off_type theOff, 0090 std::ios_base::seekdir theWay, 0091 std::ios_base::openmode theWhich) Standard_OVERRIDE; 0092 0093 //! Change to specified position, according to mode. 0094 Standard_EXPORT virtual pos_type seekpos(pos_type thePosition, 0095 std::ios_base::openmode theWhich) Standard_OVERRIDE; 0096 0097 public: 0098 //! Read a bunch of bytes at once. 0099 Standard_EXPORT virtual std::streamsize xsgetn(char* thePtr, 0100 std::streamsize theCount) Standard_OVERRIDE; 0101 0102 private: 0103 // copying is not allowed 0104 Standard_ArrayStreamBuffer(const Standard_ArrayStreamBuffer&); 0105 Standard_ArrayStreamBuffer& operator=(const Standard_ArrayStreamBuffer&); 0106 0107 protected: 0108 const char* myBegin; 0109 const char* myEnd; 0110 const char* myCurrent; 0111 }; 0112 0113 #ifdef _MSC_VER 0114 #pragma warning(pop) 0115 #endif 0116 0117 #endif // _Standard_ArrayStreamBuffer_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|