-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtilities.cpp
More file actions
66 lines (54 loc) · 1.21 KB
/
Copy pathUtilities.cpp
File metadata and controls
66 lines (54 loc) · 1.21 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <sstream>
#include <string>
#include "Utilities.h"
using namespace std;
namespace sdds
{
char Utilities::m_delimiter = ',';
void Utilities::setFieldWidth(size_t newWidth)
{
m_widthField = newWidth;
}
size_t Utilities::getFieldWidth() const
{
return m_widthField;
}
//"apple,orange,banana,kiwi,strawberry,yellow watermellon"
std::string Utilities::extractToken(const std::string& str, size_t& next_pos, bool& more)
{
std::string token{};
more = false;
if (next_pos < str.length())
{
if (str[next_pos] == m_delimiter)
{
more = false;
throw "Delimiter Found";
}
token = str.substr(next_pos, str.length()); //token = apple,......,yellow watermelon
stringstream ss(token);
if (getline(ss, token, m_delimiter)) //token = apple
{
if (token.length() > m_widthField)
{
m_widthField = token.length();
}
next_pos += (token.length() + 1);
if (next_pos < str.length())
{
more = true;
}
}
}
return token;
}
void Utilities::setDelimiter(char newDelimiter)
{
m_delimiter = newDelimiter;
}
char Utilities::getDelimiter()
{
return m_delimiter;
}
}