]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/scalar.hh
a963a2fb2a4a620af96ac17bf576841b79efadec
[lilypond.git] / flower / include / scalar.hh
1 /*
2   scalar.hh -- declare Scalar
3
4   source file of the Flower Library
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef SCALAR_HH
11 #define SCALAR_HH
12
13 #include "string.hh"
14 #include "real.hh"
15 #include "matrix.hh"
16
17 /// Perl -like scalar type.
18 struct Scalar : public String 
19 {
20   Scalar (Real r) { *this = to_str (r); }
21   Scalar (int i) { *this = to_str (i); }
22   Scalar (char c) { *this = to_str (c); }
23   Scalar (char const *c) : String (c) {}    
24   Scalar (String s) : String (s) {}
25   Scalar (Rational);
26   operator Rational();
27   Scalar() {}
28   bool isnum_b() const;
29   operator Real();
30   operator int();
31   bool to_bool () const;
32
33   /*
34     urg, these are bit silly; perhaps should make "Print_string" class
35     (derive from Scalar?)
36    */
37   Scalar (Vector v) { *this = v.str (); }
38   Scalar (Matrix m) { *this = m.str (); }
39
40   /**   perl -like string to bool conversion.
41    */
42   operator bool() const;
43 };
44
45 #endif // SCALAR_HH
46