]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/scalar.hh
release: 1.0.2
[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
16 /// Perl -like scalar type.
17 struct Scalar : public String 
18 {
19   Scalar (Real r) { *this = to_str (r); }
20   Scalar (int i) { *this = to_str (i); }
21   Scalar (char c) { *this = to_str (c); }
22   Scalar (char const *c) : String (c) {}    
23   Scalar (String s) : String (s) {}
24   Scalar (Rational);
25   operator Rational();
26   Scalar() {}
27   bool isnum_b() const;
28   operator Real();
29   operator int();
30   bool to_bool () const;
31
32   /*
33     urg, these are bit silly; perhaps should make "Print_string" class
34     (derive from Scalar?)
35    */
36   Scalar (Vector const &v);
37   Scalar (Matrix const &m);
38
39   /**   perl -like string to bool conversion.
40    */
41   operator bool() const;
42 };
43
44 #endif // SCALAR_HH
45