1
// ---------------------------------------------------------------------------
3
// - standard object library - string buffer class definition -
4
// ---------------------------------------------------------------------------
5
// - This program is free software; you can redistribute it and/or modify -
6
// - it provided that this copyright notice is kept intact. -
8
// - This program is distributed in the hope that it will be useful, but -
9
// - without any warranty; without even the implied warranty of -
10
// - merchantability or fitness for a particular purpose. In no event shall -
11
// - the copyright holder be liable for any direct, indirect, incidental or -
12
// - special damages arising in any way out of the use of this software. -
13
// ---------------------------------------------------------------------------
14
// - copyright (c) 1999-2007 amaury darsch -
15
// ---------------------------------------------------------------------------
17
#ifndef AFNIX_STRBUF_HPP
18
#define AFNIX_STRBUF_HPP
20
#ifndef AFNIX_STRING_HPP
25
/// The Strbuf class is a string buffer which can be used to accumulate
26
/// unicode characters. The class is similar to the buffer class except
27
/// that it operates with quad representation. The internal representation
28
/// is also different from the string class as the buffer class stores
29
/// the characters in a 2 dimensional array. The horizontal dimension is
30
/// used by the characters without combining class, while the vertical
31
/// dimension is used for diacritics. With this approach, the horizontal
32
/// dimension is the string representation length. Nevertheless, the length
33
/// method returns as usual the total number of chararacters while the
34
/// ncclen returns the non combining length, which is the horizontal length
35
/// which is also the representation length.
36
/// @author amaury darsch
38
class Strbuf : public virtual Object {
40
/// the buffer allocated size
44
/// the character buffer
48
/// create a new buffer class.
51
/// create a new buffer class with a default size.
52
/// @param size the buffer default size
53
Strbuf (const long size);
55
/// create a new buffer and initialize it with a c string
56
/// @param value the c string to initialize
57
Strbuf (const char* value);
59
/// create a new buffer and initialize it with a string
60
/// @param value the string to initialize
61
Strbuf (const String& value);
63
/// destroy this buffer
66
/// @return the class name
67
String repr (void) const;
70
virtual void reset (void);
72
/// @return the length of this buffer
73
virtual long length (void) const;
75
/// @return the non combining length of this buffer
76
virtual long ncclen (void) const;
78
/// resize this buffer
79
/// @param size the new buffer size
80
virtual void resize (const long size);
82
/// add a character in this buffer
83
/// @param value the character to add in this buffer
84
virtual void add (const char value);
86
/// add a unicode character in this buffer
87
/// @param value the character to add in this buffer
88
virtual void add (const t_quad value);
90
/// add a unicode character in this buffer at a position
91
/// @param value the character to add in this buffer
92
/// @param pos the buffer position
93
virtual void add (const t_quad value, const long pos);
95
/// put a unicode character in this buffer at a position
96
/// @param value the character to put in this buffer
97
/// @param pos the buffer position
98
virtual void put (const t_quad value, const long pos);
100
/// add a character buffer in this buffer
101
/// @param s the buffer to add
102
virtual void add (const char* s);
104
/// add a character buffer in this buffer by size
105
/// @param s the buffer to add
106
/// @param size the buffer size
107
virtual void add (const char* s, const long size);
109
/// add a unicode buffer in this buffer
110
/// @param s the buffer to add
111
virtual void add (const t_quad* s);
113
/// add a unicode buffer in this buffer by size
114
/// @param s the buffer to add
115
/// @param size the buffer size
116
virtual void add (const t_quad* s, const long size);
118
/// add a string to this buffer
119
/// @param s the string to add to this buffer
120
virtual void add (const String& s);
122
/// delete a character at a certain position
123
/// @param pos the character position
124
virtual void chdel (const long pos);
126
/// @return the buffer contents as a string
127
virtual String tostring (void) const;
129
/// @return the buffer contents as a string from position to end
130
virtual String substr (const long pos) const;
133
// make the copy constructor private
134
Strbuf (const Strbuf&);
135
// make the assignment operator private
136
Strbuf& operator = (const Strbuf&);