From f83c23b83121fcc1e37b52e00a51087273ee7edc Mon Sep 17 00:00:00 2001 From: zawz Date: Wed, 3 Jul 2019 19:50:30 +0200 Subject: [PATCH] Added comment support --- README | 3 ++- example.mim | 26 ++++++++++++++++---------- src/stringTools.cpp | 31 ++++++++++++++++++++++++------- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/README b/README index ba6e073..0221620 100644 --- a/README +++ b/README @@ -124,4 +124,5 @@ x single value x * all possible values -Comments can be written inside {} by doing //= +Comments can be done with // + note: // in value lines will not be ignored diff --git a/example.mim b/example.mim index b82bfdb..a458ebd 100644 --- a/example.mim +++ b/example.mim @@ -1,26 +1,29 @@ [ +// LAUNCH CONTROL { name=Launch Control commands=[ + // KNOBS HIGH { - //=KNOB HA - //=displays value 0:127 for knobs 21-28 + //KNOB HA + //displays value 0:127 for knobs 21-28 type=controller id=21:28 shell=echo "Knob #$id ch$channel:$value" }, + // KNOBS LOW { - //=KNOB L1 - //=displays value 0:127 for knob 41 from any channel + //KNOB L1 + //displays value 0:127 for knob 41 from any channel type=controller id=41 channel=* shell=echo "Knob #$id ch$channel:$value" }, { - //=KNOB L2 - //=displays value -100:100 for knob 42 on channel 0 + //KNOB L2 + //displays value -100:100 for knob 42 on channel 0 type=controller id=42 channel=0 @@ -28,8 +31,8 @@ shell=echo "Knob #$id ch$channel:$value r:$rawvalue" }, { - //=KNOB L3 H1 - //=displays value 0:1:0 for knob 42 on channel 1 (first half) + //KNOB L3 H1 + //displays value 0:1:0 for knob 42 on channel 1 (first half) type=controller id=42 channel=1 @@ -39,8 +42,8 @@ shell=echo "Knob #$id ch$channel:$value" }, { - //=KNOB L3 H2 - //=displays value 0:1:0 for knob 42 on channel 1 (second half) + //KNOB L3 H2 + //displays value 0:1:0 for knob 42 on channel 1 (second half) type=controller id=42 channel=1 @@ -52,15 +55,18 @@ ] } , +// LAUNCHPAD { name=Launchpad S commands=[ { + // ANY NOTE ON type=note id=* shell=echo "Note $id on velocity:$velocity" }, { + // ANY NOTE OFF type=note id=* trigger=0 diff --git a/src/stringTools.cpp b/src/stringTools.cpp index c4a2e51..9ade4c0 100644 --- a/src/stringTools.cpp +++ b/src/stringTools.cpp @@ -399,7 +399,7 @@ std::pair readValue(std::string const& in, unsigned int unsigned int i=0,j=0,reading=0; while(i=in.size()) { @@ -407,17 +407,26 @@ std::pair readValue(std::string const& in, unsigned int *rank=-1; return std::make_pair("",""); } - while(in[i]!='=' && in[i]!=':') //lire le nom + if(i+1 < in.size() && in[i]=='/' && in[i+1]=='/') //ignore // comment + { + i+=2; + while(i readValue(std::string const& in, unsigned int *rank=i; return std::make_pair(name, in.substr(j,i-j)); } - else if(in[i]=='[') /*Valeur encapsulée*/ + else if(in[i]=='[') //encapsulated { i++; while(i readList(std::string const& in) j=i; while(i readList(std::string const& in) i++; } } - else if(in[i]=='\"') + else if(in[i]=='\"') //quote value { i++; while(in[i]!='\"')