]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/scalar.cc
release: 1.3.0
[lilypond.git] / flower / scalar.cc
index c1f69eda6002d6ad4caf797d0ff752358997932e..48d4889a4eaed7f1a49fd917ebf604c121b10bb8 100644 (file)
@@ -1,14 +1,15 @@
+#if 0
 /*
   scalar.cc -- implement Scalar
 
   source file of the Flower Library
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include <assert.h>
 #include <stdio.h>
-#include "scalar.hh"
+
 #include "rational.hh"
 
 Scalar::Scalar (Rational r)
@@ -17,10 +18,16 @@ Scalar::Scalar (Rational r)
 }
 
 Scalar::operator Rational ()
+{
+  return to_rat ();
+}
+
+Rational
+Scalar::to_rat () const
 {
   int p = index_i ('/');
   if (p == -1)
-    return int (*this);
+    return this->to_i ();
   
   String s2 = right_str (length_i ()-p-1);
   String s1 = left_str (p);
@@ -28,6 +35,19 @@ Scalar::operator Rational ()
   return Rational (s1.value_i (), s2.value_i ());
 }
 
+bool
+Scalar::isdir_b () const
+{
+  int conv = length_i ();
+  if (conv)
+    {
+      long l =0;
+      conv = sscanf (strh_.ch_C (), "%ld", &l);
+      conv = conv && (l >= -1 && l <= 1);
+    }
+  return conv;
+}
+
 bool
 Scalar::isnum_b () const
 {
@@ -35,18 +55,30 @@ Scalar::isnum_b () const
   if (length_i ())
     {
       long l =0;
-      conv = sscanf (strh_.ch_C (), "%ld", &l);
+      conv = sscanf (strh_.ch_C (), "%lf", &l);
     }
   return length_i () && conv;
 }
 
 Scalar::operator Real()
+{
+  return to_f ();
+}
+
+Real
+Scalar::to_f () const
 {
   assert (isnum_b ());
   return value_f ();
 }
 
-Scalar::operator int()
+Scalar::operator int ()
+{
+  return to_i ();
+}
+
+int
+Scalar::to_i () const
 {
   if (!length_i ())
     return 0;                  // ugh
@@ -72,3 +104,6 @@ Scalar::to_bool () const
     return false;
   return true;
 }
+
+
+#endif