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)
41 TBaseSet<std::string>(rOtherSet)
42{
43 FD_DC("SymbolSet(" << this << ")::SymbolSet(rOtherSet " << &rOtherSet << ")");
44}
45
46// File constructor
47SymbolSet::SymbolSet(const std::string& rFilename, const std::string& rLabel) :
48 TBaseSet<std::string>()
49{
50 FD_DC("SymbolSet(" << this << ")::SymbolSet(" << rFilename << ")");
51 Read(rFilename, rLabel);
52}
53
54// DoAssign
55void SymbolSet::DoAssign(const SymbolSet& rSourceSet) {
57}
58
59
60// DoWrite(rTw&)
61void SymbolSet::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
62 (void) pContext;
63 std::string label=rLabel;
64 if(label=="") label=Name();
65 if(label=="") label="SymbolSet";
66 rTw.WriteBegin(label);
67 Iterator it;
68 // iterate symbols to write
69 for (it = Begin(); it != End(); ++it) {
70 rTw << *it;
71 }
72 rTw.WriteEnd(label);
73}
74
75// DoRead(rTr, rLabel, context)
76void SymbolSet::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
77 std::string label=rLabel;
78 if(label=="") label="SymbolSet";
79 Name(label);
80 Clear();
81 rTr.ReadBegin(label);
82 Token token;
83 while(!rTr.Eos(label)) {
84 rTr.Get(token);
85 // read individual symbol
86 if (token.Type() == Token::String) {
87 FD_DC("SymbolSet(" << this << ")::DoRead(..): inserting symbol \""
88 << token.StringValue() << "\"");
89 // insert element
90 Insert(token.StringValue());
91 continue;
92 }
93 // ignore unknown attributes
94 AttributeVoid attr;
95 attr.Read(rTr);
96 }
97 rTr.ReadEnd(label);
98}
99
100//Insert(symbol)
101bool SymbolSet::Insert(const std::string& symbol) {
102 return TBaseSet<std::string>::Insert(symbol);
103}
104
105
106//Valid(idx)
107bool SymbolSet::Valid(const std::string& symbol) const {
108 return SymbolTable::ValidSymbol(symbol);
109}
110
111
112
113
114} // end name space
#define FD_DC(message)
Class SymbolSet, TaSymbolSet.
#define FAUDES_TYPE_IMPLEMENTATION(ftype, ctype, cbase)
Definition cfl_types.h:958
const std::string & Name(void) const
void DoAssign(const SymbolSet &rSource)
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
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.33k --- 2025.09.16 --- c++ api documentaion by doxygen