From: fred Date: Thu, 20 Feb 1997 22:34:43 +0000 (+0000) Subject: flower-1.1.1 X-Git-Tag: release/1.5.59~6306 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8b7138383db014a9cf12574eea77ae2a24480c0d;p=lilypond.git flower-1.1.1 --- diff --git a/flower/stringutil.hh b/flower/stringutil.hh deleted file mode 100644 index 728ce9bb30..0000000000 --- a/flower/stringutil.hh +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef __STRING_UTIL_HH -#define __STRING_UTIL_HH -#if 0 -#if !defined(NDEBUG) -#define NDEBUG BLONDE -#endif -#endif -const INITIALMAX=8; -class String_handle; - - -typedef unsigned char Byte; - -#ifdef STRING_UTILS_INLINED -#define INLINE inline -#else -#define INLINE -#endif - -/**Internal String struct. - the data itself. Handles simple tasks (resizing, resetting) - */ -class StringData { - // GNU malloc: storage overhead is 8 bytes anyway. - -friend class String_handle; - int maxlen; // maxlen is arraysize-1 - - int length_i_; - Byte* data_by_p_; - int references; - - /// init to "" - INLINE StringData(); - - /// init from src. Conservative allocation. - INLINE StringData(StringData const &src); - - ~StringData(); - - /** POST: maxlen >= j. - IN: j, maximum stringlength_i_. - contents thrown away. - */ - INLINE void setmax(int j); - - /** POST: maxlen >= j. - IN: j, maximum stringlength_i_. - contents are kept if it grows. - */ - INLINE void remax(int j); - - /// check if writeable. - INLINE void OKW(); - - /// check state. - INLINE void OK(); - - /// reduce memory usage. - INLINE void tighten(); - - // assignment. - INLINE void set( Byte const* by_c_l, int length_i ); - - INLINE void set( char const* ch_c_l ); - - /// concatenation. - INLINE void append( Byte const* by_c_l, int length_i ); - - INLINE void operator += ( char const* ch_c_l ); - - INLINE char const* ch_c_l() const; - - INLINE char* ch_l(); - - INLINE Byte const* by_c_l() const; - - // idem, non const - INLINE Byte* by_l(); - - INLINE void trunc(int j); - - /** not really safe. Can alter length_i_ without StringData knowing it. - */ - INLINE Byte &operator [](int j); - INLINE Byte operator [](int j) const; -}; - - - - -/** - Reference counting for strings. - - handles ref. counting, and provides a very thin interface using - Byte * - - */ -class String_handle { - StringData* data; - - /// decrease ref count. Named kind of like a Tanenbaum semafore - INLINE void down(); - - /// increase ref count - INLINE void up(StringData *d); - - /** make sure data has only one reference. - POST: data->references == 1 - */ - INLINE void copy(); - -public: - INLINE String_handle(); - INLINE ~String_handle(); - INLINE String_handle(String_handle const & src); - - INLINE Byte const* by_c_l() const; - INLINE char const* ch_c_l() const; - INLINE Byte* by_l(); - INLINE char* ch_l(); - - INLINE void operator =(String_handle const &src); - INLINE void operator += (char const *s); - INLINE Byte operator[](int j) const; - - /** Access elements. WARNING: NOT SAFE - don't use this for loops. Use by_c_l() - */ - INLINE Byte &operator[](int j); - INLINE void append( Byte const* by_c_l, int length_i ); - INLINE void set( Byte const* by_c_l, int length_i ); - INLINE void operator = (char const *p); - INLINE void trunc(int j); - INLINE int length_i() const; -}; - -#if 0 -#ifdef NDEBUG -#if (NDEBUG == BLONDE) -#undef NDEBUG -#endif -#endif -#endif - -#ifdef STRING_UTILS_INLINED -#include "stringutil.cc" -#endif - -#endif // __STRING_UTIL_HH //