cfl_symbolset.cpp

Go to the documentation of this file.
00001 /** @file cfl_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 "cfl_symbolset.h"
00024 
00025 namespace faudes {
00026 
00027 // std faudes type
00028 FAUDES_TYPE_IMPLEMENTATION(SymbolSet,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 void SymbolSet::DoAssign(const SymbolSet& rSourceSet) {
00056   TBaseSet<std::string>DoAssign(rSourceSet);
00057 }
00058 
00059 
00060 // DoWrite(rTw&)
00061 void SymbolSet::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
00062   (void) pContext;
00063   std::string label=rLabel;
00064   if(label=="") label=Name(); 
00065   if(label=="") label="SymbolSet"; 
00066   rTw.WriteBegin(label);
00067   Iterator it;
00068   // iterate symbols to write
00069   for (it = Begin(); it != End(); ++it) {
00070     rTw << *it;
00071   }
00072   rTw.WriteEnd(label);
00073 }
00074 
00075 // DoRead(rTr, rLabel, context)
00076 void SymbolSet::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00077   std::string label=rLabel;
00078   if(label=="") label="SymbolSet"; 
00079   Name(label);
00080   Clear();
00081   rTr.ReadBegin(label); 
00082   Token token;
00083   while(!rTr.Eos(label)) {
00084     rTr.Get(token);
00085     // read individual symbol
00086     if (token.Type() == Token::String) {
00087       FD_DC("SymbolSet(" << this << ")::DoRead(..): inserting symbol \"" 
00088       << token.StringValue() << "\"");
00089       // insert element
00090       Insert(token.StringValue());
00091       continue;
00092     }
00093     // ignore unknown attributes
00094     AttributeVoid attr;
00095     attr.Read(rTr);
00096   }
00097   rTr.ReadEnd(label);
00098 }
00099 
00100 //Insert(symbol)
00101 bool SymbolSet::Insert(const std::string& symbol) {
00102   return TBaseSet<std::string>::Insert(symbol);
00103 }
00104 
00105 
00106 //Valid(idx)
00107 bool  SymbolSet::Valid(const std::string& symbol) const {
00108   return SymbolTable::ValidSymbol(symbol);
00109 }
00110 
00111 
00112 
00113 
00114 } // end name space

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen