attributes.cpp

Go to the documentation of this file.
00001 
00003 /* FAU Discrete Event Systems Library (libfaudes)
00004 
00005    Copyright (C) 2006  Bernd Opitz
00006    Exclusive copyright is granted to Klaus Schmidt
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public
00010    License as published by the Free Software Foundation; either
00011    version 2.1 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Lesser General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public
00019    License along with this library; if not, write to the Free Software
00020    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00021 
00022 
00023 #include "attributes.h"
00024 
00025 
00026 namespace faudes {
00027 
00028 /***********************************************************************************
00029  *
00030  * implementation of AttributeVoid 
00031  *
00032  */
00033 
00034 //Write(rTr)
00035 void AttributeVoid::Write(TokenWriter& rTw) const {
00036 }
00037 
00038 //Read(rTr)
00039 void AttributeVoid::Read(TokenReader& rTr) {
00040   Token token;
00041   while(rTr.Peek(token)) {
00042     // break on index or name, since this is the next element
00043     if((token.Type()==Token::String) || (token.Type()==Token::Integer)) {
00044       break;
00045     }
00046     // break on end, since this is the end of the set
00047     if(token.Type()==Token::End) {
00048       break;
00049     }
00050     // break on Consecutive section, since this belongs to the set
00051     if((token.Type()==Token::Begin) && (token.StringValue() == "Consecutive")) {
00052       break;
00053     }
00054     // skip any attribute section from other file format
00055     if(token.Type()==Token::Begin){
00056       rTr.ReadBegin(token.StringValue());
00057       rTr.ReadEnd(token.StringValue());
00058       continue;
00059     }  
00060     // skip any other token from other file format
00061     rTr.Get(token);
00062   }
00063 }
00064 
00065 
00066 
00067 /***********************************************************************************
00068  *
00069  * implementation of AttributeFlags 
00070  *
00071  */
00072 
00073 //Write(rTw)
00074 // Note: you should write attributes in a section, so that
00075 // the AttributeVoid read method can detect and skip them.
00076 // Here, we make an execption of the rule ...
00077 void AttributeFlags::Write(TokenWriter& rTw) const {
00078   if(!IsDefault()) {
00079     Token token;
00080     token.SetInteger16(mFlags);
00081     rTw << token;
00082   }
00083 }
00084 
00085 //Write()
00086 void AttributeFlags::Write(void) const {
00087   TokenWriter rTw(TokenWriter::Stdout);
00088   Write(rTw);
00089 }
00090 
00091 
00092 //Read(rTr)
00093 void AttributeFlags::Read(TokenReader& rTr) {
00094   Token token;
00095   rTr.Peek(token);
00096   if(token.Type()==Token::Integer16) { 
00097     rTr.Get(token);
00098     mFlags=token.IntegerValue();
00099   } else {
00100     mFlags=mDefFlags;
00101   }
00102 }
00103 
00104 
00105 } // namespace

Generated on Fri May 9 11:26:47 2008 for libFAUDES 2.09b by  doxygen 1.4.4