/[winpt]/trunk/Src/StringBuffer.h
ViewVC logotype

Contents of /trunk/Src/StringBuffer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 441 - (show annotations)
Sat Apr 14 14:11:03 2012 UTC (12 years, 10 months ago) by twoaday
File MIME type: text/plain
File size: 2586 byte(s)
2012-04-14  Timo Schulz  <twoaday@gmx.net>

        * wptBalloonPop.cpp (window_proc): Removed unused variable.
        * wptCardDlg.cpp (do_askpin): Corrected generation of PIN
        info text. Thanks to Grzesiek.
			

1 #ifndef __STRING_BUFFER_H
2 #define __STRING_BUFFER_H
3
4 /* Copyright (C) 2006, 2007, 2009 Timo Schulz
5 Released under the GNU General Public License, Version 2. */
6
7 #define DEFSIZE 128
8
9 /* A simple string buffer implementation which allows to manipulate
10 the underlying buffer in a unified and easy way. The code is written
11 for clarity and simplicty, _not_ speed. */
12 class StringBuffer
13 {
14 private:
15 char *private_contents;
16 int alloced_size;
17 int size;
18
19 private:
20 /* Add the converted data at the end of the internal buffer.
21 Allocate more memory if needed, plus some extra bytes. */
22 void addCharacters (const char *buffer, int bufsize);
23
24 public:
25 StringBuffer ();
26
27 /* Create an empty buffer object with an inital size. */
28 StringBuffer (int bufsize);
29
30
31 /* Create a buffer object with the given contents. */
32 StringBuffer (const char *contents);
33
34 /* Destructor which frees the used memory. */
35 ~StringBuffer ();
36
37 /* Overwrite buffer contents in a safe manner. */
38 void wipeContents (void);
39
40 /* Return a constant pointer to the 'char*' data of the buffer. */
41 const char *getBuffer (void);
42
43 /* Return a copy of the buffer which must be freed after use. */
44 char* getBufferCopy (void);
45
46 /* Return the size of the underlying string. */
47 int getSize (void);
48
49 /* Reset the buffer contents. */
50 void reset (void);
51
52 /* Add an integer to the buffer. */
53 void add (int val);
54
55 /* Add a single character to the buffer. */
56 void add (char val);
57
58 /* Add a long-integer to the buffer. */
59 void add (long val);
60
61 /* Add a string to the buffer. */
62 void add (const char *val);
63
64 /* Add only @len bytes of @val. */
65 void add(const char *val, size_t len);
66
67 /* Add an unsigned integer to the buffer. */
68 void add (unsigned long val);
69
70 /* Add an unsigned integer in hex format to the buffer. */
71 void addHex (unsigned long val);
72
73 /* Overloaded operators to provide an easier interface
74 for manipulating the underlying buffer. */
75 StringBuffer& operator +(int val);
76 StringBuffer& operator +(unsigned long val);
77 StringBuffer& operator +(const char *val);
78 StringBuffer& operator +(char *val);
79
80 StringBuffer& operator +=(int val);
81 StringBuffer& operator +=(unsigned long val);
82 StringBuffer& operator +=(const char *val);
83 StringBuffer& operator +=(char *);
84 StringBuffer& operator +=(char val);
85
86 StringBuffer& operator=(const char *val);
87 StringBuffer& operator=(char *val);
88 };
89
90
91 #endif /*__STRING_BUFFER_H*/

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26