Skip to content

Commit 3e9ede9

Browse files
Addition of new input format
1 parent 3a4bfcf commit 3e9ede9

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

Source/Processors/Editors/ChannelSelector.cpp

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,10 @@ int ChannelSelectorBox::convertToInteger(std::string s)
12521252
break;
12531253
}
12541254
}
1255-
1255+
if (j - i > 8)
1256+
{
1257+
return 0;
1258+
}
12561259
for (; i <= j; i++)
12571260
{
12581261
if (s[i] >= 48 && s[i] <= 57)
@@ -1297,6 +1300,27 @@ std::vector<int> ChannelSelectorBox::getBoxInfo(int len)
12971300
}
12981301
i = j;
12991302
}
1303+
else if ((int)s[i] >= 48 && (int)s[i] <= 57) // when input is given for a single channel without square brackets.
1304+
{
1305+
j = i;
1306+
for (; j < s.size(); j++)
1307+
{
1308+
if ((int)s[j] > 57 || (int)s[j] < 48)
1309+
{
1310+
break;
1311+
}
1312+
}
1313+
a = convertToInteger(s.substr(i, j - i + 1));
1314+
if (a == 0 || a > len)
1315+
{
1316+
i = j;
1317+
continue;
1318+
}
1319+
finalList.push_back(a - 1);
1320+
finalList.push_back(a - 1);
1321+
finalList.push_back(1);
1322+
i = j;
1323+
}
13001324
}
13011325

13021326
if (boxList.size() % 2 != 0)
@@ -1326,7 +1350,7 @@ std::vector<int> ChannelSelectorBox::getBoxInfo(int len)
13261350
otherChar++;
13271351
}
13281352
}
1329-
if (colonNum.size()>2 || colonNum.size() < 1 || otherChar > 0)
1353+
if (colonNum.size()>2 || otherChar > 0)
13301354
{
13311355
continue;
13321356
}
@@ -1377,7 +1401,17 @@ std::vector<int> ChannelSelectorBox::getBoxInfo(int len)
13771401
finalList.push_back(b - 1);
13781402
finalList.push_back(k);
13791403
}
1404+
else if (colonNum.size() == 0) // when range is of form [x]
1405+
{
1406+
a = convertToInteger(s.substr(boxList[i], boxList[i + 1] - boxList[i] + 1));
1407+
if (a == 0)
1408+
{
1409+
continue;
1410+
}
1411+
finalList.push_back(a - 1);
1412+
finalList.push_back(a - 1);
1413+
finalList.push_back(1);
1414+
}
13801415
}
1381-
13821416
return finalList;
13831417
}

Source/Processors/Editors/ChannelSelector.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ChannelSelectorRegion;
3535
class ChannelSelectorButton;
3636
class EditorButton;
3737
class ChannelSelectorBox;
38-
38+
class ShowAlertMessage;
3939
/**
4040
4141
Automatically creates an interactive editor for selecting channels.
@@ -314,5 +314,4 @@ class ChannelSelectorBox :public TextEditor
314314
std::vector<int> getBoxInfo(int len); // Extract Information from the box.
315315
int convertToInteger(std::string s); // Conversion of string to integer.
316316
};
317-
318317
#endif // __CHANNELSELECTOR_H_68124E35__

0 commit comments

Comments
 (0)