Canorus 0.0
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CALilyPondImport Class Reference

#include <lilypondimport.h>

Inheritance diagram for CALilyPondImport:
Inheritance graph
[legend]

Classes

struct  CATime
 

Public Member Functions

 CALilyPondImport (const QString in)
 
 CALilyPondImport (QTextStream *in=0)
 
 CALilyPondImport (CADocument *document, QTextStream *in=0)
 
void setTemplateVoice (CAVoice *voice)
 
virtual ~CALilyPondImport ()
 
const QString readableStatus ()
 
CASheetimportSheetImpl ()
 
- Public Member Functions inherited from CAImport
 CAImport (QTextStream *stream=0)
 
 CAImport (const QString stream)
 
virtual ~CAImport ()
 
void setStreamFromFile (const QString filename)
 
QString fileName ()
 
virtual const QString readableStatus ()
 
void importDocument ()
 
void importSheet ()
 
void importStaff ()
 
void importVoice ()
 
void importLyricsContext ()
 
void importFunctionMarkContext ()
 
CADocumentimportedDocument ()
 
CASheetimportedSheet ()
 
CAStaffimportedStaff ()
 
CAVoiceimportedVoice ()
 
CALyricsContextimportedLyricsContext ()
 
CAFunctionMarkContextimportedFunctionMarkContext ()
 
- Public Member Functions inherited from CAFile
 CAFile ()
 
virtual ~CAFile ()
 
const int status ()
 
const int progress ()
 
virtual const QString readableStatus ()=0
 
void setStreamFromFile (const QString filename)
 
void setStreamToFile (const QString filename)
 
void setStreamFromDevice (QIODevice *device)
 
void setStreamToDevice (QIODevice *device)
 
void setStreamToString ()
 
QString getStreamAsString ()
 

Private Types

enum  CALilyPondDepth { Score , Layout , Voice , Chord }
 

Private Member Functions

void initLilyPondImport ()
 
CAVoiceimportVoiceImpl ()
 
CALyricsContextimportLyricsContextImpl ()
 
CAVoicecurVoice ()
 
void setCurVoice (CAVoice *voice)
 
const QString parseNextElement ()
 
const QString peekNextElement ()
 
void addError (QString description, int lineError=0, int charError=0)
 
CAPlayableLength playableLengthFromLilyPond (QString &playableElt, bool parse=false)
 
bool isNote (const QString elt)
 
CADiatonicPitch relativePitchFromLilyPond (QString &note, CADiatonicPitch prevPitch, bool parse=false)
 
bool isRest (const QString elt)
 
CARest::CARestType restTypeFromLilyPond (QString &rest, bool parse=false)
 
CAClef::CAPredefinedClefType predefinedClefTypeFromLilyPond (const QString clef)
 
int clefOffsetFromLilyPond (const QString clef)
 
CABarline::CABarlineType barlineTypeFromLilyPond (const QString bar)
 
CADiatonicKey::CAGender diatonicKeyGenderFromLilyPond (QString gender)
 
CATime timeSigFromLilyPond (QString time)
 
CAMusElementfindSharedElement (CAMusElement *elt)
 
QString & in ()
 
CALilyPondDepth curDepth ()
 
void pushDepth (CALilyPondDepth depth)
 
CALilyPondDepth popDepth ()
 
int curLine ()
 
int curChar ()
 
CAVoicetemplateVoice ()
 

Private Attributes

CAVoice_curVoice
 
CASlur_curSlur
 
CASlur_curPhrasingSlur
 
QStack< CALilyPondDepth_depth
 
int _curLine
 
int _curChar
 
QList< QString > _errors
 
QList< QString > _warnings
 
CAVoice_templateVoice
 
CADocument_document
 

Static Private Attributes

static const QRegExp WHITESPACE_DELIMITERS = QRegExp("[\\s]")
 
static const QRegExp SYNTAX_DELIMITERS = QRegExp("[<>{}]")
 
static const QRegExp DELIMITERS
 

Additional Inherited Members

- Signals inherited from CAImport
void documentImported (CADocument *)
 
void sheetImported (CASheet *)
 
void staffImported (CAStaff *)
 
void voiceImported (CAVoice *)
 
void lyricsContextImported (CALyricsContext *)
 
void functionMarkContextImported (CAFunctionMarkContext *)
 
void importDone (int status)
 
- Protected Member Functions inherited from CAImport
virtual CADocumentimportDocumentImpl ()
 
virtual CASheetimportSheetImpl ()
 
virtual CAStaffimportStaffImpl ()
 
virtual CAVoiceimportVoiceImpl ()
 
virtual CALyricsContextimportLyricsContextImpl ()
 
virtual CAFunctionMarkContextimportFunctionMarkContextImpl ()
 
QTextStream & in ()
 
- Protected Member Functions inherited from CAFile
void setStatus (const int status)
 
void setProgress (const int progress)
 
QTextStream * stream ()
 
virtual void setStream (QTextStream *stream)
 
QFile * file ()
 
void setFile (QFile *file)
 
- Protected Attributes inherited from CAImport
QString _fileName
 

Member Enumeration Documentation

◆ CALilyPondDepth

Enumerator
Score 
Layout 
Voice 
Chord 

Constructor & Destructor Documentation

◆ CALilyPondImport() [1/3]

CALilyPondImport::CALilyPondImport ( const QString  in)

References initLilyPondImport().

Here is the call graph for this function:

◆ CALilyPondImport() [2/3]

CALilyPondImport::CALilyPondImport ( QTextStream *  in = 0)

References initLilyPondImport().

Here is the call graph for this function:

◆ CALilyPondImport() [3/3]

CALilyPondImport::CALilyPondImport ( CADocument document,
QTextStream *  in = 0 
)

References _document, and initLilyPondImport().

Here is the call graph for this function:

◆ ~CALilyPondImport()

CALilyPondImport::~CALilyPondImport ( )
virtual

Member Function Documentation

◆ addError()

void CALilyPondImport::addError ( QString  description,
int  lineError = 0,
int  charError = 0 
)
private

References _curChar, _curLine, _errors, curChar(), and curLine().

Referenced by importVoiceImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ barlineTypeFromLilyPond()

CABarline::CABarlineType CALilyPondImport::barlineTypeFromLilyPond ( const QString  bar)
private

Genarates barline type from the LilyPond syntax for the given barline from format "barlineType".

References CABarline::Dotted, CABarline::Double, CABarline::End, CABarline::RepeatClose, CABarline::RepeatCloseOpen, CABarline::RepeatOpen, CABarline::Single, and CABarline::Undefined.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ clefOffsetFromLilyPond()

int CALilyPondImport::clefOffsetFromLilyPond ( const QString  constClef)
private

Returns the Canorus octava or whichever interval above or below the clef.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ curChar()

int CALilyPondImport::curChar ( )
inlineprivate

References _curChar.

Referenced by addError(), and readableStatus().

Here is the caller graph for this function:

◆ curDepth()

CALilyPondDepth CALilyPondImport::curDepth ( )
inlineprivate

References _depth.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ curLine()

int CALilyPondImport::curLine ( )
inlineprivate

References _curLine.

Referenced by addError(), and readableStatus().

Here is the caller graph for this function:

◆ curVoice()

CAVoice * CALilyPondImport::curVoice ( )
inlineprivate

References _curVoice.

Referenced by findSharedElement(), and importVoiceImpl().

Here is the caller graph for this function:

◆ diatonicKeyGenderFromLilyPond()

CADiatonicKey::CAGender CALilyPondImport::diatonicKeyGenderFromLilyPond ( QString  gender)
private

Returns the key signature gender from format \genderType.

References CADiatonicKey::Major, and CADiatonicKey::Minor.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ findSharedElement()

