{
#ifdef NPRINT
if (b)
- cout << _("Debug printout disabled. Compiled with NPRINT.") << endl;
+ cout << _ ("Debug output disabled. Compiled with NPRINT.") << endl;
#endif
flower_check_debug = b;
--- /dev/null
+/*
+ (c) Han-Wen Nienhuys 1995,96,97
+
+ Distributed under GNU GPL
+*/
+
+#ifndef ARRAY_H
+#define ARRAY_H
+#include <assert.h>
+
+#ifndef INLINE
+#define INLINE inline
+#endif
+
+/// copy a bare (C-)array from #src# to #dest# sized #count#
+template<class T> void arrcpy (T*dest, T*src, int count);
+
+/**
+ Scaleable array/stack template, for a type T with default constructor.
+
+
+ This template implements a scaleable vector. With (or without) range
+ checking. The type T should have a default constructor. It is
+ best suited for simple types, such as int, double or String, it
+ provides a paranoidly safe replacement for the new T[int] construct.
+
+ You should \bf{never} store pointers to objects in an Array (since
+ the array may be relocated without the pointer knowing it).
+
+ It uses stack terminology, (push, pop, top), and can be used as a stack.
+
+
+ */
+template<class T>
+class Array
+{
+protected:
+ /// maximum length of array.
+ int max_;
+
+ /// the data itself
+ T *array_p_;
+
+ /// stretch or shrink array.
+ void remax (int newmax)
+ {
+ T* newarr = new T[newmax];
+ size_ = (newmax < size_) ? newmax : size_;
+ arrcpy (newarr, array_p_, size_);
+
+ delete[] array_p_;
+ array_p_ = newarr;
+ max_ = newmax;
+ }
+ int size_;
+
+public:
+ /// check invariants
+ void OK() const
+ {
+ assert (max_ >= size_ && size_ >=0);
+ if (max_) assert (array_p_);
+ }
+ /** report the size_.
+ @see
+ {setsize_}
+ */
+ int size() const
+ { return size_; }
+
+ /// POST: size() == 0
+ void clear()
+ { size_ = 0; }
+
+ Array()
+ { array_p_ = 0; max_ =0; size_ =0; }
+
+ // ugh, get around gcc 2.8.1 ice; see bezier.cc
+ Array (int i)
+ {
+ max_ = size_ = i;
+ array_p_ = new T[i];
+ }
+
+
+ /** set the size_ to #s#.
+ POST: size() == s.
+ Warning: contents are unspecified */
+ void set_size (int s)
+ {
+ if (s >= max_) remax (s);
+ size_ = s;
+ }
+
+ ~Array()
+ { delete[] array_p_; }
+
+ /// return a "new"ed copy of array
+ T* copy_array() const
+ {
+ T* Tarray = new T[size_];
+ arrcpy (Tarray, array_p_, size_);
+ return Tarray;
+ }
+ // depracated
+ operator T*() const
+ {
+ return copy_array();
+ }
+ void operator=(Array const & src)
+ {
+ set_size (src.size_);
+ arrcpy (array_p_,src.array_p_, size_);
+ }
+ Array (Array const & src)
+ {
+ array_p_ = src.copy_array();
+ max_ = size_ = src.size_;
+ }
+
+ /// tighten array size_.
+ void precompute() {
+ remax (size_);
+ }
+
+ T * remove_array_p () {
+ T * p = array_p_;
+ size_ = 0;
+ max_ = 0;
+ array_p_ =0;
+ return p;
+ }
+
+ /// access element
+ T &operator[] (int i)
+ {
+ return elem (i);
+ }
+ /// access element
+ T const & operator[] (int i) const
+ {
+ return elem (i);
+ }
+ /// access element
+ T &elem (int i) const
+ {
+ assert (i >=0&&i<size_);
+ return ((T*)array_p_)[i];
+ }
+
+ /// add to the end of array
+ void push (T x)
+ {
+ if (size_ == max_)
+ remax (2*max_ + 1);
+
+ // T::operator=(T &) is called here. Safe to use with automatic
+ // vars
+ array_p_[size_++] = x;
+ }
+ /// remove and return last entry
+ T pop()
+ {
+ assert (!empty());
+ T l = top (0);
+ set_size (size()-1);
+ return l;
+ }
+ /// access last entry
+ T& top (int j=0)
+ {
+ return (*this)[size_-j-1];
+ }
+ /// return last entry
+ T top (int j=0) const
+ {
+ return (*this)[size_-j-1];
+ }
+
+
+ void swap (int i,int j)
+ {
+ T t ((*this)[i]);
+ (*this)[i]=(*this)[j];
+ (*this)[j]=t;
+ }
+ bool empty() const
+ { return !size_; }
+
+ void insert (T k, int j);
+ /**
+ remove i-th element, and return it.
+ */
+ T get (int i)
+ {
+ T t = elem (i);
+ del (i);
+ return t;
+ }
+ void unordered_del (int i)
+
+ {
+ elem (i) = top();
+ set_size (size() -1);
+ }
+ void del (int i)
+ {
+ assert (i >=0&& i < size_);
+ arrcpy (array_p_+i, array_p_+i+1, size_-i-1);
+ size_--;
+ }
+ // quicksort.
+ void sort (int (*compare)(T const&,T const&),
+ int lower = -1, int upper = -1);
+ void concat (Array<T> const &src)
+ {
+ int s = size_;
+ set_size (size_ + src.size_);
+ arrcpy (array_p_+s,src.array_p_, src.size_);
+ }
+ Array<T> slice (int lower, int upper)
+ {
+ assert (lower >= 0 && lower <=upper&& upper <= size_);
+ Array<T> r;
+ int s =upper-lower;
+ r.set_size (s);
+ arrcpy (r.array_p_, array_p_ + lower, s);
+ return r;
+ }
+ void reverse();
+};
+
+#include "array.icc"
+
+#endif
--- /dev/null
+/*
+ (c) Han-Wen Nienhuys 1995,96,97,98
+
+ Distributed under GNU GPL
+*/
+
+
+#if 0
+#include "array.hh"
+#ifdef INLINE
+#undef INLINE
+#endif
+
+#define INLINE
+#endif
+
+/*
+ functions with loops don't inline
+ */
+
+template<class T> INLINE void
+arrcpy (T*dest, T*src, int count)
+{
+ for (int i_shadows_local=0; i_shadows_local < count ; i_shadows_local++)
+ *dest++ = *src++;
+}
+
+template<class T> INLINE void
+Array<T>::insert (T k, int j)
+{
+ assert (j >=0 && j<= size_);
+ set_size (size_+1);
+ for (int i=size_-1; i > j; i--)
+ array_p_[i] = array_p_[i-1];
+ array_p_[j] = k;
+}
+
+template<class T> INLINE void
+Array<T>::sort (int (*compare)(T const&,T const&),
+ int lower = -1, int upper = -1)
+{
+ if (lower < 0)
+ {
+ lower = 0 ;
+ upper = size () - 1;
+ }
+ if (lower >= upper)
+ return;
+ swap (lower, (lower+upper)/2);
+ int last = lower;
+ for (int i= lower +1; i <= upper; i++)
+ if (compare (array_p_[i], array_p_[lower]) < 0)
+ swap (++last,i);
+ swap (lower, last);
+ sort (compare, lower, last-1);
+ sort (compare, last+1, upper);
+}
+
+template<class T> INLINE void
+Array<T>::reverse ()
+{
+ int h = size_/2;
+ for (int i =0,j = size_-1; i < h; i++,j--)
+ swap (i,j);
+}
+
#ifndef ASSOC_HH
#define ASSOC_HH
-#include "varray.hh"
+#include "array.hh"
#include <assert.h>
/**
#ifndef STRING_CONVERT_HH
#define STRING_CONVERT_HH
+#include <stdarg.h>
#include "fproto.hh"
#include "string.hh"
static int hex2nibble_i (Byte byte);
static Byte nibble2hex_byte (Byte byte);
public:
+ static String bool_str (bool b);
static String bin2dec_str (String bin_str);
static String bin2hex_str (String bin_str);
static String dec2bin_str (String str);
static int dec2_i (String dec_str);
static double dec2_f (String dec_str);
static String double_str (double f, char const* fmt=0);
+ static String form_str (char const* format, ...);
+ static String vform_str (char const* format, va_list args);
static int hex2_i (String str);
static unsigned hex2_u (String str);
static String hex2bin_str (String str);
#ifndef UNIONFIND_HH
#define UNIONFIND_HH
-#include "varray.hh"
+#include "array.hh"
/*
which points of a graph are connected?.
+#error
/*
(c) Han-Wen Nienhuys 1995,96,97,98
#if 0
-#include "varray.hh"
+#include "array.hh"
#ifdef INLINE
#undef INLINE
#endif
#include <math.h>
#include "real.hh"
-#include "varray.hh"
+#include "array.hh"
class Dstream;
class String;
dat.insert (v,i);
}
void del (int i) { dat.del (i); }
- operator String() const;
+
+ String str () const;
void operator +=(Vector v) {
assert (v.dim() == dim ());
\score {
- \melodic{ \octave c';
- \clef "violin"; c1^"{violin}" \bar "||";
- \clef "french";c1^"{french}" \bar "||";
- \clef "soprano";c1^"{soprano}" \bar "||";
- \clef "mezzosoprano";c1^"{mezzosoprano}" \bar "||";
- \clef "alto";c1^"{alto}" \bar "||";
- \clef "tenor";c1^"{tenor}" \bar "||";
- \clef "baritone";c1^"{baritone}" \bar "||";
- \clef "varbaritone";c1^"{varbaritone}" \bar "||";
- \clef "G_8";c1^"{sub 8?}" \bar "||";
- \clef "G^8";c1^"{sup 8?}" \bar "|.";
- \clef "bass";c1^"{bass}" \bar "||";
- \clef "subbass";c1^"{subbass}" \bar "|.";
+ \melodic{
+ \clef "violin"; c'1^"{violin}" \bar "||";
+ \clef "french";c'1^"{french}" \bar "||";
+ \clef "soprano";c'1^"{soprano}" \bar "||";
+ \clef "mezzosoprano";c'1^"{mezzosoprano}" \bar "||";
+ \clef "alto";c'1^"{alto}" \bar "||";
+ \clef "tenor";c'1^"{tenor}" \bar "||";
+ \clef "baritone";c'1^"{baritone}" \bar "||";
+ \clef "varbaritone";c'1^"{varbaritone}" \bar "||";
+ \clef "G_8";c'1^"{sub 8?}" \bar "||";
+ \clef "G^8";c'1^"{sup 8?}" \bar "|.";
+ \clef "bass";c'1^"{bass}" \bar "||";
+ \clef "subbass";c'1^"{subbass}" \bar "|.";
}
\paper{
}
--- /dev/null
+
+\include "table13.ly";
+\include "table16.ly";
+
+\score{
+ <
+ \type Staff = a \melodic\relative c <
+% {\grace b''8 \graceat a4 \ecarg g fis2 | a2 a }
+ {\tiny b''8*1/16 \normalsize a4*31/32 g fis2 | a2 a }
+ >
+ \type Staff = b \melodic\relative c <
+% {\grace g''16 b16 \graceat a4 \ecarg g fis2 | }
+ {\tiny g''16*1/16 b16*1/16 \normalsize a4*31/32 g fis2 | a1 }
+ >
+ \type Staff = c \melodic\relative c <
+% {\grace [2/48 g''16 b g]/1 \graceat a4 \ecarg g fis2 | a1 }
+ {\tiny [2/48 g''16 b g]/1 \normalsize a4*31/32 g fis2 | a1 }
+ >
+ >
+ \paper {
+ linewidth = 120.0\mm;
+ -2 = \symboltables { \table_thirteen }
+ -1 = \symboltables { \table_sixteen }
+
+ }
+}
+
--- /dev/null
+% to see the magic: uncomment size stuff in init/paper20.ly
+
+c'4 c4
+
+\property Voice.fontsize= "-2"
+b16 * 1 / 2 (
+\property Voice.fontsize= "0" )
+g4 *31/32
+
+a a g2
String pre_str ((Byte const*)begin_ch_c_l, pos_ch_c_l - begin_ch_c_l);
pre_str = String_convert::bin2hex_str (pre_str);
for (int i = 2; i < pre_str.length_i (); i += 3)
- pre_str = pre_str.left_str (i) + " " + pre_str.cut (i, INT_MAX);
+ pre_str = pre_str.left_str (i) + " " + pre_str.cut_str (i, INT_MAX);
String post_str ((Byte const*)pos_ch_c_l, end_ch_c_l - pos_ch_c_l);
post_str = String_convert::bin2hex_str (post_str);
for (int i = 2; i < post_str.length_i (); i += 3)
- post_str = post_str.left_str (i) + " " + post_str.cut (i, INT_MAX);
+ post_str = post_str.left_str (i) + " " + post_str.cut_str (i, INT_MAX);
String str = pre_str
- + String ('\n')
- + String (' ', pre_str.length_i () + 1)
+ + to_str ('\n')
+ + to_str (' ', pre_str.length_i () + 1)
+ post_str;
return str;
}
void
error (String s)
{
- cerr << _ ("error: ") << s << "\n";
+ cerr << _ ("error: ") << s << '\n';
exit (1);
}
void
non_fatal_error (String s)
{
- cerr << _ ("error: ") << s << "\n";
+ cerr << _ ("error: ") << s << '\n';
}
void
--- /dev/null
+/*
+ some 2D geometrical concepts
+*/
+
+#ifndef BOXES_HH
+#define BOXES_HH
+
+#include "fproto.hh"
+#include "real.hh"
+#include "interval.hh"
+#include "offset.hh"
+#include "axes.hh"
+
+
+struct Box {
+ Interval interval_a_[NO_AXES];
+
+ Interval &x() {return interval_a_[X_AXIS]; }
+ Interval &y(){ return interval_a_[Y_AXIS]; }
+ Interval x() const{ return interval_a_[X_AXIS]; }
+ Interval y() const{return interval_a_[Y_AXIS]; }
+ Interval operator[](Axis a) const;
+ Interval &operator[] (Axis a);
+
+ void translate (Offset o);
+ /// smallest box enclosing #b#
+ void unite (Box b);
+ Box();
+ Box (Interval ix, Interval iy);
+};
+
+
+#endif
/// open a file for writing
Tex_stream (String filename);
void header();
- /// delegate conversion to string class.
- Tex_stream &operator<<(String);
+
+ /// delegate conversion to scalar class
+ Tex_stream &operator <<(Scalar);
/// close the file
~Tex_stream();
#include "command-request.hh"
#include "music-list.hh"
#include "identifier.hh"
-#include "varray.hh"
+#include "array.hh"
#include "text-def.hh"
#include "parseconstruct.hh"