-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStringType.h
More file actions
52 lines (44 loc) · 1.33 KB
/
Copy pathStringType.h
File metadata and controls
52 lines (44 loc) · 1.33 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
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <stack>
#include <fstream>
#include <time.h>
class StringType{
private:
const char* m_str;
size_t m_size;
public:
StringType() {}
StringType(const char* str, size_t size) : m_str(str),
m_size(size)
{}
StringType(const char* str) : StringType(str, strlen(str))
{}
StringType(std::string str) : StringType(str.c_str(), strlen(str.c_str()))
{}
~StringType() {}
size_t get_size() const{
return m_size;
}
const char* get_str() const{
return m_str;
}
};
class Like
{
private:
StringType pattern;
char escape;
bool ignorecase;
public:
Like(): escape('\\'), ignorecase(false) {}
Like(const StringType& p, char esc = '\\', bool ignore = false): pattern(p), escape(esc), ignorecase(ignore) {}
~Like() {}
bool match(const StringType& str) const;
};
bool like( const StringType& str, const StringType& pattern, char escape = '\\', bool ignorecase = false);
bool str_like(const std::string& m_str, const std::string& m_pattern);
bool stack_like( const StringType& str, const StringType& pattern, char escape = '\\', bool ignorecase = false);
bool stack_str_like(const std::string& m_str, const std::string& m_pattern);