1 #ifndef _DATA_FILE_SEGMENT_H_ 2 #define _DATA_FILE_SEGMENT_H_ 50 this->offset = offset;
51 this->length = length;
82 assert((length - count) >= 0);
99 assert((length - count) >= 0);
113 return ((offset + length) == segment.
offset);
118 return ((offset == segment.
offset) && (length == segment.
length));
123 return ((offset != segment.
offset) || (length != segment.
length));
128 return (stream & offset & length);
133 out <<
"[" << segment.
offset <<
":" << segment.
length <<
"]";
static const FileSegment Null
Identifies a null segment, with the offset as well as the length set to zero.
Definition: file_segment.h:31
FileSegment(uint64_t offset, uint64_t length)
Initializes the segment with the given parameters.
Definition: file_segment.h:48
bool operator==(const FileSegment &segment) const
Definition: file_segment.h:116
Contains a set of classes to easy the handling of data and files, as well as the serialization.
Definition: data.h:9
Identifies a data segment of a file.
Definition: file_segment.h:20
virtual ~FileSegment()
Definition: file_segment.h:137
FileSegment & RemoveFirst(int count)
Removes the first bytes of the segment.
Definition: file_segment.h:80
bool operator!=(const FileSegment &segment) const
Definition: file_segment.h:121
uint64_t offset
Offset of the data segment.
Definition: file_segment.h:23
FileSegment()
Initializes all the member variables with zero, being a null segment.
Definition: file_segment.h:38
FileSegment & RemoveLast(int count)
Removes the last bytes of the segment.
Definition: file_segment.h:97
T & SerializeWith(T &stream)
Definition: file_segment.h:126
bool IsContiguousTo(const FileSegment &segment) const
Returns true if the segment is contiguous to another given segment, so the first byte of the given se...
Definition: file_segment.h:111
FileSegment(const FileSegment &segment)
Copy constructor.
Definition: file_segment.h:57
ostream & operator<<(ostream &out, const Request &request)
Definition: request.cc:65
uint64_t length
Length of the data segment.
Definition: file_segment.h:24
FileSegment & operator=(const FileSegment &segment)
Copy assignment.
Definition: file_segment.h:65