CAMusElement * CALilyPondImport::findSharedElement ( CAMusElement elt)
private

Gathers a list of music elements with the given element's start time and returns the first music element in the gathered list with the same attributes.

This method is usually called when voices have "shared" music elements (barlines, clefs etc.). However, in LilyPond syntax the music element can/should be present in all the voices. This function finds this shared music element, if it already exists.

If the music element with the same properties exists, user should delete its own instance and add an already existing instance of the returned shared music element to the voice.

See also
CAMusElement::compare()

References curVoice(), CAStaff::getEltByType(), CAMusElement::musElementType(), CAVoice::staff(), and CAMusElement::timeStart().

Referenced by importVoiceImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ importLyricsContextImpl()

CALyricsContext * CALilyPondImport::importLyricsContextImpl ( )
privatevirtual

◆ importSheetImpl()

CASheet * CALilyPondImport::importSheetImpl ( )
virtual

Reimplemented from CAImport.

References _document, CAImport::fileName(), in(), parseNextElement(), CASheet::setName(), and CAFile::stream().

Here is the call graph for this function:

◆ importVoiceImpl()

CAVoice * CALilyPondImport::importVoiceImpl ( )
privatevirtual

◆ in()

QString & CALilyPondImport::in ( )
inlineprivate

References CAFile::stream().

Referenced by importLyricsContextImpl(), importSheetImpl(), importVoiceImpl(), parseNextElement(), and peekNextElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initLilyPondImport()

void CALilyPondImport::initLilyPondImport ( )
private

References _curChar, _curLine, _curPhrasingSlur, _curSlur, and _templateVoice.

Referenced by CALilyPondImport().

Here is the caller graph for this function:

◆ isNote()

bool CALilyPondImport::isNote ( const QString  elt)
private

Returns true, if the given LilyPond element is a note.

See also
isRest()

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ isRest()

bool CALilyPondImport::isRest ( const QString  elt)
private

Returns true, if the given LilyPond element is a rest.

See also
isNote()

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ parseNextElement()

const QString CALilyPondImport::parseNextElement ( )
private

Returns the first element in input stream ended with one of the delimiters and shorten input stream for the element.

Todo:
Only one-character syntax delimiters are supported so far.
See also
peekNextElement()

References DELIMITERS, and in().

Referenced by importLyricsContextImpl(), importSheetImpl(), and importVoiceImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peekNextElement()

const QString CALilyPondImport::peekNextElement ( )
private

Returns the first element in input stream ended with one of the delimiters but don't shorten the stream.

See also
parseNextElement()

References DELIMITERS, and in().

Referenced by importLyricsContextImpl(), and importVoiceImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ playableLengthFromLilyPond()

CAPlayableLength CALilyPondImport::playableLengthFromLilyPond ( QString &  elt,
bool  parse = false 
)
private

Generates playable lentgth and number of dots from the note/rest string in LilyPond syntax. If the playable element doesn't include length, { CAPlayable::CAPlayableLength::Undefined, 0 } is returned. This function also shortens the given string for the playable length, if parse is True.

See also
relativePitchFromString()

References CAPlayableLength::dotted(), CAPlayableLength::setDotted(), and CAPlayableLength::setMusicLength().

Referenced by importVoiceImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ popDepth()

CALilyPondDepth CALilyPondImport::popDepth ( )
inlineprivate

References _depth.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ predefinedClefTypeFromLilyPond()

CAClef::CAPredefinedClefType CALilyPondImport::predefinedClefTypeFromLilyPond ( const QString  constClef)
private

Genarates clef type from the LilyPond syntax for the given clef from format "clefType".

References CAClef::Alto, CAClef::Baritone, CAClef::Bass, CAClef::French, CAClef::Mezzosoprano, CAClef::Percussion, CAClef::Soprano, CAClef::Subbass, CAClef::Tablature, CAClef::Tenor, CAClef::Treble, and CAClef::Varbaritone.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ pushDepth()

