本文整理汇总了C++中parseInput函数的典型用法代码示例。如果您正苦于以下问题:C++ parseInput函数的具体用法?C++ parseInput怎么用?C++ parseInput使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseInput函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertKeystroke
bool ofxGuiInputField<Type>::keyPressed(ofKeyEventArgs & args){
if(hasFocus && !bMousePressed){
int newCursorIdx = -1;
if(args.key >= '0' && args.key <= '9'){
int digit = args.key - '0';
newCursorIdx = insertKeystroke(ofToString(digit));
}else if(args.key == '.' ){
newCursorIdx = insertKeystroke(".");
}else if(args.key == OF_KEY_BACKSPACE || args.key == OF_KEY_DEL){
if(hasSelectedText()){
input.erase(selectStartPos,selectEndPos-selectStartPos);
newCursorIdx = selectStartPos;
parseInput();
}else{
int deleteIdx = -1;
if(args.key == OF_KEY_BACKSPACE){
deleteIdx = selectStartPos-1;
}else if(args.key == OF_KEY_DEL){
deleteIdx = selectStartPos;
}
//erase char if valid deleteIdx
if(deleteIdx >= 0 && deleteIdx < (int)input.size()){
input.erase(deleteIdx,1);
newCursorIdx = deleteIdx;
parseInput();
}
}
}else if(args.key == OF_KEY_LEFT){
if(hasSelectedText()){
newCursorIdx = selectStartPos;
}else{
newCursorIdx = selectStartPos == 0 ? 0 : selectStartPos-1;
}
}else if(args.key == OF_KEY_RIGHT){
if(hasSelectedText()){
newCursorIdx = selectEndPos;
}else{
newCursorIdx = selectStartPos == (int)input.size() ? (int)input.size() : selectStartPos+1;
}
}else if(args.key == OF_KEY_RETURN){
leaveFocus();
}else if((args.key >= '!' && args.key <= '~')
|| (args.key <= 'a' && args.key >= 'Z')
|| (args.key == ' ')){
newCursorIdx = insertAlphabetic(ofToString((char)args.key));
}
if(newCursorIdx != -1){
//set cursor
calculateSelectionArea(newCursorIdx,newCursorIdx);
}
return true;
}
return false;
}
示例2: switch
void interaction::takeAction() {
int status;
switch((status=parseInput())) {
case QUIT:
quit();
break;
case HELP:
help();
break;
case ME:
traceMe();
break;
case FNAME:
traceFname();
break;
case IPHOST:
traceIpHost(ipHostFname);
break;
case INVLD:
invalid();
break;
default:
break;
}
}
示例3: throw
Engine::Engine(std::string inputFileName, unsigned int baseTicks) throw (std::string)
{
this->baseTicks = baseTicks;
// set parse error message
std::stringstream parseErrorStream;
parseErrorStream << "Was not able to parse File." << std::endl << "Please check if syntax is valid"
<< std::endl << "Abborting ...." << std::endl;
parseError = parseErrorStream.str();
// Try to open File
inputFile = new std::ifstream(inputFileName.c_str(), std::ifstream::in);
// Check if File was opened succesfull
if (!*inputFile)
{
std::stringstream error;
error << "Was not able to open File." << std::endl << "Please check if File exists"
<< std::endl << "Abborting ...." << std::endl;
throw error.str();
}
// Parse Input
try
{
parseInput();
}
catch (std::string error)
{
throw error;
}
}
示例4: main
int main(void)
{
char connect_param[200];
sprintf(connect_param,
"host=csl2.cs.technion.ac.il dbname=%s user=%s password=%s",
USERNAME, USERNAME, PASSWORD);
conn = PQconnectdb(connect_param);
/* check to see that the backend connection was successfully made */
if (!conn || PQstatus(conn) == CONNECTION_BAD)
{
fprintf(stderr, "Connection to server failed: %s\n",
PQerrorMessage(conn));
PQfinish(conn);
return 1;
}
parseInput();
/* Close the connection to the database and cleanup */
PQfinish(conn);
return 0;
}
示例5: main
int main()
{
while(loop == 0)
{
// Gets the current working directory for the application and prints it out
char currDir[256];
getcwd(currDir, 255);
fprintf(stdout, "%s\n", currDir);
fgets(input, buffer, stdin);
// Get a list of all the commands to be run
cmdTok = strtok(input, &delim);
numCmd = 1;
while(cmdTok)
{
cmdArray = realloc (cmdArray, sizeof (char*) * numCmd);
if(cmdTok[strlen(cmdTok)-1] == '\n')
cmdTok[strlen(cmdTok)-1] = '\0';
cmdArray[numCmd-1] = cmdTok;
numCmd++;
cmdTok = strtok(NULL, &delim);
}
// Run all the commands (This didn't work for me in the one loop for some reason)
for(i = 0; i < numCmd-1; i++)
{
parseInput(cmdArray[i]);
}
}
return 0;
}
示例6: startDemon
void startDemon() {
DWIFIClose();
sleep(500);
DWIFITCPOpenServer(80);
RS485clearRead();
parseInput();
}
示例7: parseAssign
/*** Parse a statement ***/
Node* Parser::parseStatement()
{
if(hasTokens(2) && peekToken().getType() == T_IDENTIFIER && peekToken(2).getType() == T_ASSIGN)
return parseAssign();
if(hasTokens(2) && peekToken().getType() == T_IDENTIFIER && peekToken(2).getType() == T_LPAREN)
return parseCall();
if(hasTokens() && peekToken().getType() == T_CALL)
return parseCall();
if(hasTokens() && peekToken().getType() == T_CASE)
return parseCase();
if(hasTokens() && peekToken().getType() == T_DO)
return parseDo();
if(hasTokens() && peekToken().getType() == T_END)
return parseEnd();
if(hasTokens() && peekToken().getType() == T_EXIT)
return parseExit();
if(hasTokens() && peekToken().getType() == T_FOR)
return parseFor();
if(hasTokens() && peekToken().getType() == T_IF)
return parseIf();
if(hasTokens() && peekToken().getType() == T_INPUT)
return parseInput();
if(hasTokens() && peekToken().getType() == T_OUTPUT)
return parseOutput();
if(hasTokens() && peekToken().getType() == T_REPEAT)
return parseRepeat();
if(hasTokens() && peekToken().getType() == T_RETURN)
return parseReturn();
if(hasTokens(2) && peekToken(1).getType() == T_IDENTIFIER && peekToken(2).getType() == T_LBRACKET)
return parseSliceSelectAssign();
if(hasTokens() && peekToken().getType() == T_WHILE)
return parseWhile();
throw ParserSyntaxException(getToken(), "Invalid statement!");
return 0;
}
示例8: readBlocksFile
//Read the blocks file
int readBlocksFile() {
FILE* fp;
char line[256];
int blockIndex = 0;
//if fp is null, display error
fp = fopen("Blocks.txt", "r");
if(fp == NULL){
perror("[ERROR]");
return 0;
} else {
//loop through each line (ignoring text at beginning) and store relevant information
while(fgets(line, 300, fp) != NULL) {
if(line[0] == '#' || line[0] == ' ' || line[0] == '\n'){ continue; }
else {
parseInput(line, blockIndex);
blockIndex++;
}
}
fclose(fp);
return blockIndex;
}
}
示例9: main
/* Note: When a single t is given, we assume R = r
*/
int main(void)
{
int T, input[MAX_NUM_INPUT], numInput;
char line[MAX_LEN_LINE + 1];
double R, r;
scanf("%d", &T);
gets(line);
while(T)
{
gets(line);
numInput = parseInput(line, input);
if(numInput == 1)
{
R = input[0] / 4.0;
r = R;
}
else
{
R = (double) input[0];
r = (double) input[1];
}
printf("%.4lf\n", computeCircleArea(R + r)
- computeCircleArea(R)
- computeCircleArea(r));
T--;
}
return 0;
}
示例10: acceptInput
void acceptInput() {
char line[256];
char input[256];
char request[256];
char response[256];
// infinite loop
while(1) {
// display prompt
fputs(">> ", stderr);
// accept input
fgets(line, sizeof line, stdin);
sscanf(line, "%s", input);
// if input is "exit"
if(strcmp(input, "exit") == 0)
exit(0); // quit program
else {
fprintf(stdout, "String Entered %s, Characters read : %d\n", input, strlen(line) - 1);
parseInput(input, request);
submitRequest(request);
acceptResponse(response);
parseResponse(response);
}
}
}
示例11: shellLoop
void shellLoop()
{
char *input, *originalInput;
TokenContainer tc;
bool running = true;
while(running)
{
printf(YELLOW "λ mini437sh-JG-DS: " NORMAL_COLOR);
input = getInput();
originalInput = malloc(strlen(input) + 1);
strcpy(originalInput, input);
tc = parseInput(input);
if (!emptyInput(&tc))
{
if (exitRequested(&tc))
running = false;
else
{
running = launchCommands(&tc, originalInput);
}
}
free(input);
free(originalInput);
}
killChildren();
free(tc.tokens);
}
示例12: getArgument
void
ManagerFilter::buildInitialWork()
{
// Get Params and Read Graph
int numVertices;
string graphFile = getArgument("n");
parseInput(graphFile, edges, numVertices);
this->gamma = atof(getArgument("g").c_str());
this->minQCSize = atoi(getArgument("q").c_str());
// Initially, all vertices ar in candExt
Candidate start;
for (int i = 1; i <= numVertices; i++) {
start.candExt.insert(i);
}
// Remove vertices that obviously are not candidates
int min = (int) ceil(gamma*(minQCSize-1));
IntSet::iterator it = start.candExt.begin();
while (it != start.candExt.end()) {
IntSet::iterator aux = it;
it++;
if (edges[*aux].size() < min) {
start.candExt.erase(aux);
}
}
// Add it as new work
workQueue.push(start);
}
示例13: searchInput
void searchInput(const char *flastok, const char *fhit)
{
MFILE *mfbuf=mfopen();
const char *input, *ta, *hit, *select, *end, *test;
hit=flastok;
do{
input=strstr(hit, "<input");
ta=strstr(hit, "<textarea");
select=strstr(hit, "<select");
hit=(char*)0x8FFFFFFF;
if(input!=NULL && input<hit) hit=input;
if(ta!=NULL && ta<hit) hit=ta;
if(select!=NULL && select < hit) hit=select;
if(hit!=(char*)0x8FFFFFFF && hit<fhit){
end=strchr(hit, '>');
test=strchr(hit+1, '<');
if(test!=NULL && test<end) end=strchr(end+1, '>');
mfSetLength(mfbuf, 0);
mfwrite((void*)hit+1, 1, end-hit-1, mfbuf);
printf("Input: %s\n", mfGetData(mfbuf));
parseInput(mfGetData(mfbuf));
hit++;
}
}while(hit!=(char*)0x8FFFFFFF && hit<fhit);
mfclose(mfbuf);
}
示例14: QWidget
SodController::SodController(QWidget* parent)
: QWidget(parent)
{
input = new CLineEdit(this);
output = new QPlainTextEdit(this);
commandPos = 0;
historySize = 300;
connect(input, SIGNAL(returnPressed()), this, SLOT(parseInput()) );
connect(input, SIGNAL(arrowPressed(bool)), this, SLOT(repeatCommand(bool)) );
QVBoxLayout* mainBox = new QVBoxLayout(this);
mainBox->addWidget(output);
mainBox->addWidget(input);
// and the set of general functions
general_functions["read_distances"] = &SodController::read_distances;
general_functions["read_positions"] = &SodController::read_positions;
general_functions["read_annotation"] = &SodController::read_annotation;
general_functions["shrink_dims"] = &SodController::shrink_dims;
general_functions["set_plot_par"] = &SodController::set_plot_par;
general_functions["titrate"] = &SodController::titrate;
general_functions["gaussian_bg"] = &SodController::make_gaussian_background;
general_functions["export_points"] = &SodController::export_points;
general_functions["export_positions"] = &SodController::export_positions;
general_functions["postscript"] = &SodController::postscript;
general_functions["draw_grid"] = &SodController::drawGrid;
}
示例15: parseInput
progC::progC(std::ifstream& infile){
//infile.open("file1");
parseInput(infile);
}