Skip to content

Commit ddb33aa

Browse files
committed
CUIMenu: do not use the full std namespace
The using namespace can cause confusions https://stackoverflow.com/questions/1452721/whats-the-problem-with-using-namespace-std
1 parent 02282a8 commit ddb33aa

File tree

1 file changed

+60
-61
lines changed

1 file changed

+60
-61
lines changed

src/uimenu.cpp

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <assert.h>
3232
#include <cstddef>
3333

34-
using namespace std;
3534
LOGMODULE ("uimenu");
3635

3736
const CUIMenu::TMenuItem CUIMenu::s_MenuRoot[] =
@@ -602,7 +601,7 @@ void CUIMenu::EditGlobalParameter (CUIMenu *pUIMenu, TMenuEvent Event)
602601
pUIMenu->m_MenuStackParent[pUIMenu->m_nCurrentMenuDepth-1]
603602
[pUIMenu->m_nMenuStackItem[pUIMenu->m_nCurrentMenuDepth-1]].Name;
604603

605-
string Value = GetGlobalValueString (Param,
604+
std::string Value = GetGlobalValueString (Param,
606605
pUIMenu->m_pMiniDexed->GetParameter (Param),
607606
pUIMenu->m_pConfig->GetLCDColumns() - 2);
608607

@@ -645,10 +644,10 @@ void CUIMenu::EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
645644
return;
646645
}
647646

648-
string TG ("TG");
649-
TG += to_string (nTG+1);
647+
std::string TG ("TG");
648+
TG += std::to_string (nTG+1);
650649

651-
string Value = to_string (nValue+1) + "="
650+
std::string Value = std::to_string (nValue+1) + "="
652651
+ pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetBankName (nValue);
653652

654653
pUIMenu->m_pUI->DisplayWrite (TG.c_str (),
@@ -704,7 +703,7 @@ void CUIMenu::EditProgramNumber (CUIMenu *pUIMenu, TMenuEvent Event)
704703

705704
// Skip empty voices.
706705
// Use same criteria in PgmUpDownHandler() too.
707-
string voiceName = pUIMenu->m_pMiniDexed->GetVoiceName (nTG);
706+
std::string voiceName = pUIMenu->m_pMiniDexed->GetVoiceName (nTG);
708707
if (voiceName == "EMPTY "
709708
|| voiceName == " "
710709
|| voiceName == "----------"
@@ -786,10 +785,10 @@ void CUIMenu::EditTGParameter (CUIMenu *pUIMenu, TMenuEvent Event)
786785
return;
787786
}
788787

789-
string TG ("TG");
790-
TG += to_string (nTG+1);
788+
std::string TG ("TG");
789+
TG += std::to_string (nTG+1);
791790

792-
string Value = GetTGValueString (Param,
791+
std::string Value = GetTGValueString (Param,
793792
pUIMenu->m_pMiniDexed->GetTGParameter (Param, nTG),
794793
pUIMenu->m_pConfig->GetLCDColumns() - 2);
795794

@@ -842,10 +841,10 @@ void CUIMenu::EditTGParameter2 (CUIMenu *pUIMenu, TMenuEvent Event) // second me
842841
return;
843842
}
844843

845-
string TG ("TG");
846-
TG += to_string (nTG+1);
844+
std::string TG ("TG");
845+
TG += std::to_string (nTG+1);
847846

848-
string Value = GetTGValueString (Param,
847+
std::string Value = GetTGValueString (Param,
849848
pUIMenu->m_pMiniDexed->GetTGParameter (Param, nTG),
850849
pUIMenu->m_pConfig->GetLCDColumns() - 2);
851850

@@ -898,10 +897,10 @@ void CUIMenu::EditVoiceParameter (CUIMenu *pUIMenu, TMenuEvent Event)
898897
return;
899898
}
900899

901-
string TG ("TG");
902-
TG += to_string (nTG+1);
900+
std::string TG ("TG");
901+
TG += std::to_string (nTG+1);
903902

904-
string Value = GetVoiceValueString (nParam, nValue, pUIMenu->m_pConfig->GetLCDColumns() - 2);
903+
std::string Value = GetVoiceValueString (nParam, nValue, pUIMenu->m_pConfig->GetLCDColumns() - 2);
905904

906905
pUIMenu->m_pUI->DisplayWrite (TG.c_str (),
907906
pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name,
@@ -952,10 +951,10 @@ void CUIMenu::EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event)
952951
return;
953952
}
954953

