]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/scalar.cc
release: 0.0.28
[lilypond.git] / flower / scalar.cc
index b53693928fc613d6326ce202e4ee2b7e20a6a336..d8e6f9e74b927876f92c384d339daba951be650d 100644 (file)
@@ -1,6 +1,25 @@
 #include <stdio.h>
 #include "scalar.hh"
 
+Scalar::Scalar(Rational r)
+    :String(r)
+{
+
+}
+
+Scalar::operator Rational()
+{
+    int p = pos('/');
+    if (!p)
+       return int(*this);
+    
+    String s2 = right(len()-p);
+    p--;
+    String s1 = left(p);
+
+    return Rational(s1.value(), s2.value());
+}
+
 bool
 Scalar::isnum()
 {
@@ -23,8 +42,9 @@ Scalar::operator int()
     assert (isnum());
     return value();
 }
-bool
-Scalar::to_bool() const
+
+
+Scalar::operator bool() const
 {
     if (!len())
        return false;