]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/scalar.hh
release: 1.1.60
[lilypond.git] / flower / include / scalar.hh
1 /*
2   scalar.hh -- declare Scalar
3
4   source file of the Flower Library
5
6   (c)  1997--1999 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 (long l) { *this = to_str (l); }
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   bool isdir_b() const;
30   bool isint_b() const;
31   operator Real();
32   operator int();
33   bool to_bool () const;
34   Rational to_rat () const;
35   int to_i () const;
36   Real to_f () const;
37
38   /*
39     urg, these are bit silly; perhaps should make "Print_string" class
40     (derive from Scalar?)
41    */
42   Scalar (Vector const &v);
43   Scalar (Matrix const &m);
44
45   /**   perl -like string to bool conversion.
46    */
47   operator bool() const;
48 };
49
50 #endif // SCALAR_HH
51