-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabstract_tokenizer.cpp
More file actions
40 lines (31 loc) · 1.13 KB
/
Copy pathabstract_tokenizer.cpp
File metadata and controls
40 lines (31 loc) · 1.13 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<string>
#include<iostream>
#include "abstract_tokenizer.h"
using namespace std;
/** Constructor wtih @param content and @param delimiters */
abstract_tokenizer::abstract_tokenizer(string content, string delimiters)
: content(content), delimiters(delimiters)
{}
/** Default destructor*/
abstract_tokenizer::~abstract_tokenizer() { }
/** Function that returns the content string*/
const string abstract_tokenizer::getContent() const { return content; }
/** Function that returns the delimiters as strings*/
const string abstract_tokenizer::getDelimiters() const { return delimiters; }
/** Function that sets the content of the tokenizer , @param content */
void abstract_tokenizer::setContent(string cont) { content = cont; }
/** Function that checks if there is another token to split in the structure*/
bool abstract_tokenizer::hasNextToken()
{
if (peekNextToken() == "")
return false;
return true;
}
/** Function that checkes for next token */
string abstract_tokenizer::nextToken()
{
string token = peekNextToken();
size_t pos = getContent().find(token, 0);
setContent(getContent().substr(pos + token.length()));
return token;
}