summaryrefslogtreecommitdiffstats
path: root/src/bufstr.h
diff options
context:
space:
mode:
authordimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2001-01-07 17:28:47 (GMT)
committerdimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2001-01-07 17:28:47 (GMT)
commiteab6039875f05c8776119469fff0df8761b9b3a2 (patch)
treee0730802a8bb7eac348a5e39cffb88118aa42020 /src/bufstr.h
parente4cebf12a245705a0ecb714cd3794750af9d0844 (diff)
downloadDoxygen-eab6039875f05c8776119469fff0df8761b9b3a2.zip
Doxygen-eab6039875f05c8776119469fff0df8761b9b3a2.tar.gz
Doxygen-eab6039875f05c8776119469fff0df8761b9b3a2.tar.bz2
Release-1.2.4-20010107
Diffstat (limited to 'src/bufstr.h')
-rw-r--r--src/bufstr.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/bufstr.h b/src/bufstr.h
new file mode 100644
index 0000000..576dac7
--- /dev/null
+++ b/src/bufstr.h
@@ -0,0 +1,61 @@
+/******************************************************************************
+ *
+ *
+ *
+ *
+ * Copyright (C) 1997-2001 by Dimitri van Heesch.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied warranty.
+ * See the GNU General Public License for more details.
+ *
+ * Documents produced by Doxygen are derivative works derived from the
+ * input used in their production; they are not affected by this license.
+ *
+ */
+#ifndef _BUFSTR_H
+#define _BUFSTR_H
+
+#include "qtbc.h"
+
+/*! String that can deal more efficiently with large large numbers
+ * of resizing.
+ */
+class BufStr : public QCString
+{
+ public:
+ BufStr(int size) : QCString(size), offset(0), spareRoom(10240) {}
+ void addChar(char c)
+ {
+ if (offset>=size())
+ {
+ resize(size()+spareRoom);
+ }
+ data()[offset++]=c;
+ }
+ void addArray(const char *a,int len)
+ {
+ if (offset+len>=size())
+ {
+ resize(size()+len+spareRoom);
+ }
+ memcpy(data()+offset,a,len);
+ offset+=len;
+ }
+ uint curPos() { return offset; }
+ void skip(uint s)
+ {
+ if (offset+s>=size())
+ {
+ resize(size()+s+spareRoom);
+ }
+ offset+=s;
+ }
+ private:
+ uint offset;
+ const int spareRoom; // 10Kb extra room to avoid frequent resizing
+};
+
+#endif