#include <fstream.h>
#include "assoc.hh"
#include "dstream.hh"
-#include "string.hh"
+#include "scalar.hh"
#include "textdb.hh"
/// indent of each level
r.message("not enough fields in Dstream init.");
continue;
}
- (*silent)[r[0]] = r[1].to_bool();
+ (*silent)[r[0]] = Scalar(r[1]).to_bool();
}
}
--- /dev/null
+/*
+ scalar.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef SCALAR_HH
+#define SCALAR_HH
+#include "string.hh"
+#include "real.hh"
+
+/// Perl -like scalar type.
+struct Scalar : public String {
+
+ Scalar(Real r) : String(r) {}
+ Scalar(int i) : String(i) {}
+ Scalar(char c) : String(c) {}
+ Scalar(const char *c) : String(c) {}
+ Scalar(String s ):String(s) {}
+ Scalar() {}
+ bool isnum();
+ operator Real();
+ operator int();
+ ///
+ bool to_bool() const;
+ /** perl -like string to bool conversion
+ */
+
+};
+
+#endif // SCALAR_HH
+
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
-//#include "globals.hh"
+
#include "string.hh"
+
static char* strlwr( char* s )
{
char* p = s;
// String convd to const char *
}
- const char*
-String::ptr() const
+const char*
+String::cptr() const
{
return data;
}
-#ifdef CENTRAL_OBJECT // everything derived from Sortable object
-// comparisons.
-int
-String::operator ==( const Sortable& test ) const
-{
- const String *s = (const String *) &test;
- return *this == *s;
-}
-
-int
-String::operator &&(const Object& test) const
-{
- const String *s = (const String *) &test;
-
- int i = min( len(), s->len() );
- return ( i > 0 ) ?
- ( !strncmp( data, s->data, i ) ) : 0;
-}
-
-int
-String::operator >( const Sortable& test ) const
-{
- const String *s = (const String *) &test;
- return strcmp( data, s->data ) > 0;
-}
-#endif
-
// signed comparison, analogous to strcmp;
int
String::compare( const char* test ) const
strrev(s);
return retval;
}
-bool
-String::to_bool() const
-{
- if (!len())
- return false;
- if (*this == "0")
- return false;
- String u (*this);
- u.upper();
- if (u== "FALSE")
- return false;
- return true;
-}