~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/lib/std/shl/obj/Strbuf.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-03-16 21:31:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110316213118-gk4k3ez3e5d2huna
Tags: 2.0.0-1
* QA upload.
* New upstream release
* Debian source format is 3.0 (quilt)
* Fix debhelper-but-no-misc-depends
* Fix ancient-standards-version
* Fix package-contains-linda-override
* debhelper compatibility is 7
* Fix dh-clean-k-is-deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ---------------------------------------------------------------------------
2
 
// - Strbuf.hpp                                                              -
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.                  -
7
 
// -                                                                         -
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
 
// ---------------------------------------------------------------------------
16
 
 
17
 
#ifndef  AFNIX_STRBUF_HPP
18
 
#define  AFNIX_STRBUF_HPP
19
 
 
20
 
#ifndef  AFNIX_STRING_HPP
21
 
#include "String.hpp"
22
 
#endif
23
 
 
24
 
namespace afnix {
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
37
 
 
38
 
  class Strbuf : public virtual Object {
39
 
  private:
40
 
    /// the buffer allocated size
41
 
    long d_size;
42
 
    /// the buffer length
43
 
    long d_length;
44
 
    /// the character buffer
45
 
    t_quad** p_buffer;
46
 
 
47
 
  public:
48
 
    /// create a new buffer class.
49
 
    Strbuf (void);
50
 
 
51
 
    /// create a new buffer class with a default size.
52
 
    /// @param size the buffer default size
53
 
    Strbuf (const long size);
54
 
    
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);
58
 
 
59
 
    /// create a new buffer and initialize it with a string
60
 
    /// @param value the string to initialize
61
 
    Strbuf (const String& value);
62
 
 
63
 
    /// destroy this buffer
64
 
    ~Strbuf (void);
65
 
 
66
 
    /// @return the class name
67
 
    String repr (void) const;
68
 
 
69
 
    /// reset this buffer
70
 
    virtual void reset (void);
71
 
 
72
 
    /// @return the length of this buffer
73
 
    virtual long length (void) const;
74
 
 
75
 
    /// @return the non combining length of this buffer
76
 
    virtual long ncclen (void) const;
77
 
 
78
 
    /// resize this buffer
79
 
    /// @param size the new buffer size
80
 
    virtual void resize (const long size);
81
 
 
82
 
    /// add a character in this buffer
83
 
    /// @param value the character to add in this buffer
84
 
    virtual void add (const char value);
85
 
 
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);
89
 
 
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);
94
 
 
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);
99
 
 
100
 
    /// add a character buffer in this buffer
101
 
    /// @param s the buffer to add
102
 
    virtual void add (const char* s);
103
 
 
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);
108
 
 
109
 
    /// add a unicode buffer in this buffer
110
 
    /// @param s the buffer to add
111
 
    virtual void add (const t_quad* s);
112
 
 
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);
117
 
 
118
 
    /// add a string to this buffer
119
 
    /// @param s the string to add to this buffer
120
 
    virtual void add (const String& s);
121
 
 
122
 
    /// delete a character at a certain position
123
 
    /// @param pos the character position
124
 
    virtual void chdel (const long pos);
125
 
 
126
 
    /// @return the buffer contents as a string
127
 
    virtual String tostring (void) const;
128
 
 
129
 
    /// @return the buffer contents as a string from position to end
130
 
    virtual String substr (const long pos) const;
131
 
 
132
 
  private:
133
 
    // make the copy constructor private
134
 
    Strbuf (const Strbuf&);
135
 
    // make the assignment operator private
136
 
    Strbuf& operator =  (const Strbuf&);
137
 
  };
138
 
}
139
 
 
140
 
#endif