955-
string OP ("OP");
956-
OP += to_string (nOP+1);
954+
std::string OP ("OP");
955+
OP += std::to_string (nOP+1);
957956

958-
string Value;
957+
std::string Value;
959958

960959
static const int FixedMultiplier[4] = {1, 10, 100, 1000};
961960
if (nParam == DEXED_OP_FREQ_COARSE)
@@ -969,14 +968,14 @@ void CUIMenu::EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event)
969968
}
970969
else
971970
{
972-
Value = to_string (nValue);
971+
Value = std::to_string (nValue);
973972
Value += ".00";
974973
}
975974
}
976975
else
977976
{
978977
// Fixed
979-
Value = to_string (FixedMultiplier[nValue % 4]);
978+
Value = std::to_string (FixedMultiplier[nValue % 4]);
980979
}
981980
}
982981
else if (nParam == DEXED_OP_FREQ_FINE)
@@ -1034,9 +1033,9 @@ void CUIMenu::SavePerformance (CUIMenu *pUIMenu, TMenuEvent Event)
10341033
CTimer::Get ()->StartKernelTimer (MSEC2HZ (1500), TimerHandler, 0, pUIMenu);
10351034
}
10361035

1037-
string CUIMenu::GetGlobalValueString (unsigned nParameter, int nValue, int nWidth)
1036+
std::string CUIMenu::GetGlobalValueString (unsigned nParameter, int nValue, int nWidth)
10381037
{
1039-
string Result;
1038+
std::string Result;
10401039

10411040
assert (nParameter < sizeof CUIMenu::s_GlobalParameter / sizeof CUIMenu::s_GlobalParameter[0]);
10421041

@@ -1047,15 +1046,15 @@ string CUIMenu::GetGlobalValueString (unsigned nParameter, int nValue, int nWidt
10471046
}
10481047
else
10491048
{
1050-
Result = to_string (nValue);
1049+
Result = std::to_string (nValue);
10511050
}
10521051

10531052
return Result;
10541053
}
10551054

1056-
string CUIMenu::GetTGValueString (unsigned nTGParameter, int nValue, int nWidth)
1055+
std::string CUIMenu::GetTGValueString (unsigned nTGParameter, int nValue, int nWidth)
10571056
{
1058-
string Result;
1057+
std::string Result;
10591058

10601059
assert (nTGParameter < sizeof CUIMenu::s_TGParameter / sizeof CUIMenu::s_TGParameter[0]);
10611060

@@ -1066,15 +1065,15 @@ string CUIMenu::GetTGValueString (unsigned nTGParameter, int nValue, int nWidth)
10661065
}
10671066
else
10681067
{
1069-
Result = to_string (nValue);
1068+
Result = std::to_string (nValue);
10701069
}
10711070

10721071
return Result;
10731072
}
10741073

1075-
string CUIMenu::GetVoiceValueString (unsigned nVoiceParameter, int nValue, int nWidth)
1074+
std::string CUIMenu::GetVoiceValueString (unsigned nVoiceParameter, int nValue, int nWidth)
10761075
{
1077-
string Result;
1076+
std::string Result;
10781077

10791078
assert (nVoiceParameter < sizeof CUIMenu::s_VoiceParameter / sizeof CUIMenu::s_VoiceParameter[0]);
10801079

@@ -1085,15 +1084,15 @@ string CUIMenu::GetVoiceValueString (unsigned nVoiceParameter, int nValue, int n
10851084
}
10861085
else
10871086
{
1088-
Result = to_string (nValue);
1087+
Result = std::to_string (nValue);
10891088
}
10901089

10911090
return Result;
10921091
}
10931092

1094-
string CUIMenu::GetOPValueString (unsigned nOPParameter, int nValue, int nWidth)
1093+
std::string CUIMenu::GetOPValueString (unsigned nOPParameter, int nValue, int nWidth)
10951094
{
1096-
string Result;
1095+
std::string Result;
10971096

10981097
assert (nOPParameter < sizeof CUIMenu::s_OPParameter / sizeof CUIMenu::s_OPParameter[0]);
10991098

@@ -1104,13 +1103,13 @@ string CUIMenu::GetOPValueString (unsigned nOPParameter, int nValue, int nWidth)
11041103
}
11051104
else
11061105
{
1107-
Result = to_string (nValue);
1106+
Result = std::to_string (nValue);
11081107
}
11091108

11101109
return Result;
11111110
}
11121111

