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)
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
162 return data->is_binary_bo ();