3 stringhandle.inl -- implement String_handle
5 source file of Flower lib
7 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #ifndef STRINGHANDLE_INL
11 #define STRINGHANDLE_INL
16 #include "stringdata.hh"
17 #include "stringhandle.hh"
22 if (!(--data->references)) delete data; data = 0;
25 /// increase ref count
27 String_handle::up(String_data *d)
29 data=d; data->references ++;
35 if (data->references !=1){
36 String_data *newdata = new String_data(*data);
43 String_handle::String_handle()
49 String_handle::~String_handle()
55 String_handle::String_handle(String_handle const & src)
61 String_handle::byte_l()
64 return data->byte_l();
71 return (char*)data->byte_l();
75 const* String_handle::byte_c_l() const
77 return data->byte_c_l();
81 String_handle::ch_c_l() const
83 return (char const*)data->byte_c_l();
87 String_handle::operator =(String_handle const &src)
96 String_handle::operator += (char const *s)
104 String_handle::operator[](int j) const
110 // don't use this for loops. Use byte_c_l()
112 String_handle::operator[](int j)
114 copy(); // hmm. Not efficient
115 return data->byte_l()[j];
119 String_handle::append( Byte const* byte_c_l, int length_i )
122 data->append( byte_c_l, length_i );
126 String_handle::set( Byte const* byte_c_l, int length_i )
129 data->set( byte_c_l, length_i );
133 String_handle::operator = (char const *p)
140 String_handle::trunc(int j)
142 copy(); data->trunc(j);
146 String_handle::length_i() const
148 return data->length_i_;