1113-
string CUIMenu::ToVolume (int nValue, int nWidth)
1112+
std::string CUIMenu::ToVolume (int nValue, int nWidth)
11141113
{
11151114
char buf[nWidth + 1];
11161115
unsigned nBarWidth = nWidth - 3;
@@ -1122,7 +1121,7 @@ string CUIMenu::ToVolume (int nValue, int nWidth)
11221121
return buf;
11231122
}
11241123

1125-
string CUIMenu::ToPan (int nValue, int nWidth)
1124+
std::string CUIMenu::ToPan (int nValue, int nWidth)
11261125
{
11271126
char buf[nWidth + 1];
11281127
unsigned nBarWidth = nWidth - 3;
@@ -1134,22 +1133,22 @@ string CUIMenu::ToPan (int nValue, int nWidth)
11341133
return buf;
11351134
}
11361135

1137-
string CUIMenu::ToMIDIChannel (int nValue, int nWidth)
1136+
std::string CUIMenu::ToMIDIChannel (int nValue, int nWidth)
11381137
{
11391138
switch (nValue)
11401139
{
11411140
case CMIDIDevice::OmniMode: return "Omni";
11421141
case CMIDIDevice::Disabled: return "Off";
1143-
default: return to_string (nValue+1);
1142+
default: return std::to_string (nValue+1);
11441143
}
11451144
}
11461145

1147-
string CUIMenu::ToAlgorithm (int nValue, int nWidth)
1146+
std::string CUIMenu::ToAlgorithm (int nValue, int nWidth)
11481147
{
1149-
return to_string (nValue + 1);
1148+
return std::to_string (nValue + 1);
11501149
}
11511150

1152-
string CUIMenu::ToOnOff (int nValue, int nWidth)
1151+
std::string CUIMenu::ToOnOff (int nValue, int nWidth)
11531152
{
11541153
static const char *OnOff[] = {"Off", "On"};
11551154

@@ -1158,7 +1157,7 @@ string CUIMenu::ToOnOff (int nValue, int nWidth)
11581157
return OnOff[nValue];
11591158
}
11601159

1161-
string CUIMenu::ToLFOWaveform (int nValue, int nWidth)
1160+
std::string CUIMenu::ToLFOWaveform (int nValue, int nWidth)
11621161
{
11631162
static const char *Waveform[] = {"Triangle", "Saw down", "Saw up",
11641163
"Square", "Sine", "Sample/Hold"};
@@ -1168,7 +1167,7 @@ string CUIMenu::ToLFOWaveform (int nValue, int nWidth)
11681167
return Waveform[nValue];
11691168
}
11701169

1171-
string CUIMenu::ToTransposeNote (int nValue, int nWidth)
1170+
std::string CUIMenu::ToTransposeNote (int nValue, int nWidth)
11721171
{
11731172
nValue += NoteC3 - 24;
11741173

@@ -1177,14 +1176,14 @@ string CUIMenu::ToTransposeNote (int nValue, int nWidth)
11771176
return s_NoteName[nValue];
11781177
}
11791178

1180-
string CUIMenu::ToBreakpointNote (int nValue, int nWidth)
1179+
std::string CUIMenu::ToBreakpointNote (int nValue, int nWidth)
11811180
{
11821181
assert ((unsigned) nValue < sizeof s_NoteName / sizeof s_NoteName[0]);
11831182

11841183
return s_NoteName[nValue];
11851184
}
11861185

1187-
string CUIMenu::ToKeyboardCurve (int nValue, int nWidth)
1186+
std::string CUIMenu::ToKeyboardCurve (int nValue, int nWidth)
11881187
{
11891188
static const char *Curve[] = {"-Lin", "-Exp", "+Exp", "+Lin"};
11901189

@@ -1193,7 +1192,7 @@ string CUIMenu::ToKeyboardCurve (int nValue, int nWidth)
11931192
return Curve[nValue];
11941193
}
11951194

1196-
string CUIMenu::ToOscillatorMode (int nValue, int nWidth)
1195+
std::string CUIMenu::ToOscillatorMode (int nValue, int nWidth)
11971196
{
11981197
static const char *Mode[] = {"Ratio", "Fixed"};
11991198

@@ -1202,51 +1201,51 @@ string CUIMenu::ToOscillatorMode (int nValue, int nWidth)
12021201
return Mode[nValue];
12031202
}
12041203

