-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathString.hpp
More file actions
84 lines (59 loc) · 2.38 KB
/
String.hpp
File metadata and controls
84 lines (59 loc) · 2.38 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// String.hpp
// Assignment3
//
// Created by rick gessner on 1/29/20.
// Copyright © 2020 rick gessner. All rights reserved.
//
#ifndef String_hpp
#define String_hpp
#include <stdio.h>
#include <iostream>
#include "BufferManager.hpp"
//#include "Searchable.hpp"
//#include "Sortable.hpp"
//It's up to you to decide the how the string and buffermanager
//will work together -- IS_A vs HAS-A.
namespace ECE141 {
template<typename T=char, size_t aPresize=32>
class String {
public:
//add rest of the OCF methods...
String(const char* aBuffer=0); //default ctor
String(const String &aString);
String& operator=(const String &aCopy);
//add version to assign from const char*
size_t size() const {return length;}
//mutation methods...
T& operator[](size_t pos);
String operator+(const String &aString);
//add method to add const char*
//add method to support "hello"+theStringObject
String& operator+=(const String &aString);
//add method to append const char*
String& insert(size_t anIndex, const String &aStr, size_t aStrIndex,
size_t aStrCount);
//add method to insert const char*
String& insert(size_t anIndex, T aChar);
String& replace(size_t anIndex, size_t aMaxCopyLen, const String &aString);
//add method to replace const char*
String& erase(size_t anIndex, size_t aCount);
//Comparision methods...
int compare( const String& aString ) const;
//add method to add compare const char*
bool operator==(const String &aString) const {return true;}
bool operator!=(const String &aString) const {return !(*this==aString);}
bool operator<(const String &aString) const {return false;}
bool operator<=(const String &aString) const {return false;}
bool operator>(const String &aString) const {return false;}
bool operator>=(const String &aString) const {return false;}
//Add version(s) to support const char*...
//Search...
int find( const String &aString, size_t anIndex = 0 );
friend std::ostream& operator << (std::ostream &anOut, const String &aStr);
friend std::istream& operator >> (std::istream &anOut, String &aString);
protected:
size_t length;
};
} //end namespace
#endif /* String_hpp */