-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathTuple.cpp
53 lines (42 loc) · 912 Bytes
/
Tuple.cpp
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
#include <db/Tuple.h>
using namespace db;
//
// Tuple
//
Tuple::Tuple(const TupleDesc &td, RecordId *rid) : td(td), rid(rid) {
fields.resize(td.numFields());
}
const TupleDesc &Tuple::getTupleDesc() const {
return td;
}
const RecordId *Tuple::getRecordId() const {
return rid;
}
void Tuple::setRecordId(const RecordId *id) {
rid = id;
}
const Field &Tuple::getField(int i) const {
return *fields[i];
}
void Tuple::setField(int i, const Field *f) {
fields[i] = f;
}
Tuple::iterator Tuple::begin() const {
return fields.begin();
}
Tuple::iterator Tuple::end() const {
return fields.end();
}
std::string Tuple::to_string() const {
std::string s;
auto it = fields.begin();
if (it != fields.end()) {
s += (*it)->to_string();
++it;
}
while (it != fields.end()) {
s += ", " + (*it)->to_string();
++it;
}
return s;
}