]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/scalar.hh
b389277bc3bafcae8a49d056b51d1758e54e8a9e
[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   /**   perl -like string to bool conversion.
40    */
41   operator bool() const;
42 };
43
44 #endif // SCALAR_HH
45