3#ifndef STREAMBASE_TUPLE_LIST_H
4#define STREAMBASE_TUPLE_LIST_H
44 size_t size()
const {
return getSize(); }
50 void resize(
size_t size) { setSize(size); }
51 void setSize(
size_t size);
60 bool empty()
const {
return size() == 0; }
64 const Tuple& operator[] (
size_t index)
const;
67 Tuple& operator[] (
size_t index);
75 const Tuple& back()
const;
79 typedef std::vector<Tuple>::iterator iterator;
80 typedef std::vector<Tuple>::const_iterator const_iterator;
86 const_iterator begin()
const;
87 const_iterator end()
const;
91#ifndef DOXYGEN_INTERNAL_ONLY
104 size_t copyIntoBuffer(
char* buf,
size_t len,
bool byteswap)
const;
105 static TupleList createFromPackedBuffer(
size_t* size_used,
106 const char* buf,
size_t buf_len,
bool byteswap,
const Schema& s,
107 size_t expect_num_tuples = (
size_t)-1);
108 static TupleList createRawFromPackedBuffer(
size_t* size_used,
109 const char* buf,
size_t buf_len,
bool byteswap,
const Schema& s,
110 size_t expect_num_tuples = (
size_t)-1);
112 const std::string getRawBits()
const {
return _->rawBits; }
113 void setRawBits(
const char *bits,
const size_t len) { _->rawBits.assign(bits, len); }
122 struct TupleListPrivateImpl {
124 std::vector<Tuple> tuples;
127 TupleListPrivateImpl() { }
128 TupleListPrivateImpl(
const TupleListPrivateImpl& t) :
129 schema(t.schema), tuples(t.tuples), rawBits(t.rawBits) { }
132 std::shared_ptr<TupleListPrivateImpl> _;
137 void ensureAllocated()
const;
142inline std::ostream& operator << (std::ostream& os,
const sb::TupleList& tl) {
A type of tuple, containing zero or more fields (each encapsulated as a Schema::Field object).
Definition: Schema.hpp:62
TupleLists are value types that can be copied and modified seperately thus.
Definition: TupleList.hpp:17
std::string as_string() const
Return a human-readable string value representing this list in its entirety (including all header val...
TupleList(const Schema &schema, size_t size=0)
Create tuple list with an initial size of size
TupleList(const TupleList &list)
Create tuple list from a tuplelist.
void clear()
clear the list
Definition: TupleList.hpp:57
iterator begin()
STL compatible iterators.
void setSchema(const Schema &schema)
set the schema for this list (also setting the schema for any tuples in the list)
void push_back(const Tuple &r)
append a tuple to the list
size_t getSize() const
Get the number of tuples in the list.
const Schema & getSchema() const
Get the schema.
TupleList(const Tuple &tuple)
Create tuple list from a single tuple.
Tuple & back()
return the last tuple in the list
bool empty() const
Is the list empty?
Definition: TupleList.hpp:60
void resize(size_t size)
Change the size of the list any new tuples will be entirely null.
Definition: TupleList.hpp:50
TupleList()
Default (null) constructor.
Tuples are value types that can be copied and modified separately thus.
Definition: Tuple.hpp:47