2 string-data.hh -- declare String_data
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
14 /**Internal String struct.
15 the data itself. Handles simple tasks (resizing, resetting)
18 // GNU malloc: storage overhead is 8 bytes anyway.
20 friend class String_handle
;
21 int maxlen
; // maxlen is arraysize-1
30 /// init from src. Conservative allocation.
31 String_data(String_data
const &src
);
35 /** POST: maxlen >= j.
36 @param j, maximum stringlength_i_.
41 /** POST: maxlen >= j.
42 @param j, maximum stringlength_i_.
43 contents are kept if it grows.
47 /// check if writeable.
53 /// reduce memory usage.
57 void set( Byte
const* byte_c_l
, int length_i
);
59 void set( char const* ch_c_l
);
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;
70 Byte
const* byte_c_l() const;
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;
81 bool null_terminated_b()const;
86 #ifdef STRING_UTILS_INLINED
90 #include "string-data.inl"
95 #endif // STRING_DATA_HH