From e6554551cfe74d2d61671c4a1740f9982ad8e190 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 22:45:07 +0000 Subject: [PATCH] lilypond-1.3.21 --- flower/include/scalar.hh | 49 ------------------ flower/scalar.cc | 109 --------------------------------------- 2 files changed, 158 deletions(-) diff --git a/flower/include/scalar.hh b/flower/include/scalar.hh index 4fecbd16e2..e69de29bb2 100644 --- a/flower/include/scalar.hh +++ b/flower/include/scalar.hh @@ -1,49 +0,0 @@ -/* - scalar.hh -- declare Scalar - - source file of the Flower Library - - (c) 1997--2000 Han-Wen Nienhuys -*/ - - -#ifndef SCALAR_HH -#define SCALAR_HH - -#include "string.hh" -#include "real.hh" -#include "protected-scm.hh" - -#error -/// Perl -like scalar type. -struct Scalar -{ - Protected_scm scm_; -public: - Scalar (Real r); - Scalar (int i); - Scalar (long l); - Scalar (char c); - Scalar (char const *c); - Scalar (String s); - Scalar (Rational); - operator Rational(); - Scalar(); - bool isnum_b() const; - bool isdir_b() const; - bool isint_b() const; - operator Real(); - operator int(); - bool to_bool () const; - Rational to_rat () const; - int to_i () const; - Real to_f () const; - - - /** perl -like string to bool conversion. - */ - operator bool() const; -}; - -#endif // SCALAR_HH - diff --git a/flower/scalar.cc b/flower/scalar.cc index 1f3f772386..e69de29bb2 100644 --- a/flower/scalar.cc +++ b/flower/scalar.cc @@ -1,109 +0,0 @@ -#if 0 -/* - scalar.cc -- implement Scalar - - source file of the Flower Library - - (c) 1997--2000 Han-Wen Nienhuys -*/ - -#include -#include - -#include "rational.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::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 -{ - int conv = false; - if (length_i ()) - { - long l =0; - 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 () -{ - 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; -} - - -#endif -- 2.39.5