#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/OS/Text/TextBuffer.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL_TEXTBUFFER_HEADER #define RAVL_TEXTBUFFER_HEADER 1 /////////////////////////////////////////// //! file="Ravl/OS/Text/TextBuffer.hh" //! lib=RavlOS //! userlevel=Develop //! author="Charles Galambos" //! docentry="Ravl.OS.Text Processing" //! rcsid="$Id: TextBuffer.hh,v 1.6 2002/05/19 21:36:59 craftit Exp $" //! date="05/12/1997" #include "Ravl/Text/TextFileLine.hh" #include "Ravl/DList.hh" #include "Ravl/RCHandleV.hh" #include "Ravl/Assert.hh" namespace RavlN { ////////////////////////////////////// //! userlevel=Develop //: Text buffer body class TextBufferBodyC : public RCBodyVC { public: TextBufferBodyC(); //: Create a empty text buffer. bool Load(const StringC &filename); //: Try and load a file. bool AppendFile(const StringC &filename); //: Append a file to the end of this one. bool Load(istream &strm); //: Create buffer from stream. bool Append(istream &strm); //: Append contents of a stream to this file. bool SaveAs(const StringC &Filename); //: Try and save this file as another name. UIntT AppendLine(const StringC &text,bool noFinalReturn = false); //: Append a line of text to file. // If 'noFinalReturn' is false, check each line ends with '\n', otherwise leave it alone.
// returns LineNo or -1 if failed. UIntT Append(const StringC &text,bool noFinalReturn = false); //: Append a line of text to file. // If 'noFinalReturn' is false, check each line ends with '\n', otherwise leave it alone.
// returns LineNo or -1 if failed.
IntT GlobalSubst(const StringC &org,const StringC &nv);
//: Substute 'org' for 'nv' the whole buffer.
// returns the number of substitutions done.
void Empty();
//: Empty all contents, set name to noname
void Dump(ostream &strm) const ;
//: Dump to stdout.
inline UIntT NoLines() const
{ return noLines; }
//: Return number of lines in buffer.
inline bool IsReadonly() const
{ return Readonly; }
//: Is readonly ?
inline void SetModified()
{ Modified = true; }
//: Set renumber flag.
DListC
// returns LineNo or -1 if failed.
UIntT Append(const StringC &text,bool noFinalRet = false)
{ return Body().Append(text,noFinalRet); }
//: Append a line of text to file.
// If 'noFinalReturn' is false, ensure each line ends with '\n', otherwise leave it alone.
// returns LineNo or -1 if failed.
IntT GlobalSubst(const StringC &org,const StringC &nv)
{ return Body().GlobalSubst(org,nv); }
//: Substute 'org' for 'nv' the whole buffer.
// returns the number of substitutions done.
void Empty()
{ Body().Empty(); }
//: Empty all contents, set name to noname
void Dump(ostream &strm) const
{ Body().Dump(strm); }
//: Dump to stdout.
// For debuging only.
inline UIntT NoLines() const
{ return Body().NoLines(); }
//: Return number of lines in buffer.
inline bool IsReadonly() const
{ return Body().IsReadonly(); }
//: Is readonly ?
inline void SetModified()
{ Body().SetModified(); }
//: Set renumber flag.
DListC