Documentation.
[qshowdiff.git] / text.cpp
blob6972e7350d04b4d15e7d18259cbb5f21e5190db4
1 #include "text.h"
2 using namespace std;
4 Text::Text(const Text &t)
6 copy(t);
9 Text::~Text()
11 free();
14 Text & Text::operator=(const Text &t)
16 free();
17 copy(t);
18 return *this;
21 bool Text::operator==(const Text &t) const
23 if (_text.size() != t._text.size())
24 return false;
26 // _text and t._text has same length so no t._text.end() is needed
27 vector<QString *>::const_iterator it = _text.begin();
28 vector<QString *>::const_iterator it_end = _text.end();
29 vector<QString *>::const_iterator it2 = t._text.begin();
31 for (;it != it_end; it++, it2++){
32 if (**it != **it2)
33 return false;
36 return true;
39 void Text::addLine(QString *qs)
41 _text.push_back(qs);
45 Text::iterator Text::begin() const
47 iterator iter;
48 iter.it = _text.begin();
49 return iter;
52 Text::iterator Text::end() const
54 iterator iter;
55 iter.it = _text.end();
56 return iter;
60 //private:
61 void Text::free()
63 vector<QString *>::const_iterator it = _text.begin();
64 vector<QString *>::const_iterator it_end = _text.end();
66 for(;it != it_end; it++){
67 delete *it;
69 _text.clear();
72 void Text::copy(const Text &t)
74 vector<QString *>::const_iterator it = t._text.begin();
75 vector<QString *>::const_iterator it_end = t._text.end();
77 for (;it != it_end; it++){
78 _text.push_back(new QString(**it));