Add string split util
This commit is contained in:
parent
5fed47367d
commit
a1873af50d
@ -14,4 +14,9 @@ CodePosition get_node_pos(Node node);
|
|||||||
*/
|
*/
|
||||||
Type string_to_type(string type_name);
|
Type string_to_type(string type_name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splits a string using the provided delimiter
|
||||||
|
*/
|
||||||
|
vector<string> split_string(const string& input, char delimiter);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,3 +1,8 @@
|
|||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "include/utils.h"
|
#include "include/utils.h"
|
||||||
|
|
||||||
CodePosition get_node_pos(Node node) {
|
CodePosition get_node_pos(Node node) {
|
||||||
@ -13,4 +18,16 @@ Type string_to_type(string type_name) {
|
|||||||
return Type::Double;
|
return Type::Double;
|
||||||
|
|
||||||
throw exception();
|
throw exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<string> split_string(const string& input, char delimiter) {
|
||||||
|
vector<string> tokens;
|
||||||
|
string token;
|
||||||
|
istringstream tokenStream(input);
|
||||||
|
|
||||||
|
while (getline(tokenStream, token, delimiter)) {
|
||||||
|
tokens.push_back(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tokens;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user