forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_utils.h
More file actions
32 lines (23 loc) · 937 Bytes
/
string_utils.h
File metadata and controls
32 lines (23 loc) · 937 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
#ifndef LFORTRAN_STRING_UTILS_H
#define LFORTRAN_STRING_UTILS_H
#include <string>
#include <vector>
#include <cctype>
#include <libasr/alloc.h>
namespace LFortran
{
bool startswith(const std::string &s, const std::string &e);
bool endswith(const std::string &s, const std::string &e);
std::string to_lower(const std::string &s);
std::vector<std::string> split(const std::string &s);
std::string join(const std::string j, const std::vector<std::string> &v);
std::vector<std::string> slice(const std::vector<std::string> &v,
int start=0, int end=-1);
char *s2c(Allocator &al, const std::string &s);
// Replaces all occurrences of `regex` (a regular expression, must escape
// special characters) with `replace`
std::string replace(const std::string &s,
const std::string ®ex, const std::string &replace);
std::string read_file(const std::string &filename);
} // namespace LFortran
#endif // LFORTRAN_STRING_UTILS_H