]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/string-data.hh
more conversion for dash-change.
[lilypond.git] / flower / include / string-data.hh
1 /*
2   string-data.hh -- declare  String_data
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef STRINGDATA_HH
10 #define STRINGDATA_HH
11
12 #include "flower-proto.hh"
13
14 namespace std {
15   
16 /**Internal String struct.
17    the data itself. Handles simple tasks (resizing, resetting)
18 */
19 class String_data
20 {
21   // GNU malloc: storage overhead is 8 bytes anyway.
22
23   friend class String_handle;
24   int maxlen;   // maxlen is arraysize-1
25
26   int length_;
27   Byte *data_byte_;
28   int ref_count_;
29
30   /// init to ""
31   String_data ();
32
33   /// init from src. Conservative allocation.
34   String_data (String_data const &src);
35
36   ~String_data ();
37
38   /** POST: maxlen >= j.
39       @param j, maximum stringlength_.
40       contents thrown away.
41   */
42   void setmax (int j);
43
44   /** POST: maxlen >= j.
45       @param j, maximum stringlength_.
46       contents are kept if it grows.
47   */
48   void remax (int j);
49
50   /// check if writeable.
51   void OKW ();
52
53   /// check state.
54   void OK ();
55
56   /// reduce memory usage.
57   void tighten ();
58
59   // assignment.
60   void set (Byte const *byte, int length_i);
61
62   void set (char const *str0);
63
64   /// concatenation.
65   void append (Byte const *byte, int length_i);
66
67   void operator += (char const *str0);
68
69   char const *c_str () const;
70  
71   char *get_c_str ();
72
73   Byte const *to_bytes () const;
74
75   // idem, non const
76   Byte *get_bytes ();
77
78   void trunc (int j);
79
80   /** access element. not really safe. Can alter length_ without
81       #String_data# knowing it.  */
82   Byte &operator [] (int j);
83   Byte operator [] (int j) const;
84   bool is_binary_bo () const;
85 };
86
87 }
88
89 #ifdef STRING_UTILS_INLINED
90 #ifndef INLINE
91 #define INLINE inline
92 #endif
93 #include "string-data.icc"
94 #endif
95
96 #endif // STRING_DATA_HH