41 const wxString &cmdName,
const wxString &
params)
91 bool TransferString(
const wxString & Name, wxString & strValue);
96 bool ExchangeWithMaster(
const wxString & Name);
101bool ShuttleCli::ExchangeWithMaster(
const wxString & Name)
104 mParams = L
" " + mParams;
105 i = mParams.Find( L
" " + Name + L
"=" );
107 int j = i + 2 + Name.Length();
108 wxString terminator = L
' ';
109 if (mParams.GetChar(j) == L
'"')
114 else if(mParams.GetChar(j) == L
'\'')
120 while( j<(
int)mParams.Length() && mParams.GetChar(j) != terminator )
122 mValueString = mParams.Mid(i, j - i);
128bool ShuttleCli::TransferString(
const wxString & Name, wxString & strValue)
130 if( ExchangeWithMaster(Name)) {
131 strValue = mValueString;
140 const wxString &cmdName,
141 const wxString &cmdParamsArg)
145 mResponse = std::make_shared< ResponseTarget >();
147 = std::make_unique<CommandOutputTargets>(std::make_unique<NullProgressTarget>(),
151#ifdef OLD_BATCH_SYSTEM
159 wxASSERT(type != NULL);
161 mCommand->SetParameter(
wxT(
"CommandName"), cmdName);
162 mCommand->SetParameter(
wxT(
"ParamString"), cmdParamsArg);
163 auto aCommand = std::make_shared<ApplyAndSendResponse>(
mCommand, output);
166#ifdef OLD_BATCH_SYSTEM
175 shuttle.mParams = cmdParamsArg;
177 ParamValueMap::const_iterator iter;
181 for (iter =
params.begin(); iter !=
params.end(); ++iter)
183 wxString paramString;
185 if (shuttle.TransferString(iter->first, paramString,
wxT(
"")))
188 if (!
mCommand->SetParameter(iter->first, paramString))
198 wxString cmdParams(cmdParamsArg);
200 while (!cmdParams.empty())
202 cmdParams.Trim(
true);
203 cmdParams.Trim(
false);
204 int splitAt = cmdParams.Find(
wxT(
'='));
205 if (splitAt < 0 && !cmdParams.empty())
207 Failure(
wxT(
"Parameter string is missing '='"));
210 wxString paramName = cmdParams.Left(splitAt);
213 Failure(
wxT(
"Unrecognized parameter: '") + paramName +
wxT(
"'"));
219 cmdParams = cmdParams.Mid(splitAt+1);
220 if( cmdParams.empty() )
222 else if( cmdParams[0] ==
'\"' ){
223 cmdParams = cmdParams.Mid(1);
224 splitAt = cmdParams.Find(
wxT(
'\"'))+1;
226 else if( cmdParams[0] ==
'\'' ){
227 cmdParams = cmdParams.Mid(1);
228 splitAt = cmdParams.Find(
wxT(
'\''))+1;
231 splitAt = cmdParams.Find(
wxT(
' '))+1;
234 splitAt = cmdParams.length();
236 cmdParams = cmdParams.Mid(splitAt);
238 auto aCommand = std::make_shared<ApplyAndSendResponse>(
mCommand, output);
246 wxString cmdString(cmdStringArg);
250 cmdString.Trim(
true); cmdString.Trim(
false);
251 int splitAt = cmdString.Find(
wxT(
':'));
252 if (splitAt < 0 && cmdString.Find(
wxT(
' ')) >= 0) {
253 Failure(
wxT(
"Syntax error!\nCommand is missing ':'"));
257 wxString cmdName = cmdString.Left(splitAt);
258 wxString cmdParams = cmdString.Mid(splitAt+1);
263 cmdParams.Trim(
false);
Contains declaration of Command base class.
Contains declaration of CommandBuilder class.
Contains declarations for CommandDirectory class.
std::map< wxString, wxVariant > ParamValueMap
EffectDistortionSettings params
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
void Failure(const wxString &msg={})
void Success(const OldStyleCommandPointer &cmd)
void BuildCommand(AudacityProject &project, const wxString &cmdName, const wxString &cmdParams)
ResponseTargetPointer mResponse
OldStyleCommandPointer GetCommand()
CommandBuilder(AudacityProject &project, const wxString &cmdString)
OldStyleCommandPointer mCommand
OldStyleCommandType * LookUp(const wxString &cmdName) const
static CommandDirectory * Get()
Get a pointer to the singleton instance.
Class that maps parameter names to default values and validators.
ParamValueMap GetDefaults() const
OldStyleCommandPointer is a unique_ptr to an OldStyleCommand.
Base class for containing data common to all commands of a given type. Also acts as a factory.
virtual OldStyleCommandPointer Create(AudacityProject &project, std::unique_ptr< CommandOutputTargets > &&target)=0