本文整理汇总了C++中ArArgumentBuilder::getFullString方法的典型用法代码示例。如果您正苦于以下问题:C++ ArArgumentBuilder::getFullString方法的具体用法?C++ ArArgumentBuilder::getFullString怎么用?C++ ArArgumentBuilder::getFullString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArArgumentBuilder
的用法示例。
在下文中一共展示了ArArgumentBuilder::getFullString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addStringsForStartOfLogToMap
AREXPORT void ArServerHandlerMapping::addStringsForStartOfLogToMap(
ArMap *arMap)
{
std::list<std::string>::iterator it;
std::string str;
ArArgumentBuilder *builder;
for (it = myStringsForStartOfLog.begin();
it != myStringsForStartOfLog.end();
it++)
{
str = (*it);
builder = new ArArgumentBuilder;
builder->add(str.c_str());
if (strcasecmp(builder->getArg(0), "LogInfoStrip:") == 0)
{
builder->removeArg(0, true);
printf("lis %s\n", builder->getFullString());
}
std::list<std::string> infoNames = arMap->getInfoNames();
for (std::list<std::string>::iterator iter = infoNames.begin();
iter != infoNames.end();
iter++)
{
const char *curName = (*iter).c_str();
if (strcasecmp(builder->getArg(0), curName) == 0)
{
builder->removeArg(0, true);
arMap->getInfo(curName)->push_back(builder);
builder = NULL;
break;
}
}
if (builder != NULL)
delete builder;
}
}
示例2: playWavFile
bool ArSoundPlayer::playWavFile(const char* filename, const char* params)
{
ArArgumentBuilder builder;
//builder.addPlain("sleep .35; play");
builder.addPlain("play");
builder.add("-v %.2f", ourVolume);
builder.addPlain(filename);
builder.addPlain(params);
ArLog::log(ArLog::Normal, "ArSoundPlayer: Playing file \"%s\" with \"%s\"",
filename, builder.getFullString());
int ret;
if ((ret = system(builder.getFullString())) != -1)
{
ArLog::log(ArLog::Normal, "ArSoundPlayer: Played file \"%s\" with \"%s\" (got %d)",
filename, builder.getFullString(), ret);
return true;
}
else
{
ArLog::logErrorFromOS(ArLog::Normal,
"ArSoundPlayer::playWaveFile: system call failed");
return false;
}
/*
This was an old mechanism for doing a fork then exec in order to
mimic a system call, so that it could have the child PID for
killing... however in our embedded linux killing the play command
doesn't also kill the sox command, so the kill doesn't work at
all... and the fork() would also reserve a lot of memory for the new process
...
so it was replaced with the above system call
const char* prog = NULL;
prog = getenv("PLAY_WAV");
if(prog == NULL)
prog = "play";
char volstr[4];
if(strcmp(prog, "play") == 0)
{
snprintf(volstr, 4, "%f", ourVolume);
}
ArLog::log(ArLog::Normal, "ArSoundPlayer: Playing file \"%s\" using playback program \"%s\" with argument: -v %s", filename, prog, volstr);
ourPlayChildPID = fork();
//ourPlayChildPID = vfork(); // XXX rh experimental, avoids the memory copy cost of fork()
// NOTE: after vfork() you can ONLY safely use an exec function or _exit() in the
// child process. Any other call, if it modifies memory still shared by the
// parent, will result in problems.
if(ourPlayChildPID == -1)
{
ArLog::log(ArLog::Terse, "ArSoundPlayer: error forking! (%d: %s)", errno,
(errno == EAGAIN) ? "EAGAIN reached process limit, or insufficient memory to copy page tables" :
( (errno == ENOMEM) ? "ENOMEM out of kernel memory" : "unknown error" ) );
ArLog::logErrorFromOS(ArLog::Normal,
"ArSoundPlayer::playWaveFile: fork failed");
return false;
}
if(ourPlayChildPID == 0)
{
// child process: execute sox
int r = -1;
r = execlp(prog, prog, "-v", volstr, filename, (char*)0);
if(r < 0)
{
int err = errno;
const char *errstr = strerror(err);
printf("ArSoundPlayer (child process): Error executing Wav file playback program \"%s %s\" (%d: %s)\n", prog, filename, err, errstr);
//_exit(-1); // need to use _exit with vfork
exit(-1);
}
}
// parent process: wait for child to finish
ArLog::log(ArLog::Verbose, "ArSoundPlayer: created child process %d to play wav file \"%s\".",
ourPlayChildPID, filename);
int status;
waitpid(ourPlayChildPID, &status, 0);
if(WEXITSTATUS(status) != 0) {
ArLog::log(ArLog::Terse, "ArSoundPlayer: Error: Wav file playback program \"%s\" with file \"%s\" exited with error code %d.", prog, filename, WEXITSTATUS(status));
ourPlayChildPID = -1;
return false;
}
ArLog::log(ArLog::Verbose, "ArSoundPlayer: child process %d finished.", ourPlayChildPID);
ourPlayChildPID = -1;
return true;
*/
}