]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/scalar.cc
patch::: 1.3.119.jcn3
[lilypond.git] / flower / scalar.cc
index ba7d810b03a765a5171e78534bf9d6c02ad023bf..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,103 +0,0 @@
-/*
-  scalar.cc -- implement Scalar
-
-  source file of the Flower Library
-
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include <assert.h>
-#include <stdio.h>
-#include "scalar.hh"
-#include "rational.hh"
-#include "matrix.hh"
-
-Scalar::Scalar (Rational r)
-{
-  (*this) = r.str ();
-}
-
-Scalar::operator Rational ()
-{
-  return to_rat ();
-}
-
-Rational
-Scalar::to_rat () const
-{
-  int p = index_i ('/');
-  if (p == -1)
-    return this->to_i ();
-  
-  String s2 = right_str (length_i ()-p-1);
-  String s1 = left_str (p);
-
-  return Rational (s1.value_i (), s2.value_i ());
-}
-
-bool
-Scalar::isnum_b () const
-{
-  int conv = false;
-  if (length_i ())
-    {
-      long l =0;
-      conv = sscanf (strh_.ch_C (), "%ld", &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 ()
-{
-  return to_i ();
-}
-
-int
-Scalar::to_i () const
-{
-  if (!length_i ())
-    return 0;                  // ugh
-  
-  assert (isnum_b());
-  return value_i ();
-}
-
-Scalar::operator bool () const
-{
-  return to_bool ();
-}
-
-bool
-Scalar::to_bool () const
-{
-  if (!length_i ())
-    return false;
-  if (*this == "0")
-    return false;
-  String u (*this);
-  if (u.upper_str () == "FALSE")
-    return false;
-  return true;
-}
-
-Scalar::Scalar(Matrix const &m)
-{
-  *this = m.str ();
-}
-
-Scalar::Scalar (Vector const &v)
-{
-  *this = v.str ();
-}