-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformatting.cpp
More file actions
37 lines (33 loc) · 978 Bytes
/
formatting.cpp
File metadata and controls
37 lines (33 loc) · 978 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
28
29
30
31
32
33
34
35
36
37
/*
* SET07109 Coursework 2: Implementing a compiler symbol table (Part A) / Implementing a binary search tree (Part B)
* -----------------------------------------------------------------------------------------------------------------
* implementation functions for formatting.hpp
* author: Vinh Phat Tu (40507973)
* last date of modification: April 2021
*/
#include "formatting.hpp"
#include <sstream>
using namespace std;
/*
* Function: line_split
* --------------------
* splits a string into tokens using a single delimiter
*
* parameters:
* - str: string to be split
* - chr: delimiter
*
* returns: vector<string>
* - vector of tokens
*/
vector<string> string_split(const string &str, const char chr)
{
vector<string> tokens;
stringstream line_stream(str);
string temp;
while(getline(line_stream,temp, chr))
{
tokens.push_back(temp);
}
return tokens;
}