Functions

/Users/garethloy/Musimathics/Musimat1.2/MusimatLib/Pitch.cpp File Reference

#include "Musimat.h"

Go to the source code of this file.

Functions

ostream & operator<< (ostream &os, Pitch &p)
Bool isnumeric (char c)
Bool inRange (char c, char lb, char ub)
istream & operator>> (istream &is, Pitch &p)

Function Documentation

Bool inRange ( char  c,
char  lb,
char  ub 
) [inline]

Definition at line 35 of file Pitch.cpp.

References Return.

Referenced by operator>>().

{
        Return c >= lb && c <= ub;
}
Bool isnumeric ( char  c ) [inline]

Definition at line 30 of file Pitch.cpp.

References Return.

Referenced by operator>>().

{
        Return c >= '0' && c <= '9';
}
ostream& operator<< ( ostream &  os,
Pitch p 
)

Definition at line 24 of file Pitch.cpp.

References Pitch::print(), and Return.

{
        os << p.print();
        Return os;
}
istream& operator>> ( istream &  is,
Pitch p 
)

Definition at line 40 of file Pitch.cpp.

References Else, If, inRange(), Pitch::isAccidental(), isnumeric(), Pitch::isPitchClass(), Return, and While.

{
        //char buf[16];
        //cin >> buf;
        //p = Pitch(buf);
        //Return is;
        char c;
        cin >> c;
        If ((p.m_pc = p.isPitchClass(c)) == -1) {
                cin.unget();
                Return is;
        }

        Integer acc = 0;
        While (cin >> c && ((acc = p.isAccidental(c)) != -3)) {
                p.m_acc += acc;
        }

        If (!inRange(c, '0', '9')) {
                cin.unget();
                Return is;
        } Else {
                char buf[16];
                char* b = buf;
                Integer cnt = 0;
                cin.unget(); 
                While (!cin.eof() && cin >> c && isnumeric(c) && cnt++ < 16) {
//                      char y = cin.eof();
                        *b++ = c;
                }
                cin.unget();
                *b = '\0';
                p.m_oct = atoi(buf);
        }
        Return is;
}