3 stringhandle.inl -- implement String_handle
5 source file of Flower lib
7 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #ifndef STRINGHANDLE_INL
11 #define STRINGHANDLE_INL
16 #include "string-data.hh"
17 #include "string-handle.hh"
20 String_handle::down ()
22 if (! (--data->ref_count_))
30 THIS does not have to be initialized.
33 String_handle::up (String_data *d)
40 String_handle::copy ()
42 if (data->ref_count_ !=1)
44 String_data *newdata = new String_data (*data);
51 String_handle::String_handle ()
57 String_handle::~String_handle ()
63 String_handle::String_handle (String_handle const & src)
69 String_handle::get_bytes ()
72 return data->get_bytes ();
76 String_handle::get_str0 ()
79 return (char*)data->get_bytes ();
83 const* String_handle::to_bytes () const
85 return data->to_bytes ();
89 String_handle::to_str0 () const
91 return (char const*)data->to_bytes ();
95 String_handle::operator = (String_handle const &src)
104 String_handle::operator += (char const *s)
112 String_handle::operator[] (int j) const
118 // don't use this for loops. Use to_bytes ()
120 String_handle::operator[] (int j)
122 copy (); // hmm. Not efficient
123 return data->get_bytes ()[j];
127 String_handle::append (Byte const* byte, int length_i)
130 data->append (byte, length_i);
134 String_handle::set (Byte const* byte, int length_i)
137 data->set (byte, length_i);
141 String_handle::operator = (char const *p)
148 String_handle::trunc (int j)
150 copy (); data->trunc (j);
154 String_handle::length () const
156 return data->length_;
160 String_handle::is_binary_bo () const {
161 return data->is_binary_bo ();