-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathword_tokenizer.cpp
More file actions
27 lines (23 loc) · 837 Bytes
/
Copy pathword_tokenizer.cpp
File metadata and controls
27 lines (23 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include"abstract_tokenizer.h"
#include"word_tokenizer.h"
#include<string>
using namespace std;
/** Default constructor that has strings as params with @param content @param delimites*/
word_tokenizer::word_tokenizer(string content, string delimiters)
:abstract_tokenizer(content, delimiters)
{}
/** Destructor */
word_tokenizer::~word_tokenizer() {}
/**Checks the next token word*/
string word_tokenizer::peekNextToken()
{
size_t pos = 0;
size_t found = getContent().find_first_of(getDelimiters(), pos);
while (pos == found) /*while the current character is still a delimiter*/
{
++pos;
found = getContent().find_first_of(getDelimiters(), pos);
/*increment and check again*/
}
return getContent().substr(pos, found - pos); /*If the character position has skipped ahead, there must be a token we can split and return*/
}