lilypond-1.4.3
[lilypond.git] / flower / include / string-data.hh
blob764dd8f0cdf65fa02efc88cb97287d01295ae3af
1 /*
2 string-data.hh -- declare String_data
4 source file of the LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.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, int length_i);
59 void set (char const* ch_C);
61 /// concatenation.
62 void append (Byte const* byte_C, int length_i);
64 void operator += (char const* ch_C);
66 char const* ch_C () const;
68 char* ch_l ();
70 Byte const* byte_C () 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;
81 bool is_binary_bo () const;
86 #ifdef STRING_UTILS_INLINED
87 #ifndef INLINE
88 #define INLINE inline
89 #endif
90 #include "string-data.icc"
92 #endif
95 #endif // STRING_DATA_HH