7 #ifndef FRAGMENT_CONTENTS_H 8 #define FRAGMENT_CONTENTS_H 34 std::vector<fragment_line> v;
42 typedef std::vector<fragment_line>::iterator ittype;
44 fragment_lines *lines;
48 iterator(fragment_lines *_lines,
const ittype &_i)
53 :lines(other.lines), i(other.i)
58 iterator &operator++() { ++i;
return *
this; }
59 iterator &operator--() { --i;
return *
this; }
61 fragment_line &operator*() {
return *i; }
62 fragment_line *operator->() {
return &*i; }
65 other.lines->incref();
73 bool operator==(
const iterator &other)
const {
return i==other.i;}
74 bool operator!=(
const iterator &other)
const {
return i!=other.i;}
81 typedef std::vector<fragment_line>::const_iterator ittype;
83 const fragment_lines *lines;
92 :lines(other.lines), i(other.i)
96 :lines(other.lines), i(other.i)
104 const fragment_line &operator*() {
return *i; }
105 const fragment_line *operator->() {
return &*i; }
108 other.lines->incref();
117 other.lines->incref();
125 bool operator==(
const iterator &other)
const {
return i==other.i;}
126 bool operator==(
const const_iterator &other)
const {
return i==other.i;}
128 bool operator!=(
const iterator &other)
const {
return i!=other.i;}
129 bool operator!=(
const const_iterator &other)
const {
return i!=other.i;}
132 fragment_lines():refs(0) {}
134 void incref()
const {++refs;}
135 void decref()
const {--refs;
if(refs==0)
delete this;}
137 void push_back(
const fragment_line &l) {v.push_back(l);}
145 fragment_line &front() {
return v.front();}
146 const fragment_line &front()
const {
return v.front();}
148 fragment_line &back() {
return v.back();}
149 const fragment_line &back()
const {
return v.back();}
151 fragment_line &operator[](
int i) {
return v[i]; }
152 const fragment_line &operator[](
int i)
const {
return v[i]; }
154 size_t size()
const {
return v.size();}
166 :lines(other.lines), final_nl(other.final_nl)
174 void push_back(
const fragment_line &l) {lines->push_back(l);}
176 iterator begin() {
return lines->begin();}
177 const_iterator begin()
const {
return lines->begin();}
179 iterator end() {
return lines->end();}
180 iterator end()
const {
return lines->end();}
182 fragment_line &front() {
return lines->front();}
183 const fragment_line &front()
const {
return lines->front();}
185 fragment_line &back() {
return lines->back();}
186 const fragment_line &back()
const {
return lines->back();}
188 size_t size()
const {
return lines->size();}
190 void set_final_nl(
bool final_nl_new) {final_nl=final_nl_new;}
192 bool get_final_nl() {
return final_nl;}
194 fragment_line &operator[](
int i) {
return (*lines)[i]; }
195 const fragment_line &operator[](
int i)
const {
return (*lines)[i]; }
199 other.lines->incref();
203 final_nl=other.final_nl;
210 fragment_lines *lines;
This class represents the formatted contents of a fragment.
Definition: fragment_contents.h:30
fragment_contents()
Generate empty contents for a fragment.
Definition: fragment_contents.h:161
Definition: fragment_contents.h:40
~fragment_contents()
When this is destroyed, decrement the lines' reference count.
Definition: fragment_contents.h:172
fragment_contents(const fragment_contents &other)
Copy constructor.
Definition: fragment_contents.h:165
Definition: fragment_contents.h:79