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 "string-data.hh"
17 #include "string-handle.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() const
77 return data->byte_C();
81 String_handle::ch_C() const
83 return (char const*)data->byte_C();
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()
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, int length_i )
122 data->append( byte_C, length_i );
126 String_handle::set( Byte const* byte_C, int length_i )
129 data->set( byte_C, 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_;
152 String_handle::is_binary_bo() const {
153 return data->is_binary_bo();