Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const string ParseEvent(istream& input_stream) {
- string event;
- string raw_event;
- getline(input_stream, raw_event);
- for (auto it = raw_event.begin(); it != raw_event.end(); it++){
- if (event.size() == 0){
- if (*it == ' ') {
- continue;
- }
- else if (
- *it == '"' and *(prev(raw_event.end())) != '"'
- ){
- continue;
- }
- else {
- event += *it;
- }
- }
- else if (event.size() == 1 and it != prev(raw_event.end())){
- if (
- *it == ' ' and event[0] == '"'
- ){
- continue;
- }
- else if (
- *it == ' ' and *(next(it)) == ' '
- ){
- continue;
- }
- else {
- event += *it;
- }
- }
- else if (event.size() > 1 and next(it) != prev(raw_event.end()) and it != prev(raw_event.end())){
- if (
- *it == ' ' and *(next(it)) == ' '
- ){
- continue;
- }
- else {
- event += *it;
- }
- }
- else if (next(it) == prev(raw_event.end())){
- if (*it == ' ' and *prev(raw_event.end()) == '"') {
- continue;
- } else if (*it == ' ' and *prev(raw_event.end()) == ' '){
- continue;
- } else {
- event += *it;
- }
- }
- else if (it == prev(raw_event.end())){
- if (*it == '"' and event[0] != '"') {
- continue;
- } else if (*it == ' '){
- continue;
- } else {
- event += *it;
- }
- }
- }
- return event;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement