Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Fl_Buffer.h

00001 /*
00002  * $Id: Fl_Buffer.h,v 1.9 2003/02/25 14:36:39 laza2000 Exp $
00003  *
00004  * Extended Fast Light Toolkit (EFLTK)
00005  * Copyright (C) 2002-2003 by EDE-Team
00006  * WWW: http://www.sourceforge.net/projects/ede
00007  *
00008  * Fast Light Toolkit (FLTK)
00009  * Copyright (C) 1998-2003 by Bill Spitzak and others.
00010  * WWW: http://www.fltk.org
00011  *
00012  * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00013  * version 2. See COPYING for details.
00014  *
00015  * Author : Alexey Parshin
00016  * Email  : alexey@fltk.net
00017  *
00018  * Please report all bugs and problems to "efltk-bugs@fltk.net"
00019  *
00020  */
00021 
00022 #ifndef _FL_BUFFER_H_
00023 #define _FL_BUFFER_H_
00024 
00025 #include "Fl_Export.h"
00026 #include "Fl_String.h"
00027 
00031 class FL_API Fl_Buffer 
00032 {
00033 protected:
00034     unsigned m_size;
00035     unsigned m_bytes;
00036     char *   m_buffer;
00037 public:
00038     Fl_Buffer(unsigned sz=16);
00039     ~Fl_Buffer();
00040     char *data() const { return m_buffer; }
00041     bool check_size(unsigned sz);
00042 
00043     void set(const char *data,unsigned sz);
00044     void set(const Fl_Buffer& buffer);
00045     void set(const Fl_String& str);
00046 
00047     void append(const char *data,unsigned sz);
00048     void append(char ch);
00049     void append(const Fl_Buffer& buffer);
00050     void append(const Fl_String& buffer);
00051 
00052     Fl_Buffer& operator = (const Fl_Buffer& buffer) {
00053         set(buffer);
00054         return *this;
00055     }
00056 
00057     Fl_Buffer& operator = (const Fl_String& buffer) {
00058         set(buffer);
00059         return *this;
00060     }
00061 
00062     Fl_Buffer& operator += (const Fl_Buffer& buffer) {
00063         append(buffer);
00064         return *this;
00065     }
00066 
00067     Fl_Buffer& operator += (const Fl_String& buffer) {
00068         append(buffer);
00069         return *this;
00070     }
00071 
00072     void reset();
00073     void fill(char c);
00074 
00075     unsigned size()  const { return m_size; }
00076     unsigned bytes() const { return m_bytes; }
00077     void bytes(unsigned b) { set(0L,b); }
00078 
00079     void save_file(const char *fileName);
00080     void read_file(const char *fileName);
00081 };
00082 
00087 class FL_API Fl_String_Buffer : public Fl_Buffer {
00088 public:
00089     Fl_String_Buffer(unsigned sz=16) : Fl_Buffer(sz) {}
00090     char& operator [] (int ndx) { return m_buffer[ndx]; }
00091 };
00092 
00093 #endif

Generated on Thu Jul 31 15:33:43 2003 for eFLTK by doxygen1.2.15