Massive changes - see ChangeLog.
[lilypond.git] / flower / include / string-handle.hh
blob90e9aad4df232a3f584ad029a84b0af3aade2f2b
1 /*
2 string-handle.hh -- declare String_handle
4 source file of the LilyPond music typesetter
6 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
10 #ifndef STRINGHANDLE_HH
11 #define STRINGHANDLE_HH
13 #include "flower-proto.hh"
16 /**
17 Reference counting for strings.
19 handles ref. counting, and provides a very thin interface using
20 Byte *
23 class String_handle {
24 String_data* data;
26 /// decrease ref count. Named kind of like a Tanenbaum semafore
27 void down ();
29 void up (String_data *d);
31 /** make sure data has only one reference.
32 POST: data->ref_count_ == 1
34 void copy ();
36 public:
37 String_handle ();
38 ~String_handle ();
39 String_handle (String_handle const & src);
41 Byte const* to_bytes () const;
42 char const* to_str0 () const;
43 Byte* get_bytes ();
44 char* get_str0 ();
45 bool is_binary_bo () const;
46 void operator = (String_handle const &src);
47 void operator += (char const *s);
48 Byte operator[] (int j) const;
50 /** Access elements. WARNING: NOT SAFE
51 don't use this for loops. Use to_bytes ()
53 Byte &operator[] (int j);
54 void append (Byte const* byte, int length_i);
55 void set (Byte const* byte, int length_i);
56 void operator = (char const *p);
57 void trunc (int j);
58 int length () const;
61 #ifdef STRING_UTILS_INLINED
62 #ifndef INLINE
63 #define INLINE inline
64 #endif
65 #include "string-handle.icc"
66 /* we should be resetting INLINE. oh well. */
67 #endif
70 #endif // STRINGHANDLE_HH