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

Annotation of /trunk/Src/StringBuffer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 368 - (hide annotations)
Tue Dec 6 13:40:04 2011 UTC (13 years, 2 months ago) by twoaday
File MIME type: text/plain
File size: 2544 byte(s)
2011-12-06  Timo Schulz  <twoaday@gmx.net>

        * wptNLS.cpp (get_user_langid): Removed.
        Use gettext_get_langid() instead. Changed all callers.
        (gettext_set_file): Removed.
        (w32_stpcpy): Likewise.
        * StringBuffer.cpp: Overload '=' operator for 'char*'.


1 twoaday 326 #ifndef __STRING_BUFFER_H
2     #define __STRING_BUFFER_H
3    
4 twoaday 328 /* Copyright (C) 2006, 2007, 2009 Timo Schulz
5 twoaday 326 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 twoaday 328 /* Destructor which frees the used memory. */
35 twoaday 326 ~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 twoaday 328
64     /* Add only @len bytes of @val. */
65     void add(const char *val, size_t len);
66 twoaday 326
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    
77     StringBuffer& operator +(unsigned long val);
78    
79     StringBuffer& operator +(const char *val);
80    
81     StringBuffer& operator +=(int val);
82    
83     StringBuffer& operator +=(unsigned long val);
84    
85     StringBuffer& operator +=(const char *val);
86 twoaday 328
87     StringBuffer& operator +=(char *);
88 twoaday 326
89     StringBuffer& operator +=(char val);
90    
91     StringBuffer& operator=(const char *val);
92 twoaday 368
93     StringBuffer& operator=(char *val);
94 twoaday 326 };
95    
96    
97     #endif /*__STRING_BUFFER_H*/

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26