3 stringhandle.inl -- implement String_handle
5 source file of Flower lib
7 (c) 1997--1998 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)
37 String_data *newdata = new String_data (*data);
44 String_handle::String_handle()
50 String_handle::~String_handle()
56 String_handle::String_handle (String_handle const & src)
62 String_handle::byte_l()
65 return data->byte_l();
72 return (char*)data->byte_l();
76 const* String_handle::byte_C() const
78 return data->byte_C();
82 String_handle::ch_C() const
84 return (char const*)data->byte_C();
88 String_handle::operator =(String_handle const &src)
97 String_handle::operator += (char const *s)
105 String_handle::operator[](int j) const
111 // don't use this for loops. Use byte_C()
113 String_handle::operator[](int j)
115 copy(); // hmm. Not efficient
116 return data->byte_l()[j];
120 String_handle::append (Byte const* byte_C, int length_i)
123 data->append (byte_C, length_i);
127 String_handle::set (Byte const* byte_C, int length_i)
130 data->set (byte_C, length_i);
134 String_handle::operator = (char const *p)
141 String_handle::trunc (int j)
143 copy(); data->trunc (j);
147 String_handle::length_i() const
149 return data->length_i_;
153 String_handle::is_binary_bo() const {
154 return data->is_binary_bo();