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 "stringlistedge.h"
28
StringListEdge::StringListEdge(Graph *g, Subject *n1, Subject *n2):
30
stringList = new List<string *>;
31
stringListLabel = "Strings";
32
stringLabel = "String";
35
StringListEdge::StringListEdge(const StringListEdge &s): Edge(s) {
36
stringList = new List<string *>;
37
for (s.stringList->first(); !s.stringList->done();
38
s.stringList->next()) {
39
string *a = s.stringList->cur();
40
stringList->add(new string(*a));
42
stringListLabel = s.stringListLabel;
43
stringLabel = s.stringLabel;
46
StringListEdge::~StringListEdge() {
51
StringListEdge::StringErrorType StringListEdge::SetString(
52
const string *s, unsigned n, bool update) {
53
StringList::Insert(stringList, s, n, update);
54
return StringListEdge::STRING_OK;
57
bool StringListEdge::HasString(const string *s) {
58
for (stringList->first(); !stringList->done();
60
if (*stringList->cur() == *s)
66
bool StringListEdge::ReadMembers(InputFile *ifile, double format) {
67
if (!Edge::ReadMembers(ifile, format))
70
if (!ifile->ReadAttribute(&stringListLabel, &val))
72
int numItems = val.toint();
73
for (int i=0; i<numItems; i++) {
74
string *at = new string;
75
if (!ifile->ReadStringAttribute(&stringLabel, at)) {
84
void StringListEdge::WriteMembers(OutputFile *ofile) {
85
Edge::WriteMembers(ofile);
86
int numItems = stringList->count();
87
(*ofile) << "\t{ " << stringListLabel << " " << numItems << " }\n";
88
for (int i=0; i<numItems; i++) {
89
(*ofile) << "\t{ " << stringLabel << " " << '"'
90
<< *(*stringList)[i] << '"' << " }\n";