0025616: Avoid Classes using "new" to allocate Instances but not defining a copy...
[occt.git] / src / LDOM / LDOM_OSStream.hxx
index f3fa75e..2648b92 100644 (file)
@@ -4,8 +4,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 //          and current element of sequence,
 //          also it has methods for the sequence management.
 
 //          and current element of sequence,
 //          also it has methods for the sequence management.
 
+#include <NCollection_DefineAlloc.hxx>
+#include <NCollection_BaseAllocator.hxx>
 #include <Standard_OStream.hxx>
 #include <Standard_Boolean.hxx>
 
 #include <stdlib.h>
 #include <stdio.h> /* EOF */
 
 #include <Standard_OStream.hxx>
 #include <Standard_Boolean.hxx>
 
 #include <stdlib.h>
 #include <stdio.h> /* EOF */
 
-class LDOM_StringElem; // defined in cxx file
-
 class LDOM_SBuffer : public streambuf
 {
 class LDOM_SBuffer : public streambuf
 {
- public:
+  // One element of sequence.
+  // Can only be allocated by the allocator and assumes
+  // it is IncAllocator, so destructor isn't required.
+  struct LDOM_StringElem
+  {
+    char*            buf;  //!< pointer on data string
+    int              len;  //!< quantity of really written data
+    LDOM_StringElem* next; //!< pointer on the next element of a sequence
+
+    DEFINE_NCOLLECTION_ALLOC
+
+    LDOM_StringElem(const int, const Handle_NCollection_BaseAllocator&);
+    ~LDOM_StringElem();
+
+  private:
+    LDOM_StringElem (const LDOM_StringElem&);
+    LDOM_StringElem& operator= (const LDOM_StringElem&);
+  };
+
+public:
   Standard_EXPORT LDOM_SBuffer (const Standard_Integer theMaxBuf);
   // Constructor. Sets a default value for the
   //              length of each sequence element.
   Standard_EXPORT LDOM_SBuffer (const Standard_Integer theMaxBuf);
   // Constructor. Sets a default value for the
   //              length of each sequence element.
@@ -54,7 +73,7 @@ class LDOM_SBuffer : public streambuf
   // Caller of this function is responsible
   // for memory release after the string usage.
 
   // Caller of this function is responsible
   // for memory release after the string usage.
 
-  Standard_Integer Length () const {return myLength;};
+  Standard_Integer Length () const {return myLength;}
   // Returns full length of data contained
 
   Standard_EXPORT void Clear ();
   // Returns full length of data contained
 
   Standard_EXPORT void Clear ();
@@ -73,11 +92,13 @@ class LDOM_SBuffer : public streambuf
   Standard_EXPORT ~LDOM_SBuffer ();
   // Destructor
 
   Standard_EXPORT ~LDOM_SBuffer ();
   // Destructor
 
- private:
+private:
+
   Standard_Integer      myMaxBuf; // default length of one element
   Standard_Integer      myLength; // full length of contained data
   LDOM_StringElem* myFirstString; // the head of the sequence
   LDOM_StringElem* myCurString;   // current element of the sequence
   Standard_Integer      myMaxBuf; // default length of one element
   Standard_Integer      myLength; // full length of contained data
   LDOM_StringElem* myFirstString; // the head of the sequence
   LDOM_StringElem* myCurString;   // current element of the sequence
+  Handle(NCollection_BaseAllocator) myAlloc; //allocator for chunks
 };
 
 class LDOM_OSStream : public Standard_OStream
 };
 
 class LDOM_OSStream : public Standard_OStream
@@ -86,11 +107,11 @@ class LDOM_OSStream : public Standard_OStream
   Standard_EXPORT LDOM_OSStream (const Standard_Integer theMaxBuf);
   // Constructor
 
   Standard_EXPORT LDOM_OSStream (const Standard_Integer theMaxBuf);
   // Constructor
 
-  Standard_CString str () const {return myBuffer.str();};
+  Standard_CString str () const {return myBuffer.str();}
 
 
-  Standard_Integer Length () const {return myBuffer.Length();};
+  Standard_Integer Length () const {return myBuffer.Length();}
 
 
-  void Clear () { myBuffer.Clear(); };
+  void Clear () { myBuffer.Clear(); }
 
  private:
   LDOM_SBuffer myBuffer;
 
  private:
   LDOM_SBuffer myBuffer;