libFAUDES

Sections

Index

symbolset.cpp

Go to the documentation of this file.
00001 /** @file symbolset.cpp @brief Class SymbolSet */
00002 
00003 /* FAU Discrete Event Systems Library (libfaudes)
00004 
00005    Copyright (C) 2006  Bernd Opitz
00006    Copyright (C) 2007  Thomas Moor
00007    Exclusive copyright is granted to Klaus Schmidt
00008 
00009    This library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Lesser General Public
00011    License as published by the Free Software Foundation; either
00012    version 2.1 of the License, or (at your option) any later version.
00013 
00014    This library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Lesser General Public License for more details.
00018 
00019    You should have received a copy of the GNU Lesser General Public
00020    License along with this library; if not, write to the Free Software
00021    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00022 
00023 #include "symbolset.h"
00024 
00025 namespace faudes {
00026 
00027 // std faudes type
00028 FAUDES_TYPE_IMPLEMENTATION(SymbolSet,TBaseSet<std::string>,)
00029 
00030 
00031 // SymbolSet()
00032 SymbolSet::SymbolSet(void) : 
00033   TBaseSet<std::string>() 
00034 {
00035   FD_DC("SymbolSet(" << this << ")::SymbolSet()");
00036   Name("SymbolSet");
00037 }
00038 
00039 // SymbolSet(rOtherSet)
00040 SymbolSet::SymbolSet(const TBaseSet<std::string>& rOtherSet) : 
00041   TBaseSet<std::string>(rOtherSet) 
00042 {
00043   FD_DC("SymbolSet(" << this << ")::SymbolSet(rOtherSet " << &rOtherSet << ")");
00044 }
00045 
00046 // File constructor
00047 SymbolSet::SymbolSet(const std::string& rFilename, const std::string& rLabel) :
00048   TBaseSet<std::string>() 
00049 {
00050   FD_DC("SymbolSet(" << this << ")::SymbolSet(" << rFilename << ")");
00051   Read(rFilename, rLabel);
00052 }
00053 
00054 // DoAssign
00055 SymbolSet& SymbolSet::DoAssign(const SymbolSet& rSourceSet) {
00056   TBaseSet<std::string>DoAssign(rSourceSet);
00057   return *this; 
00058 }
00059 
00060 
00061 // DoWrite(rTw&)
00062 void SymbolSet::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
00063   (void) pContext;
00064   std::string label=rLabel;
00065   if(label=="") label=Name(); 
00066   if(label=="") label="SymbolSet"; 
00067   rTw.WriteBegin(label);
00068   Iterator it;
00069   // iterate symbols to write
00070   for (it = Begin(); it != End(); ++it) {
00071     rTw << *it;
00072   }
00073   rTw.WriteEnd(label);
00074 }
00075 
00076 // DoRead(rTr, rLabel, context)
00077 void SymbolSet::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00078   std::string label=rLabel;
00079   if(label=="") label="SymbolSet"; 
00080   Name(label);
00081   Clear();
00082   rTr.SeekBegin(label); 
00083   Token token;
00084   while(!rTr.Eos(label)) {
00085     rTr.Get(token);
00086     // read individual symbol
00087     if (token.Type() == Token::String) {
00088       FD_DC("SymbolSet(" << this << ")::DoRead(..): inserting symbol \"" 
00089       << token.StringValue() << "\"");
00090       // insert element
00091       Insert(token.StringValue());
00092       continue;
00093     }
00094     // ignore unknown attributes
00095     AttributeVoid attr;
00096     attr.Read(rTr);
00097   }
00098   rTr.SeekEnd(label);
00099 }
00100 
00101 //Insert(symbol)
00102 bool SymbolSet::Insert(const std::string& symbol) {
00103   return TBaseSet<std::string>::Insert(symbol);
00104 }
00105 
00106 
00107 //Valid(idx)
00108 bool  SymbolSet::Valid(const std::string& symbol) const {
00109   return SymbolTable::ValidSymbol(symbol);
00110 }
00111 
00112 
00113 
00114 
00115 } // end name space

libFAUDES 2.14g --- 2009-12-3 --- c++ source docu by doxygen 1.5.6