void CALilyPondImport::pushDepth ( CALilyPondDepth  depth)
inlineprivate

References _depth.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ readableStatus()

const QString CALilyPondImport::readableStatus ( )
virtual

Reimplemented from CAImport.

References curChar(), curLine(), and CAFile::status().

Here is the call graph for this function:

◆ relativePitchFromLilyPond()

CADiatonicPitch CALilyPondImport::relativePitchFromLilyPond ( QString &  constNName,
CADiatonicPitch  prevPitch,
bool  parse = false 
)
private

Generates the note pitch and number of accidentals from the note written in LilyPond syntax.

See also
playableLengthFromLilyPond()

References CADiatonicPitch::noteName().

Referenced by importVoiceImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ restTypeFromLilyPond()

CARest::CARestType CALilyPondImport::restTypeFromLilyPond ( QString &  elt,
bool  parse = false 
)
private

Genarates rest type from the LilyPond syntax for the given rest. This function also shortens the given string for the rest type, if parse is True.

References CARest::Hidden, and CARest::Normal.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ setCurVoice()

void CALilyPondImport::setCurVoice ( CAVoice voice)
inlineprivate

References _curVoice.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ setTemplateVoice()

void CALilyPondImport::setTemplateVoice ( CAVoice voice)
inline

References _templateVoice.

Referenced by CAMainWin::sourceViewCommit().

Here is the caller graph for this function:

◆ templateVoice()

CAVoice * CALilyPondImport::templateVoice ( )
inlineprivate

References _templateVoice.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

◆ timeSigFromLilyPond()

CALilyPondImport::CATime CALilyPondImport::timeSigFromLilyPond ( QString  timeSig)
private

Returns the time signature beat and beats in beats/beat format.

Referenced by importVoiceImpl().

Here is the caller graph for this function:

Member Data Documentation

◆ _curChar

int CALilyPondImport::_curChar
private

◆ _curLine

int CALilyPondImport::_curLine
private

◆ _curPhrasingSlur

CASlur* CALilyPondImport::_curPhrasingSlur
private

◆ _curSlur

CASlur* CALilyPondImport::_curSlur
private

◆ _curVoice

CAVoice* CALilyPondImport::_curVoice
private

Referenced by curVoice(), and setCurVoice().

◆ _depth

QStack<CALilyPondDepth> CALilyPondImport::_depth
private

Referenced by curDepth(), popDepth(), and pushDepth().

◆ _document

CADocument* CALilyPondImport::_document
private

◆ _errors

QList<QString> CALilyPondImport::_errors
private

Referenced by addError().

◆ _templateVoice

CAVoice* CALilyPondImport::_templateVoice
private

◆ _warnings

QList<QString> CALilyPondImport::_warnings
private

◆ DELIMITERS

const QRegExp CALilyPondImport::DELIMITERS
staticprivate
Initial value:
=
QRegExp(
)
static const QRegExp WHITESPACE_DELIMITERS
Definition: lilypondimport.h:46
static const QRegExp SYNTAX_DELIMITERS
Definition: lilypondimport.h:47

Combined WHITESPACE_DELIMITERS and SYNTAX_DELIMITERS.

Referenced by parseNextElement(), and peekNextElement().

◆ SYNTAX_DELIMITERS

const QRegExp CALilyPondImport::SYNTAX_DELIMITERS = QRegExp("[<>{}]")
staticprivate

Delimiters which separate various music elements in LilyPond syntax, but are specific for LilyPond syntax. They are reported as its own element when parsing the next element.

See also
nextElement(), parseNextElement()

◆ WHITESPACE_DELIMITERS

const QRegExp CALilyPondImport::WHITESPACE_DELIMITERS = QRegExp("[\\s]")
staticprivate

Copyright (c) 2007, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.

Delimiters which separate various music elements in LilyPond syntax. These are new lines, tabs, blanks etc.

See also
nextElement(), parseNextElement()

The documentation for this class was generated from the following files: