22#include "smartpointer.h"
30typedef SMARTP<guidoelement> Sguidoelement;
31typedef SMARTP<guidoparam> Sguidoparam;
34EXP std::ostream& operator<< (std::ostream& os,
const Sguidoelement& elt);
53 void set (
long value,
bool quote=
true);
54 std::string get ()
const {
return fValue; }
55 bool quote ()
const {
return fQuote; }
58 guidoparam(std::string value,
bool quote);
59 guidoparam(
long value,
bool quote);
60 virtual ~guidoparam ();
80 virtual void print (std::ostream&
os)
const;
83 void setName (std::string name) { fName = name; }
84 std::string getName ()
const {
return fName; }
85 std::string getStart ()
const {
return fStartList; }
86 std::string getEnd ()
const {
return fEndList; }
87 std::string getSep ()
const {
return fSep; }
88 void setEnd (std::string end) { fEndList=end; }
89 std::vector<Sguidoelement>& elements() {
return fElements; }
90 const std::vector<Sguidoelement>& elements()
const {
return fElements; }
91 const std::vector<Sguidoparam>& parameters()
const {
return fParams; }
93 bool empty ()
const {
return fElements.empty(); }
94 virtual bool isSeq ()
const {
return false; }
95 virtual bool isChord ()
const {
return false; }
96 virtual bool isTag ()
const {
return false; }
97 virtual bool isNote ()
const {
return false; }
98 virtual bool isRangeTag()
const {
99 return fName.find(
"End") != std::string::npos || fName.find(
"Begin") != std::string::npos;
101 virtual bool isBeginTag()
const {
102 return fName.find(
"Begin") != std::string::npos;
104 virtual bool isEndTag()
const {
105 return fName.find(
"End") != std::string::npos;
108 int countNotes ()
const;
112 std::vector<Sguidoelement>::const_iterator
e = find(fElements.begin(), fElements.end(),
i);
113 if (
e != fElements.end()) {
114 auto next = std::next(
e);
115 if (next != fElements.end()) {
124 std::vector<Sguidoelement>::const_reverse_iterator
e = find(fElements.rbegin(), fElements.rend(),
i);
125 if (
e != fElements.rend()) {
126 auto next = std::next(
e);
127 if (next != fElements.rend()) {
137 guidoelement(std::string name, std::string sep=
" ");
138 virtual ~guidoelement();
140 void printparams (std::ostream& os)
const;
173 { fNum=
dur.fNum; fDenom=
dur.fDenom; fDots=
dur.fDots;
return *
this; }
175 {
return (fNum!=
dur.fNum) || (fDenom!=
dur.fDenom) || (fDots!=
dur.fDots); }
195 void setName (
const std::string name) { fNote = name; }
196 void setOctave (
char octave) { fOctave = octave; }
198 void setAccidental (
const std::string
acc) { fAccidental =
acc; }
200 const char * name()
const {
return fNote.c_str(); }
201 const char * accidental()
const {
return fAccidental.c_str(); }
202 char octave()
const {
return fOctave; }
205 virtual bool isNote ()
const {
return true; }
214 std::string fAccidental;
237 enum { kMaxInstances=128 };
240 static void resetall();
241 static void freeall();
243 enum { defoctave=1, defnum=1, defdenom=4 };
245 void reset() { fOctave=defoctave; fDur.set(defnum, defdenom, 0); }
265 virtual bool isSeq ()
const {
return true; }
279 virtual bool isChord ()
const {
return true; }
285 virtual void print (std::ostream&
os)
const;
299 virtual bool isTag ()
const {
return true; }
the smart pointer implementation
Definition smartpointer.h:58
The guido chord element.
Definition guido.h:276
A generic guido element representation.
Definition guido.h:73
std::string fSep
the element separator (default to space)
Definition guido.h:148
std::string fStartList
the contained element start marker (default to empty)
Definition guido.h:144
std::string fEndList
the contained element end marker (default to empty)
Definition guido.h:146
std::vector< Sguidoparam > fParams
list of optional parameters
Definition guido.h:152
std::vector< Sguidoelement > fElements
list of the enclosed elements
Definition guido.h:150
const bool getNext(Sguidoelement &i, Sguidoelement &next_e) const
Get next subelement.
Definition guido.h:111
void setName(std::string name)
the element name
Definition guido.h:83
A guido note representation.
Definition guido.h:188
A guido note duration representation.
Definition guido.h:164
Represents the current status of notes duration and octave.
Definition guido.h:235
A guidotag parameter representation.
Definition guido.h:46
void set(std::string value, bool quote=true)
the parameter value
The guido sequence element.
Definition guido.h:262
A guido tag representation.
Definition guido.h:295
the base class for smart pointers implementation
Definition smartpointer.h:29