1 // Created on: 1993-04-15
2 // Created by: Christian CAILLET
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Interface_LineBuffer_HeaderFile
18 #define _Interface_LineBuffer_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <TCollection_AsciiString.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Character.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <Standard_CString.hxx>
29 class Standard_OutOfRange;
30 class TCollection_AsciiString;
31 class TCollection_HAsciiString;
34 //! Simple Management of a Line Buffer, to be used by Interface
36 //! While a String is suitable to do that, this class ensures an
37 //! optimised Memory Management, because this is a hard point of
39 class Interface_LineBuffer
46 //! Creates a LineBuffer with an absolute maximum size
47 //! (Default value is only to satisfy compiler requirement)
48 Standard_EXPORT Interface_LineBuffer(const Standard_Integer size = 10);
50 //! Changes Maximum allowed size of Buffer.
51 //! If <max> is Zero, Maximum size is set to the initial size.
52 Standard_EXPORT void SetMax (const Standard_Integer max);
54 //! Sets an Initial reservation for Blank characters
55 //! (this reservation is counted in the size of the current Line)
56 Standard_EXPORT void SetInitial (const Standard_Integer initial);
58 //! Sets a Keep Status at current Length. It means that at next
59 //! Move, the new line will begin by characters between Keep + 1
60 //! and current Length
61 Standard_EXPORT void SetKeep();
63 //! Returns True if there is room enough to add <more> characters
64 //! Else, it is required to Dump the Buffer before refilling it
65 //! <more> is recorded to manage SetKeep status
66 Standard_EXPORT Standard_Boolean CanGet (const Standard_Integer more);
68 //! Returns the Content of the LineBuffer
69 //! was C++ : return const
70 Standard_EXPORT Standard_CString Content() const;
72 //! Returns the Length of the LineBuffer
73 Standard_EXPORT Standard_Integer Length() const;
75 //! Clears completely the LineBuffer
76 Standard_EXPORT void Clear();
78 //! Inhibits effect of SetInitial until the next Move (i.e. Keep)
79 //! Then Prepare will not insert initial blanks, but further ones
80 //! will. This allows to cancel initial blanks on an internal Split
81 //! A call to SetInitial has no effect on this until Move
82 Standard_EXPORT void FreezeInitial();
84 //! Fills a AsciiString <str> with the Content of the Line Buffer,
85 //! then Clears the LineBuffer
86 Standard_EXPORT void Move (TCollection_AsciiString& str);
88 //! Same as above, but <str> is known through a Handle
89 Standard_EXPORT void Move (const Handle(TCollection_HAsciiString)& str);
91 //! Same as above, but generates the HAsciiString
92 Standard_EXPORT Handle(TCollection_HAsciiString) Moved();
94 //! Adds a text as a CString. Its Length is evaluated from the
95 //! text (by C function strlen)
96 Standard_EXPORT void Add (const Standard_CString text);
98 //! Adds a text as a CString. Its length is given as <lntext>
99 Standard_EXPORT void Add (const Standard_CString text, const Standard_Integer lntext);
101 //! Adds a text as a AsciiString from TCollection
102 Standard_EXPORT void Add (const TCollection_AsciiString& text);
104 //! Adds a text made of only ONE Character
105 Standard_EXPORT void Add (const Standard_Character text);
119 //! Prepares Move : Inserts Initial Blanks if required, and
120 //! determines if SetKeep can be supported (it cannot be if Length
121 //! + Next String to get (see CanGet) overpass Max Size)
122 Standard_EXPORT void Prepare();
124 //! Keeps characters from SetKeep. If SetKeep is Zero, equivalent
126 Standard_EXPORT void Keep();
129 TCollection_AsciiString theline;
130 Standard_Integer themax;
131 Standard_Integer theinit;
132 Standard_Integer thekeep;
133 Standard_Integer theget;
134 Standard_Integer thelen;
135 Standard_Integer thefriz;
136 Standard_Character thekept;
147 #endif // _Interface_LineBuffer_HeaderFile