|
||||
File indexing completed on 2025-01-18 10:04:12
0001 // Created on: 2001-10-01 0002 // Created by: Julia DOROVSKIKH 0003 // Copyright (c) 2001-2014 OPEN CASCADE SAS 0004 // 0005 // This file is part of Open CASCADE Technology software library. 0006 // 0007 // This library is free software; you can redistribute it and/or modify it under 0008 // the terms of the GNU Lesser General Public License version 2.1 as published 0009 // by the Free Software Foundation, with special exception defined in the file 0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0011 // distribution for complete text of the license and disclaimer of any warranty. 0012 // 0013 // Alternatively, this file may be used under the terms of Open CASCADE 0014 // commercial license or contractual agreement. 0015 0016 #ifndef LDOM_OSStream_HeaderFile 0017 #define LDOM_OSStream_HeaderFile 0018 0019 #include <NCollection_DefineAlloc.hxx> 0020 #include <NCollection_BaseAllocator.hxx> 0021 #include <Standard_OStream.hxx> 0022 0023 #include <stdio.h> /* EOF */ 0024 0025 //! Class LDOM_SBuffer inherits std::streambuf and 0026 //! redefines some virtual methods of it (overflow() and xsputn()). 0027 //! This class contains pointers on first and current element 0028 //! of sequence, also it has methods for the sequence management. 0029 class LDOM_SBuffer : public std::streambuf 0030 { 0031 //! One element of sequence. 0032 //! Can only be allocated by the allocator and assumes 0033 //! it is IncAllocator, so destructor isn't required. 0034 struct LDOM_StringElem 0035 { 0036 char* buf; //!< pointer on data string 0037 int len; //!< quantity of really written data 0038 LDOM_StringElem* next; //!< pointer on the next element of a sequence 0039 0040 DEFINE_NCOLLECTION_ALLOC 0041 0042 LDOM_StringElem(const int, const Handle(NCollection_BaseAllocator)&); 0043 ~LDOM_StringElem(); 0044 0045 private: 0046 LDOM_StringElem (const LDOM_StringElem&); 0047 LDOM_StringElem& operator= (const LDOM_StringElem&); 0048 }; 0049 0050 public: 0051 //! Constructor. Sets a default value for the 0052 //! length of each sequence element. 0053 Standard_EXPORT LDOM_SBuffer (const Standard_Integer theMaxBuf); 0054 0055 //! Concatenates strings of all sequence elements 0056 //! into one string. Space for output string is allocated 0057 //! with operator new. 0058 //! Caller of this function is responsible 0059 //! for memory release after the string usage. 0060 Standard_EXPORT Standard_CString str () const; 0061 0062 //! Returns full length of data contained 0063 Standard_Integer Length () const {return myLength;} 0064 0065 //! Clears first element of sequence and removes all others 0066 Standard_EXPORT void Clear (); 0067 0068 // Methods of std::streambuf 0069 0070 Standard_EXPORT virtual int overflow(int c = EOF) Standard_OVERRIDE; 0071 Standard_EXPORT virtual int underflow() Standard_OVERRIDE; 0072 //virtual int uflow(); 0073 0074 Standard_EXPORT virtual std::streamsize xsputn(const char* s, std::streamsize n) Standard_OVERRIDE; 0075 //virtual int xsgetn(char* s, int n); 0076 //virtual int sync(); 0077 0078 Standard_EXPORT ~LDOM_SBuffer (); 0079 // Destructor 0080 0081 private: 0082 0083 Standard_Integer myMaxBuf; // default length of one element 0084 Standard_Integer myLength; // full length of contained data 0085 LDOM_StringElem* myFirstString; // the head of the sequence 0086 LDOM_StringElem* myCurString; // current element of the sequence 0087 Handle(NCollection_BaseAllocator) myAlloc; //allocator for chunks 0088 }; 0089 0090 //! Subclass if std::ostream allowing to increase performance 0091 //! of outputting data into a string avoiding reallocation of buffer. 0092 //! Class LDOM_OSStream implements output into a sequence of 0093 //! strings and getting the result as a string. 0094 //! It inherits Standard_OStream (std::ostream). 0095 //! Beside methods of std::ostream, it also has additional 0096 //! useful methods: str(), Length() and Clear(). 0097 class LDOM_OSStream : public Standard_OStream 0098 { 0099 public: 0100 //! Constructor 0101 Standard_EXPORT LDOM_OSStream(const Standard_Integer theMaxBuf); 0102 0103 Standard_EXPORT virtual ~LDOM_OSStream(); 0104 0105 Standard_CString str () const {return myBuffer.str();} 0106 0107 Standard_Integer Length () const { return myBuffer.Length(); } 0108 0109 void Clear () { myBuffer.Clear(); } 0110 0111 private: 0112 LDOM_SBuffer myBuffer; 0113 0114 public: 0115 // byte order mark defined at the start of a stream 0116 enum BOMType { 0117 BOM_UNDEFINED, 0118 BOM_UTF8, 0119 BOM_UTF16BE, 0120 BOM_UTF16LE, 0121 BOM_UTF32BE, 0122 BOM_UTF32LE, 0123 BOM_UTF7, 0124 BOM_UTF1, 0125 BOM_UTFEBCDIC, 0126 BOM_SCSU, 0127 BOM_BOCU1, 0128 BOM_GB18030 0129 }; 0130 }; 0131 0132 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |