Skip to content

Instantly share code, notes, and snippets.

@MCAR43
Created April 4, 2017 15:16
Show Gist options
  • Select an option

  • Save MCAR43/683977b7e789f9a5aa65d3d60b1d1f5f to your computer and use it in GitHub Desktop.

Select an option

Save MCAR43/683977b7e789f9a5aa65d3d60b1d1f5f to your computer and use it in GitHub Desktop.
void Query::getQuery(){
std::istringstream iss(raw_query);
string selectLine, fromLine, whereLine, tempString, trashString;
int newlineCounter = 0;
int embeddedCounter = 0;
string next;
do{
if(newlineCounter == 0){
std::getline(iss,selectLine, '\n');
std::istringstream selectStream(selectLine);
std::getline(selectStream, next, ' ');
selectStatement.arguments.push_back(next);
while(selectStream >> next){
selectStatement.arguments.push_back(next);
}
}
else if(newlineCounter == 1){
std::getline(iss,fromLine, '\n');
std::istringstream fromStream(fromLine);
std::getline(fromStream, next, ' ');
fromStatement.arguments.push_back(next);
while(fromStream >> next){
fromStatement.arguments.push_back(next);
}
}
else if(newlineCounter == 2){
std::getline(iss,whereLine, '\n');
std::istringstream whereStream(whereLine);
std::getline(whereStream, next, ' ');
whereStatement.arguments.push_back(next);
while(whereStream >> next){
whereStatement.arguments.push_back(next);
}
}
newlineCounter++;
} while(!endOfQuery(next, ';'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment