|
||||
File indexing completed on 2025-01-18 10:04:58
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 allocated memory block. 0028 //! Implements minimal sub-set of methods for passing buffer to std::istream, including seek support. 0029 //! 0030 //! This class can be used for creating a seekable input stream in cases, 0031 //! when the source data does not satisfies Reader requirements (non-seekable stream, compressed data) 0032 //! or represents an in-memory resource. 0033 //! 0034 //! The memory itself is NOT managed by this class - it is up to the caller to ensure that passed memory pointer 0035 //! is not released during Standard_ArrayStreamBuffer lifetime. 0036 //! 0037 //! Usage example: 0038 //! @code 0039 //! const char* theBuffer; 0040 //! const size_t theBufferLength; 0041 //! Standard_ArrayStreamBuffer aStreamBuffer (theBuffer, theBufferLength); 0042 //! std::istream aStream (&aStreamBuffer); 0043 //! TopoDS_Shape aShape; 0044 //! BRep_Builder aBuilder; 0045 //! BRepTools::Read (aShape, aStream, aBuilder); 0046 //! @endcode 0047 class Standard_ArrayStreamBuffer : public std::streambuf 0048 { 0049 public: 0050 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, 0056 const size_t theSize); 0057 0058 //! Destructor. 0059 Standard_EXPORT virtual ~Standard_ArrayStreamBuffer(); 0060 0061 //! (Re)-initialize the stream. 0062 //! Passed pointer is stored as is (memory is NOT copied nor released with destructor). 0063 //! @param theBegin pointer to the beginning of pre-allocated buffer 0064 //! @param theSize length of pre-allocated buffer 0065 Standard_EXPORT virtual void Init (const char* theBegin, 0066 const size_t theSize); 0067 0068 protected: 0069 0070 //! Get character on underflow. 0071 //! Virtual function called by other member functions to get the current character 0072 //! in the controlled input sequence without changing the current position. 0073 Standard_EXPORT virtual int_type underflow() Standard_OVERRIDE; 0074 0075 //! Get character on underflow and advance position. 0076 //! Virtual function called by other member functions to get the current character 0077 //! in the controlled input sequence and then advance the position indicator to the next character. 0078 Standard_EXPORT virtual int_type uflow() Standard_OVERRIDE; 0079 0080 //! Put character back in the case of backup underflow. 0081 //! Virtual function called by other member functions to put a character back 0082 //! into the controlled input sequence and decrease the position indicator. 0083 Standard_EXPORT virtual int_type pbackfail (int_type ch) Standard_OVERRIDE; 0084 0085 //! Get number of characters available. 0086 //! Virtual function (to be read s-how-many-c) called by other member functions 0087 //! to get an estimate on the number of characters available in the associated input sequence. 0088 Standard_EXPORT virtual std::streamsize showmanyc() Standard_OVERRIDE; 0089 0090 //! Seek to specified position. 0091 Standard_EXPORT virtual pos_type seekoff (off_type theOff, 0092 std::ios_base::seekdir theWay, 0093 std::ios_base::openmode theWhich) Standard_OVERRIDE; 0094 0095 //! Change to specified position, according to mode. 0096 Standard_EXPORT virtual pos_type seekpos (pos_type thePosition, 0097 std::ios_base::openmode theWhich) Standard_OVERRIDE; 0098 0099 public: 0100 0101 //! Read a bunch of bytes at once. 0102 Standard_EXPORT virtual std::streamsize xsgetn (char* thePtr, 0103 std::streamsize theCount) Standard_OVERRIDE; 0104 0105 private: 0106 0107 // copying is not allowed 0108 Standard_ArrayStreamBuffer (const Standard_ArrayStreamBuffer& ); 0109 Standard_ArrayStreamBuffer& operator= (const Standard_ArrayStreamBuffer& ); 0110 0111 protected: 0112 0113 const char* myBegin; 0114 const char* myEnd; 0115 const char* myCurrent; 0116 0117 }; 0118 0119 #ifdef _MSC_VER 0120 #pragma warning(pop) 0121 #endif 0122 0123 #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 |