-
Notifications
You must be signed in to change notification settings - Fork 246
/
StrBlob.h
58 lines (43 loc) · 1.21 KB
/
StrBlob.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
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
#ifndef STRBLOB_H
#define STRBLOB_H
class StrBlobPtr;
class ConstStrBlobPtr;
#include <vector>
#include <string>
#include <initializer_list>
#include <memory>
#include <iostream>
class StrBlob {
friend class StrBlobPtr;
friend class ConstStrBlobPtr;
public:
typedef std::vector<std::string>::size_type size_type;
StrBlob();
StrBlob(std::initializer_list<std::string> il);
StrBlob(const StrBlob &);
StrBlob &operator=(const StrBlob &);
size_type size() const { return data->size(); }
bool empty() const { return data->empty(); }
void push_back(const std::string &s);
void push_back(std::string &&s);
void pop_back();
std::string &front();
const std::string &front() const;
std::string &back();
const std::string &back() const;
StrBlobPtr begin();
StrBlobPtr end();
ConstStrBlobPtr cbegin() const;
ConstStrBlobPtr cend() const;
private:
std::shared_ptr<std::vector<std::string>> data;
void check(size_type pos, const std::string &msg) const;
};
inline void StrBlob::push_back(const std::string &s) {
data->push_back(s);
}
inline void StrBlob::push_back(std::string &&s) {
std::cout << "StrBlob::push_back(std::string &&s)" << std::endl;
data->push_back(std::move(s));
}
#endif