1205-
string CUIMenu::ToOscillatorDetune (int nValue, int nWidth)
1204+
std::string CUIMenu::ToOscillatorDetune (int nValue, int nWidth)
12061205
{
1207-
string Result;
1206+
std::string Result;
12081207

12091208
nValue -= 7;
12101209

12111210
if (nValue > 0)
12121211
{
1213-
Result = "+" + to_string (nValue);
1212+
Result = "+" + std::to_string (nValue);
12141213
}
12151214
else
12161215
{
1217-
Result = to_string (nValue);
1216+
Result = std::to_string (nValue);
12181217
}
12191218

12201219
return Result;
12211220
}
12221221

1223-
string CUIMenu::ToPortaMode (int nValue, int nWidth)
1222+
std::string CUIMenu::ToPortaMode (int nValue, int nWidth)
12241223
{
12251224
switch (nValue)
12261225
{
12271226
case 0: return "Fingered";
12281227
case 1: return "Full time";
1229-
default: return to_string (nValue);
1228+
default: return std::to_string (nValue);
12301229
}
12311230
};
12321231

1233-
string CUIMenu::ToPortaGlissando (int nValue, int nWidth)
1232+
std::string CUIMenu::ToPortaGlissando (int nValue, int nWidth)
12341233
{
12351234
switch (nValue)
12361235
{
12371236
case 0: return "Off";
12381237
case 1: return "On";
1239-
default: return to_string (nValue);
1238+
default: return std::to_string (nValue);
12401239
}
12411240
};
12421241

1243-
string CUIMenu::ToPolyMono (int nValue, int nWidth)
1242+
std::string CUIMenu::ToPolyMono (int nValue, int nWidth)
12441243
{
12451244
switch (nValue)
12461245
{
12471246
case 0: return "Poly";
12481247
case 1: return "Mono";
1249-
default: return to_string (nValue);
1248+
default: return std::to_string (nValue);
12501249
}
12511250
}
12521251

@@ -1401,7 +1400,7 @@ void CUIMenu::PgmUpDownHandler (TMenuEvent Event)
14011400

14021401
// Skip empty voices.
14031402
// Use same criteria in EditProgramNumber () too.
1404-
string voiceName = m_pMiniDexed->GetVoiceName (nTG);
1403+
std::string voiceName = m_pMiniDexed->GetVoiceName (nTG);
14051404
if (voiceName == "EMPTY "
14061405
|| voiceName == " "
14071406
|| voiceName == "----------"
@@ -1859,7 +1858,7 @@ void CUIMenu::EditPerformanceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
18591858
void CUIMenu::InputTxt (CUIMenu *pUIMenu, TMenuEvent Event)
18601859
{
18611860
unsigned nTG=0;
1862-
string TG ("TG");
1861+
std::string TG ("TG");
18631862

18641863
std::string MsgOk;
18651864
std::string NoValidChars;
@@ -1894,7 +1893,7 @@ void CUIMenu::InputTxt (CUIMenu *pUIMenu, TMenuEvent Event)
18941893
NoValidChars = {127};
18951894
MaxChars=10;
18961895
MenuTitleL="Name";
1897-
TG += to_string (nTG+1);
1896+
TG += std::to_string (nTG+1);
18981897
MenuTitleR=TG;
18991898
OkTitleL="";
19001899
OkTitleR="";
@@ -2000,7 +1999,7 @@ void CUIMenu::InputTxt (CUIMenu *pUIMenu, TMenuEvent Event)
20001999
// \E[?25l Cursor invisible
20012000

20022001
std::string escCursor="\E[?25h\E[2;"; // this is to locate cursor
2003-
escCursor += to_string(nPosition + 2);
2002+
escCursor += std::to_string(nPosition + 2);
20042003
escCursor += "H";
20052004

20062005

@@ -2063,10 +2062,10 @@ void CUIMenu::EditTGParameterModulation (CUIMenu *pUIMenu, TMenuEvent Event)
20632062
return;
20642063
}
20652064

2066-
string TG ("TG");
2067-
TG += to_string (nTG+1);
2065+
std::string TG ("TG");
2066+
TG += std::to_string (nTG+1);
20682067

2069-
string Value = GetTGValueString (Param,
2068+
std::string Value = GetTGValueString (Param,
20702069
pUIMenu->m_pMiniDexed->GetTGParameter (Param, nTG),
20712070
pUIMenu->m_pConfig->GetLCDColumns() - 2);
20722071

0 commit comments

Comments
 (0)