本文整理汇总了C++中parseCommandLine函数的典型用法代码示例。如果您正苦于以下问题:C++ parseCommandLine函数的具体用法?C++ parseCommandLine怎么用?C++ parseCommandLine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseCommandLine函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: request
void RPCExecutor::request(const QString &command)
{
std::vector<std::string> args;
if(!parseCommandLine(args, command.toStdString()))
{
emit reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
return;
}
if(args.empty())
return; // Nothing to do
try
{
std::string strPrint;
// Convert argument list to JSON objects in method-dependent way,
// and pass it along with the method name to the dispatcher.
json_spirit::Value result = tableRPC.execute(
args[0],
RPCConvertValues(args[0], std::vector<std::string>(args.begin() + 1, args.end())));
// Format result reply
if (result.type() == json_spirit::null_type)
strPrint = "";
else if (result.type() == json_spirit::str_type)
strPrint = result.get_str();
else
strPrint = write_string(result, true);
emit reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint));
}
catch (json_spirit::Object& objError)
{
try // Nice formatting for standard-format error
{
int code = find_value(objError, "code").get_int();
std::string message = find_value(objError, "message").get_str();
emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")");
}
catch(std::runtime_error &) // raised when converting to invalid type, i.e. missing code or message
{ // Show raw JSON object
emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(write_string(json_spirit::Value(objError), false)));
}
}
catch (std::exception& e)
{
emit reply(RPCConsole::CMD_ERROR, QString("Error: ") + QString::fromStdString(e.what()));
}
}
示例2: main
int main (int argc, const char **argv)
{
gSymbolList = (const char**)calloc (MAX_SUBSCRIPTIONS, sizeof (char*));
parseCommandLine (argc, argv);
if (!gNumSymbols)
gSymbolList[gNumSymbols++] = "MAMA_TOPIC";
initializeMama ();
createPublisher ();
subscribeToSymbols ();
start();
return 0;
}
示例3: main
int main(int argc, char* argv[])
{
parseCommandLine(argc,argv);
NarrowBand nb(filename);
nb.build3Dgrid(prec);
nb.expandGrid(expand);
nb.writeGridToFile();
nb.computeDistanceFunction();
nb.writeDtoFile();
nb.computeGradient();
nb.writeDDtoFile();
nb.computeInitialSurface();
nb.writeUtoFile();
nb.evolve(iter,deltaT);
return 0;
}
示例4: parseCommandLine
static void parseCommandLine(Ref<ParseStream> cin, const FileName& path)
{
while (true)
{
std::string tag = cin->getString();
if (tag == "") return;
/* parse command line parameters from a file */
if (tag == "-c") {
FileName file = path + cin->getFileName();
parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
}
/* parse camera parameters */
else if (tag == "-vp") g_camera.from = cin->getVec3fa();
else if (tag == "-vi") g_camera.to = cin->getVec3fa();
else if (tag == "-vd") g_camera.to = g_camera.from + cin->getVec3fa();
else if (tag == "-vu") g_camera.up = cin->getVec3fa();
else if (tag == "-fov") g_camera.fov = cin->getFloat();
/* frame buffer size */
else if (tag == "-size") {
g_width = cin->getInt();
g_height = cin->getInt();
}
/* full screen mode */
else if (tag == "-fullscreen")
g_fullscreen = true;
/* rtcore configuration */
else if (tag == "-rtcore")
g_rtcore = cin->getString();
/* number of threads to use */
else if (tag == "-threads")
g_numThreads = cin->getInt();
/* skip unknown command line parameter */
else {
std::cerr << "unknown command line parameter: " << tag << " ";
while (cin->peek() != "" && cin->peek()[0] != '-') std::cerr << cin->getString() << " ";
std::cerr << std::endl;
}
}
}
示例5: TEST_F
TEST_F(TestApplication, can_parse_command_line_expected_query) {
// Arrange
constexpr int argc = 3;
constexpr const char* argv[argc] = {
"somepath_to_binary",
"-q",
"Name1,Name2"
};
Parameters expected;
expected.query = "Name1,Name2";
// Act
const auto result = parseCommandLine(argc, argv);
// Assert
EXPECT_EQ(expected.query, result.query);
}
示例6: main
void main(int argc, char **argv)
{
/*! parse command line options */
parseCommandLine(argc, argv);
/*! bind to a port */
network::socket_t socket = network::bind(g_port);
/*! handle incoming connections */
do {
std::cout << std::endl << "listening for connections on port " << g_port << " ... " << std::flush;
network::socket_t client = network::listen(socket);
std::cout << " [CONNECTED]" << std::endl;
new NetworkServer(client,Device::rtCreateDevice(g_device_type.c_str(), g_threads),g_encoding,g_verbose);
}
while (g_multiple_connections);
}
示例7: main
int main(int argc, const char* argv[])
{
mamaCaptureConfig mCapture = NULL;
mamaCaptureList mCaptureList = NULL;
mamaCaptureConfig_create (&mCapture);
if (mCapture == NULL)
{
mama_log (MAMA_LOG_LEVEL_NORMAL,
"Allocation of memory for capture failed!!!!");
exit (1);
}
gCapture = &mCapture;
parseCommandLine (mCapture , &mCaptureList, argc, argv);
/*Set up a signal handler so that we don't
just stop without cleaning up*/
gCaptureList = &mCaptureList;
initializeMama (mCapture);
mamaCaptureList_parseCommandInput (mCapture,
mCaptureList, gSource);
mamaCapture_openFile (&mCapture->myCapture,
mCapture->myCaptureFilename);
buildDataDictionary(mCapture);
dumpDataDictionary (mCapture);
if (mCapture->myDumpList)
{
dumpList (mCaptureList);
}
subscribeToSymbols (mCapture,mCaptureList);
mama_logStdout (MAMA_LOG_LEVEL_NORMAL, "Type CTRL-C to exit.\n\n");
mama_start (mCapture->myBridge);
mamaCapture_closeFile(mCapture->myCapture);
msshutdown (mCapture,mCaptureList);
return 0;
}
示例8: main
int
main(int argc, char **argv) {
struct cmdlineInfo cmdline;
struct pam pam;
int row;
double normalizer;
tuplen * tuplerown;
pnm_init(&argc, argv);
parseCommandLine(argc, argv, &cmdline);
pam.size = sizeof(pam);
pam.len = PAM_STRUCT_SIZE(tuple_type);
pam.file = stdout;
pam.format = PAM_FORMAT;
pam.plainformat = 0;
pam.width = cmdline.width;
pam.height = cmdline.height;
pam.depth = 1;
pam.maxval = cmdline.maxval;
strcpy(pam.tuple_type, cmdline.tupletype);
normalizer = imageNormalizer(&pam, cmdline.sigma);
pnm_writepaminit(&pam);
tuplerown = pnm_allocpamrown(&pam);
for (row = 0; row < pam.height; ++row) {
int col;
for (col = 0; col < pam.width; ++col) {
double const gauss1 = gauss(distFromCenter(&pam, col, row),
cmdline.sigma);
tuplerown[col][0] = gauss1 * normalizer;
}
pnm_writepamrown(&pam, tuplerown);
}
pnm_freepamrown(tuplerown);
return 0;
}
示例9: readCommandFile
void
readCommandFile(
char *name
)
{
char *s, // buffer
**vector; // local versions of arg vector
unsigned count = 0; // count
size_t n;
if (!(file = FILEOPEN(name,"rt")))
makeError(0,CANT_OPEN_FILE,name);
vector = NULL; // no args yet
while (fgets(buf,MAXBUF,file)) {
n = _tcslen(buf);
// if we didn't get the whole line, OR the line ended with a backSlash
if ((n == MAXBUF-1 && buf[n-1] != '\n') ||
(buf[n-1] == '\n' && buf[n-2] == '\\')
) {
if (buf[n-2] == '\\' && buf[n-1] == '\n') {
// Replace \n by \0 and \\ by a space; Also reset length
buf[n-1] = '\0';
buf[n-2] = ' ';
n--;
}
s = makeString(buf);
getRestOfLine(&s,&n);
} else
s = buf;
processLine(s,&count,&vector); // separate into args
if (s != buf)
FREE(s);
}
if (fclose(file) == EOF)
makeError(0, ERROR_CLOSING_FILE, name);
parseCommandLine(count,vector); // evaluate the args
while (count--) // free the arg vector
if(vector[count])
FREE(vector[count]); // NULL entries mean that the space the
} // entry used to pt to is still in use
示例10: main
int
main(int argc, char **argv)
{
struct cmdlineInfo cmdline;
struct pam outpam;
int * jasperCmpt; /* malloc'ed */
/* jaspercmpt[P] is the component number for use with the
Jasper library that corresponds to Plane P of the PAM.
*/
jas_image_t * jasperP;
pnm_init(&argc, argv);
parseCommandLine(argc, argv, &cmdline);
{
int rc;
rc = jas_init();
if ( rc != 0 )
pm_error("Failed to initialize Jasper library. "
"jas_init() returns rc %d", rc );
}
jas_setdbglevel(cmdline.debuglevel);
readJpc(cmdline.inputFilename, &jasperP);
outpam.file = stdout;
outpam.size = sizeof(outpam);
outpam.len = PAM_STRUCT_SIZE(tuple_type);
computeOutputParm(jasperP, &outpam, &jasperCmpt);
pnm_writepaminit(&outpam);
convertToPamPnm(&outpam, jasperP, jasperCmpt);
free(jasperCmpt);
jas_image_destroy(jasperP);
pm_close(stdout);
return 0;
}
示例11: QApplication
AppDelegate::AppDelegate(int argc, char* argv[]) :
QApplication(argc, argv),
_qtReady(false),
_dsReady(false),
_dsResourcesReady(false),
_acReady(false),
_domainServerProcess(NULL),
_acMonitorProcess(NULL),
_domainServerName("localhost")
{
// be a signal handler for SIGTERM so we can stop child processes if we get it
signal(SIGTERM, signalHandler);
// look for command-line options
parseCommandLine();
setApplicationName("Stack Manager");
setOrganizationName("High Fidelity");
setOrganizationDomain("io.highfidelity.StackManager");
QFile* logFile = new QFile("last_run_log", this);
if (!logFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) {
qDebug() << "Failed to open log file. Will not be able to write STDOUT/STDERR to file.";
} else {
outStream = new QTextStream(logFile);
}
qInstallMessageHandler(myMessageHandler);
_domainServerProcess = new BackgroundProcess(GlobalData::getInstance().getDomainServerExecutablePath(), this);
_acMonitorProcess = new BackgroundProcess(GlobalData::getInstance().getAssignmentClientExecutablePath(), this);
_manager = new QNetworkAccessManager(this);
_window = new MainWindow();
createExecutablePath();
downloadLatestExecutablesAndRequirements();
_checkVersionTimer.setInterval(0);
connect(&_checkVersionTimer, SIGNAL(timeout()), this, SLOT(checkVersion()));
_checkVersionTimer.start();
connect(this, &QApplication::aboutToQuit, this, &AppDelegate::stopStack);
}
示例12: main
int main( int argc, const char *argv[] )
{
std::string path;
Json::Features features;
bool parseOnly;
int exitCode = parseCommandLine( argc, argv, features, path, parseOnly );
if ( exitCode != 0 )
{
return exitCode;
}
std::string input = readInputTestFile( path.c_str() );
if ( input.empty() )
{
printf( "Failed to read input or empty input: %s\n", path.c_str() );
return 3;
}
std::string basePath = removeSuffix( argv[1], ".json" );
if ( !parseOnly && basePath.empty() )
{
printf( "Bad input path. Path does not end with '.expected':\n%s\n", path.c_str() );
return 3;
}
std::string actualPath = basePath + ".actual";
std::string rewritePath = basePath + ".rewrite";
std::string rewriteActualPath = basePath + ".actual-rewrite";
Json::Value root;
exitCode = parseAndSaveValueTree( input, actualPath, "input", root, features, parseOnly );
if ( exitCode == 0 && !parseOnly )
{
std::string rewrite;
exitCode = rewriteValueTree( rewritePath, root, rewrite );
if ( exitCode == 0 )
{
Json::Value rewriteRoot;
exitCode = parseAndSaveValueTree( rewrite, rewriteActualPath,
"rewrite", rewriteRoot, features, parseOnly );
}
}
return exitCode;
}
示例13: main
int main(int argc, char **argv) {
try {
std::vector<Common::UString> args;
Common::Platform::getParameters(argc, argv, args);
int returnValue = 1;
Common::UString inFile, outFile;
if (!parseCommandLine(args, returnValue, inFile, outFile))
return returnValue;
desmall(inFile, outFile);
} catch (...) {
Common::exceptionDispatcherError();
}
return 0;
}
示例14: main
int
main(int argc, char * argv[]) {
struct cmdlineInfo cmdline;
FILE * ifP;
xelval lmin, lmax;
gray * lumamap; /* Luminosity map */
unsigned int * lumahist; /* Histogram of luminosity values */
int rows, cols; /* Rows, columns of input image */
xelval maxval; /* Maxval of input image */
int format; /* Format indicator (PBM/PGM/PPM) */
xel ** xels; /* Pixel array */
unsigned int pixelCount;
pnm_init(&argc, argv);
parseCommandLine(argc, argv, &cmdline);
ifP = pm_openr(cmdline.inputFileName);
xels = pnm_readpnm(ifP, &cols, &rows, &maxval, &format);
pm_close(ifP);
computeLuminosityHistogram(xels, rows, cols, maxval, format,
cmdline.gray, &lumahist, &lmin, &lmax,
&pixelCount);
getMapping(cmdline.rmap, lumahist, maxval, pixelCount, &lumamap);
if (cmdline.verbose)
reportMap(lumahist, maxval, lumamap);
remap(xels, cols, rows, maxval, format, !!cmdline.gray, lumamap);
pnm_writepnm(stdout, xels, cols, rows, maxval, format, 0);
if (cmdline.wmap)
writeMap(cmdline.wmap, lumamap, maxval);
pgm_freerow(lumamap);
return 0;
}
示例15: main
int
main(int argc, char ** argv) {
struct cmdlineInfo cmdline;
MS_Ico const MSIconDataP = createIconFile();
unsigned int iconIndex;
unsigned int offset;
ppm_init (&argc, argv);
parseCommandLine(argc, argv, &cmdline);
verbose = cmdline.verbose;
for (iconIndex = 0; iconIndex < cmdline.iconCount; ++iconIndex) {
addEntryToIcon(MSIconDataP, cmdline.inputFilespec[iconIndex],
cmdline.andpgmFilespec[iconIndex],
cmdline.truetransparent);
}
/*
* Now we have to go through and calculate the offsets.
* The first infoheader starts at 6 + count*16 bytes.
*/
offset = (MSIconDataP->count * 16) + 6;
for (iconIndex = 0; iconIndex < MSIconDataP->count; ++iconIndex) {
IC_Entry entry = MSIconDataP->entries[iconIndex];
entry->file_offset = offset;
/*
* Increase the offset by the size of this offset & data.
* this includes the size of the color data.
*/
offset += entry->size_in_bytes;
}
/*
* And now, we have to actually SAVE the .ico!
*/
writeMS_Ico(MSIconDataP, cmdline.output);
free(cmdline.inputFilespec);
free(cmdline.andpgmFilespec);
return 0;
}