filters

listelement.cpp
1/*
2** A program to convert the XML rendered by KWord into LATEX.
3**
4** Copyright (C) 2000 Robert JACOLIN
5**
6** This library is free software; you can redistribute it and/or
7** modify it under the terms of the GNU Library General Public
8** License as published by the Free Software Foundation; either
9** version 2 of the License, or (at your option) any later version.
10**
11** This library is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14** Library General Public License for more details.
15**
16** To receive a copy of the GNU Library General Public License, write to the
17** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19**
20*/
21
22#include <kdebug.h> /* for kdDebug stream */
23#include "listelement.h"
24
25/*******************************************/
26/* Constructor */
27/*******************************************/
28ListElement::ListElement()
29{
30 _start = 0;
31 _end = 0;
32 _size = 0;
33}
34
35/*******************************************/
36/* Destructor */
37/*******************************************/
38ListElement::~ListElement()
39{
40 Element *elt = 0;
41 kdDebug(30522) << "Destruction of a list of elements" << endl;
42 while(_start != 0)
43 {
44 elt = _start;
45 _start = _start->getNext();
46 delete elt;
47 _size = _size - 1;
48 }
49}
50
51/*******************************************/
52/* Initialiser */
53/*******************************************/
54void ListElement::initialiser(Element *elt)
55{
56 _end = _start = elt;
57}
58
59
60/*******************************************/
61/* add */
62/*******************************************/
63void ListElement::add(Element *elt)
64{
65 if(_start == 0)
66 {
67 initialiser(elt);
68 _size = 1;
69 }
70 else
71 {
72 _end->setNext(elt);
73 _end = elt;
74 _size = _size + 1;
75 }
76}
77
This class is a element.