]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/include/string-handle.icc
*** empty log message ***
[lilypond.git] / flower / include / string-handle.icc
index decb241bff747970c2dab88b15af3ffce56ecab3..7e653ef2e278319af7b894e23b16d552f8cd8b08 100644 (file)
@@ -1,38 +1,48 @@
 /* -*-c++-*-
-   
-  stringhandle.inl -- implement String_handle
 
-  source file of Flower lib
+stringhandle.inl -- implement String_handle
 
-  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+source file of Flower lib
+
+(c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #ifndef STRINGHANDLE_INL
 #define STRINGHANDLE_INL
 
-#include <assert.h>
-#include <memory.h>
+#include <cassert>
+#include <memory>
+using namespace std;
 
 #include "string-data.hh"
 #include "string-handle.hh"
 
-INLINE void 
-String_handle::down () 
-{ 
-  if (! (--data->references)) delete data; data = 0; 
+namespace std {
+  
+INLINE void
+String_handle::down ()
+{
+  if (! (--data->ref_count_))
+    delete data;
+  data = 0;
 }
 
-/// increase ref count
-INLINE void 
-String_handle::up (String_data *d) 
-{ 
-  data=d; data->references ++; 
+/*
+  increase ref count
+
+  THIS does not have to be initialized.
+*/
+INLINE void
+String_handle::up (String_data *d)
+{
+  data = d;
+  data->ref_count_++;
 }
 
-INLINE void 
-String_handle::copy () 
+INLINE void
+String_handle::copy ()
 {
-  if (data->references !=1)
+  if (data->ref_count_ != 1)
     {
       String_data *newdata = new String_data (*data);
       down ();
@@ -41,51 +51,51 @@ String_handle::copy ()
 }
 
 INLINE
-String_handle::String_handle () 
+String_handle::String_handle ()
 {
   up (new String_data);
 }
 
 INLINE
-String_handle::~String_handle () 
-{      
+String_handle::~String_handle ()
+{
   down ();
-}    
+}
 
 INLINE
-String_handle::String_handle (String_handle const & src) 
-{      
+String_handle::String_handle (String_handle const &src)
+{
   up (src.data);
 }
 
-INLINE Byte
-String_handle::byte_l () 
+INLINE Byte *
+String_handle::get_bytes ()
 {
   copy ();
-  return data->byte_l ();
+  return data->get_bytes ();
 }
 
-INLINE char
-String_handle::ch_l () 
+INLINE char *
+String_handle::get_c_str ()
 {
   copy ();
-  return (char*)data->byte_l ();
+  return (char *)data->get_bytes ();
 }
 
-INLINE Byte 
-const* String_handle::byte_C () const 
+INLINE Byte
+const *String_handle::to_bytes () const
 {
-  return data->byte_C ();
+  return data->to_bytes ();
 }
 
-INLINE char const
-String_handle::ch_C () const 
+INLINE char const *
+String_handle::c_str () const
 {
-  return (char const*)data->byte_C ();
+  return (char const *)data->to_bytes ();
 }
 
-INLINE void 
-String_handle::operator = (String_handle const &src) 
+INLINE void
+String_handle::operator = (String_handle const &src)
 {
   if (this == &src)
     return;
@@ -93,65 +103,67 @@ String_handle::operator = (String_handle const &src)
   up (src.data);
 }
 
-INLINE void 
-String_handle::operator += (char const *s) 
-{      
+INLINE void
+String_handle::operator += (char const *s)
+{
   copy ();
   *data += s;
-}    
-
+}
 
-INLINE Byte 
-String_handle::operator[] (int j) const 
-{ 
-  return (*data)[j]; 
+INLINE Byte
+String_handle::operator [] (int j) const
+{
+  return (*data)[j];
 }
 
 // !NOT SAFE!
-// don't use this for loops. Use byte_C ()
+// don't use this for loops. Use to_bytes ()
 INLINE Byte &
-String_handle::operator[] (int j) 
+String_handle::operator [] (int j)
 {
   copy ();     // hmm. Not efficient
-  return data->byte_l ()[j];
+  return data->get_bytes ()[j];
 }
 
-INLINE void 
-String_handle::append (Byte const* byte_C, int length_i) 
+INLINE void
+String_handle::append (Byte const *byte, int length_i)
 {
   copy ();
-  data->append (byte_C, length_i);
+  data->append (byte, length_i);
 }
-                          
-INLINE void 
-String_handle::set (Byte const* byte_C, int length_i) 
+
+INLINE void
+String_handle::set (Byte const *byte, int length_i)
 {
   copy ();
-  data->set (byte_C, length_i);
+  data->set (byte, length_i);
 }
-                          
-INLINE void 
-String_handle::operator = (char const *p) 
+
+INLINE void
+String_handle::operator = (char const *p)
 {
   copy ();
   data->set (p);
 }
-                          
-INLINE void 
-String_handle::trunc (int j) 
+
+INLINE void
+String_handle::trunc (int j)
 {
-  copy (); data->trunc (j); 
+  copy (); data->trunc (j);
 }
 
-INLINE int 
-String_handle::length_i () const 
-{ 
-  return data->length_i_; 
+INLINE int
+String_handle::length () const
+{
+  return data->length_;
 }
 
 INLINE bool
-String_handle::is_binary_bo () const {
+String_handle::is_binary_bo () const
+{
   return data->is_binary_bo ();
 }
 
+}
+
 #endif