lilypond-1.1.44
[lilypond.git] / flower / stringdata.hh
blobba9099c4402926a50c1c4a9c74438feb940bfd62
1 /*
2 stringdata.hh -- declare String_data
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
10 #ifndef STRINGDATA_HH
11 #define STRINGDATA_HH
14 /**Internal String struct.
15 the data itself. Handles simple tasks (resizing, resetting)
17 class String_data {
18 // GNU malloc: storage overhead is 8 bytes anyway.
20 friend class String_handle;
21 int maxlen; // maxlen is arraysize-1
23 int length_i_;
24 Byte* data_byte_p_;
25 int references;
27 /// init to ""
28 String_data();
30 /// init from src. Conservative allocation.
31 String_data(String_data const &src);
33 ~String_data();
35 /** POST: maxlen >= j.
36 @param j, maximum stringlength_i_.
37 contents thrown away.
39 void setmax(int j);
41 /** POST: maxlen >= j.
42 @param j, maximum stringlength_i_.
43 contents are kept if it grows.
45 void remax(int j);
47 /// check if writeable.
48 void OKW();
50 /// check state.
51 void OK();
53 /// reduce memory usage.
54 void tighten();
56 // assignment.
57 void set( Byte const* byte_c_l, int length_i );
59 void set( char const* ch_c_l );
61 /// concatenation.
62 void append( Byte const* byte_c_l, int length_i );
64 void operator += ( char const* ch_c_l );
66 char const* ch_c_l() const;
68 char* ch_l();
70 Byte const* byte_c_l() const;
72 // idem, non const
73 Byte* byte_l();
75 void trunc(int j);
77 /** access element. not really safe. Can alter length_i_ without
78 #String_data# knowing it. */
79 Byte &operator [](int j);
80 Byte operator [](int j) const;
85 #ifdef STRING_UTILS_INLINED
86 #ifndef INLINE
87 #define INLINE inline
88 #endif
89 #include "stringdata.inl"
91 #endif
94 #endif // STRING_DATA_HH