cfl_symbolset.cpp
Go to the documentation of this file.
1/** @file cfl_symbolset.cpp @brief Class SymbolSet */
2
3/* FAU Discrete Event Systems Library (libfaudes)
4
5 Copyright (C) 2006 Bernd Opitz
6 Copyright (C) 2007 Thomas Moor
7 Exclusive copyright is granted to Klaus Schmidt
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#include "cfl_symbolset.h"
24
25namespace faudes {
26
27// std faudes type
28FAUDES_TYPE_IMPLEMENTATION(SymbolSet,SymbolSet,TBaseSet<std::string>)
29
30
31// SymbolSet()
33 TBaseSet<std::string>()
34{
35 FD_DC("SymbolSet(" << this << ")::SymbolSet()");
36 Name("SymbolSet");
37}
38
39// SymbolSet(rOtherSet)
40SymbolSet::SymbolSet(const SymbolSet& rOtherSet) :
41 TBaseSet<std::string>(rOtherSet)
42{
43 FD_DC("SymbolSet(" << this << ")::SymbolSet(rOtherSet " << &rOtherSet << ")");
44}
45
46// SymbolSet(rOtherSet)
48 TBaseSet<std::string>(rOtherSet)
49{
50 FD_DC("SymbolSet(" << this << ")::SymbolSet(rOtherSet " << &rOtherSet << ")");
51}
52
53// File constructor
54SymbolSet::SymbolSet(const std::string& rFilename, const std::string& rLabel) :
55 TBaseSet<std::string>()
56{
57 FD_DC("SymbolSet(" << this << ")::SymbolSet(" << rFilename << ")");
58 Read(rFilename, rLabel);
59}
60
61// DoCopy
62void SymbolSet::DoCopy(const SymbolSet& rSourceSet) {
64}
65
66
67// DoWrite(rTw&)
68void SymbolSet::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
69 (void) pContext;
70 std::string label=rLabel;
71 if(label=="") label=Name();
72 if(label=="") label="SymbolSet";
73 rTw.WriteBegin(label);
74 Iterator it;
75 // iterate symbols to write
76 for (it = Begin(); it != End(); ++it) {
77 rTw << *it;
78 }
79 rTw.WriteEnd(label);
80}
81
82// DoRead(rTr, rLabel, context)
83void SymbolSet::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
84 std::string label=rLabel;
85 if(label=="") label="SymbolSet";
86 Name(label);
87 Clear();
88 rTr.ReadBegin(label);
89 Token token;
90 while(!rTr.Eos(label)) {
91 rTr.Get(token);
92 // read individual symbol
93 if (token.Type() == Token::String) {
94 FD_DC("SymbolSet(" << this << ")::DoRead(..): inserting symbol \""
95 << token.StringValue() << "\"");
96 // insert element
97 Insert(token.StringValue());
98 continue;
99 }
100 // ignore unknown attributes
101 AttributeVoid attr;
102 attr.Read(rTr);
103 }
104 rTr.ReadEnd(label);
105}
106
107//Insert(symbol)
108bool SymbolSet::Insert(const std::string& symbol) {
109 return TBaseSet<std::string>::Insert(symbol);
110}
111
112
113//Valid(idx)
114bool SymbolSet::Valid(const std::string& symbol) const {
115 return SymbolTable::ValidSymbol(symbol);
116}
117
118
119
120
121} // end name space
#define FD_DC(message)
Class SymbolSet, TaSymbolSet.
#define FAUDES_TYPE_IMPLEMENTATION(ftype, ctype, cbase)
Definition cfl_types.h:1017
const std::string & Name(void) const
TBaseSet< std::string >::Iterator Iterator
void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
bool Insert(const std::string &symbol)
void DoWrite(TokenWriter &tw, const std::string &rLabel="", const Type *pContext=0) const
bool Valid(const std::string &symbol) const
void DoCopy(const SymbolSet &rSource)
static bool ValidSymbol(const std::string &rName)
bool Eos(const std::string &rLabel)
void ReadEnd(const std::string &rLabel)
void ReadBegin(const std::string &rLabel)
bool Get(Token &token)
void WriteEnd(const std::string &rLabel)
void WriteBegin(const std::string &rLabel)
const std::string & StringValue(void) const
@ String
any string, space separated or quoted, must start with a letter
Definition cfl_token.h:86
TokenType Type(void) const
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
virtual bool Insert(const T &rElem)

libFAUDES 2.34d --- 2026.03.11 --- c++ api documentaion by doxygen