-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathString.h
33 lines (33 loc) · 980 Bytes
/
String.h
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
#pragma once
class String
{
char* str;
size_t size;
void free();
void copy(const String& other);
public:
void deleteStr();
String();
String(const char*);
String(const String&);
char operator[](size_t index)const;
size_t getSize() const;
void concat(const String& other);
bool hasSameString(const String nam) const;
bool compareStrings(const String nam) const;
const char* c_str() const;
String& operator=(const String& other);
~String();
};
static bool isValidSymbol(char ch) {
return ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch == ',') || (ch == '.') || (ch == '!') || (ch == ';') || (ch == ':') || (ch == '-') || (ch == '(') || (ch == ')') || (ch == '"') || (ch == ' ') || (ch == '\n') || (ch == '\0'));
}
static bool checkRow(const String row) {
size_t size = row.getSize();
for (size_t i = 0; i < size; i++) {
if (isValidSymbol(row[i]) == 0) {
return 0;
}
}
return 1;
}