]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/include/string.hh
* cygwin/GNUmakefile (INSTALLATION_OUT_SUFFIXES): Remove profile
[lilypond.git] / flower / include / string.hh
index b3f08e6738966ce511f3dcc59d5b9c6923d18004..d4787b3a7a11a003536eab329dba0bc55a8c9916 100644 (file)
@@ -1,19 +1,17 @@
 /*
-
   FILE   : string.hh -- declare String
+
   Rehacked by HWN 3/nov/95
   removed String & 's
   introduced Class String_handle
- */
+*/
 
 #ifndef STRING_HH
 #define STRING_HH
 
-
 // too darn slow with gcc3
 #ifdef STREAM_SUPPORT
-#if ( __GNUC__ > 2 )
+#if (__GNUC__ > 2)
 #include <iostream>
 #else
 class ostream;
@@ -23,69 +21,68 @@ class ostream;
 #include "arithmetic-operator.hh"
 #include "string-handle.hh"
 
-/** 
-  Intuitive string class. provides 
+/**
+
+Intuitive string class. provides
 \begin{itemize}
 \item
-  ref counting through #String_handle#
+ref counting through #String_handle#
 \item
-  conversion from bool, int, double, char* , char.  
+conversion from bool, int, double, char* , char.
 \item
-  to be moved to String_convert:
-  conversion to int, upcase, downcase 
+to be moved to String_convert:
+conversion to int, upcase, downcase
 
 \item
-  printable. 
+printable.
 
 \item
-  indexing (index_i, index_any_i, last_index_i)
+indexing (index_i, index_any_i, last_index_i)
 
 \item
-  cutting (left_string, right_string, mid_string)
+cutting (left_string, right_string, mid_string)
 
 \item
-  concat (+=, +)
+concat (+=, +)
 
 \item
-  signed comparison (<, >, ==, etc)
+signed comparison (<, >, ==, etc)
 
 \item
-  No operator[] is provided, since this would be enormously  slow. If needed,
-  convert to char const* .
+No operator[] is provided, since this would be enormously  slow. If needed,
+convert to char const* .
 \end{itemize}
-
 */
 class String
 {
 protected:
-  String_handle strh_; 
+  String_handle strh_;
 
   bool null_terminated ();
-    
+
 public:
 
   /** init to empty string. This is needed because other
-    constructors are provided.*/
+      constructors are provided.*/
   String ();
 
   /// String s = "abc";
-  String (char const* source); 
-  String (Byte constbyte, int length_i);
+  String (char const *source);
+  String (Byte const *byte, int length_i);
 
   ///  return "new"-ed copy of contents
-  Byteget_copy_byte () const;
-  charget_copy_str0 () const;
+  Byte *get_copy_byte () const;
+  char *get_copy_str0 () const;
 
-  char constto_str0 () const;
-  Byte constto_bytes () const;
+  char const *to_str0 () const;
+  Byte const *to_bytes () const;
   char *get_str0 ();
   Byte *get_bytes ();
 
-  String &operator = (String const & source);
+  String &operator = (String const &source);
 
   /// concatenate s
-  void operator += (char consts) { strh_ += s; }
+  void operator += (char const *s) { strh_ += s; }
   void operator += (String s);
 
   bool is_empty () const;
@@ -94,8 +91,8 @@ public:
   void prepend (String);
 
   /**
-    Return a char.  UNSAFE because it may change strlen () result
-   */
+     Return a char.  UNSAFE because it may change strlen () result
+  */
   char &operator [] (int n);
   char operator [] (int n) const;
 
@@ -115,20 +112,19 @@ public:
   String nomid_string (int index_i, int n) const;
 
   /// signed comparison,  analogous to memcmp;
-  static int compare (String const & s1,const  String& s2);
-       
+  static int compare (String const &s1, const String &s2);
+
   /// index of rightmost c 
   int index_last (char c) const;
 
   /// index of rightmost element of string (???)
-  int index_last (char conststring) const;
+  int index_last (char const *string) const;
 
   int index (char c) const;
 
   /// index of leftmost occurance of STRING
   int index (String) const;
 
-
   int index_any (String) const;
 
   void to_upper ();
@@ -136,9 +132,9 @@ public:
 
 #ifdef STREAM_SUPPORT
   /// provide Stream output
-  void print_on (ostreamos) const;
+  void print_on (ostream &os) const;
 #endif
-  
+
   /// the length of the string
   int length () const;
 
@@ -152,33 +148,32 @@ public:
 };
 
 /*
- better to clutter global namespace, than suffer *ugh, ugh, ugh*
- implicit conversions.
 better to clutter global namespace, than suffer *ugh, ugh, ugh*
 implicit conversions.
 
- it might be cool to have no type-checking at all in a language,
- but once there is, having this silently circumvented is a nightmare.
 it might be cool to have no type-checking at all in a language,
 but once there is, having this silently circumvented is a nightmare.
 
- whenever implicit conversions seem necessary (e.g. operator << ()),
- use Scalar as the generic type iso String.
- */
 whenever implicit conversions seem necessary (e.g. operator << ()),
 use Scalar as the generic type iso String.
+*/
 
 /// for completeness (=handy)
 inline String to_string (String s) { return s; }
 /// "cccc"
 String to_string (char c, int n = 1);
-String to_string (int i, char constformat = 0);
-String to_string (double f, char constformat = 0);
-String to_string (long  b);
+String to_string (int i, char const *format = 0);
+String to_string (double f, char const *format = 0);
+String to_string (long b);
 String to_string (bool b);
-String to_string (char const* format, ... );
+String to_string (char const *format, ...);
 
 /*
   technically incorrect, but lets keep it here: this is a
   catch all place for this stuff.
-  */
-  
-#include "international.hh"
+*/
 
+#include "international.hh"
 
 #include "compare.hh"
 INSTANTIATE_COMPARE (String const &, String::compare);
@@ -191,26 +186,27 @@ INSTANTIATE_COMPARE (String const &, String::compare);
 /* we should be resetting INLINE. oh well. */
 #endif
 
-
 // because char const* also has an operator ==, this is for safety:
-inline bool operator== (String s1, char const* s2)
+inline bool operator == (String s1, char const *s2)
 {
   return s1 == String (s2);
 }
-inline bool operator== (char const* s1, String s2)
+inline bool operator == (char const *s1, String s2)
 {
-  return String (s1)==s2;
+  return String (s1) == s2;
 }
-inline bool operator!= (String s1, char const* s2 ) {
-  return s1!=String (s2);
+inline bool operator != (String s1, char const *s2)
+{
+  return s1 != String (s2);
 }
-inline bool operator!= (char const* s1,String s2) {
-  return String (s2) !=s1;
+inline bool operator != (char const *s1, String s2)
+{
+  return String (s2) != s1;
 }
 
 IMPLEMENT_ARITHMETIC_OPERATOR (String, +);
 #ifdef STREAM_SUPPORT
-ostream &operator << (ostreamos, String d);
+ostream &operator << (ostream &os, String d);
 #endif
 
 #endif