1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1998, Vrije Universiteit Amsterdam
5
// Author: Frank Dehne (frank@cs.vu.nl).
7
// TCM is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// TCM is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with TCM; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
////////////////////////////////////////////////////////////////////////////////
22
#include "inputfile.h"
23
#include "outputfile.h"
25
#include "stringlist.h"
26
#include "stringlistnode2.h"
28
StringListNode2::StringListNode2(Graph *g): StringListNode(g) {
29
stringList2 = new List<string *>;
30
stringListLabel2 = "Strings2";
31
stringLabel2 = "String2";
34
StringListNode2::StringListNode2(const StringListNode2 &s): StringListNode(s) {
35
stringList2 = new List<string *>;
36
for (s.stringList2->first(); !s.stringList2->done();
37
s.stringList2->next()) {
38
string *a = s.stringList2->cur();
39
stringList2->add(new string(*a));
41
stringListLabel2 = s.stringListLabel2;
42
stringLabel2 = s.stringLabel2;
45
StringListNode2::~StringListNode2() {
50
bool StringListNode2::HasString2(const string *s) {
51
for (stringList2->first(); !stringList2->done();
52
stringList2->next()) {
53
if (*stringList2->cur() == *s)
59
StringListNode2::StringErrorType StringListNode2::SetString2(
60
const string *s, unsigned n, bool update) {
61
StringList::Insert(stringList2, s, n, update);
62
return StringListNode::STRING_OK;
65
bool StringListNode2::ReadMembers(InputFile *ifile, double format) {
66
if (!StringListNode::ReadMembers(ifile, format))
69
if (!ifile->ReadAttribute(&stringListLabel2, &val))
71
int numItems = val.toint();
72
for (int i=0; i<numItems; i++) {
73
string *at = new string;
74
if (!ifile->ReadStringAttribute(&stringLabel2, at)) {
83
void StringListNode2::WriteMembers(OutputFile *ofile) {
84
StringListNode::WriteMembers(ofile);
85
int numItems = stringList2->count();
86
(*ofile) << "\t{ " << stringListLabel2 << " " << numItems << " }\n";
87
for (int i=0; i<numItems; i++) {
88
(*ofile) << "\t{ " << stringLabel2 << " " << '"'
89
<< *(*stringList2)[i] << '"' << " }\n";