3 stringhandle.inl -- implement String_handle
5 source file of Flower lib
7 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #ifndef STRINGHANDLE_INL
11 #define STRINGHANDLE_INL
17 #include "string-data.hh"
18 #include "string-handle.hh"
21 String_handle::down ()
23 if (! (--data->ref_count_))
31 THIS does not have to be initialized.
34 String_handle::up (String_data *d)
41 String_handle::copy ()
43 if (data->ref_count_ !=1)
45 String_data *newdata = new String_data (*data);
52 String_handle::String_handle ()
58 String_handle::~String_handle ()
64 String_handle::String_handle (String_handle const & src)
70 String_handle::get_bytes ()
73 return data->get_bytes ();
77 String_handle::get_str0 ()
80 return (char*)data->get_bytes ();
84 const* String_handle::to_bytes () const
86 return data->to_bytes ();
90 String_handle::to_str0 () const
92 return (char const*)data->to_bytes ();
96 String_handle::operator = (String_handle const &src)
105 String_handle::operator += (char const *s)
113 String_handle::operator[] (int j) const
119 // don't use this for loops. Use to_bytes ()
121 String_handle::operator[] (int j)
123 copy (); // hmm. Not efficient
124 return data->get_bytes ()[j];
128 String_handle::append (Byte const* byte, int length_i)
131 data->append (byte, length_i);
135 String_handle::set (Byte const* byte, int length_i)
138 data->set (byte, length_i);
142 String_handle::operator = (char const *p)
149 String_handle::trunc (int j)
151 copy (); data->trunc (j);
155 String_handle::length () const
157 return data->length_;
161 String_handle::is_binary_bo () const {
162 return data->is_binary_bo ();