Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

NamedStream.h

00001 /*****************************************************************************
00002  * Author:   Valient Gough <vgough@pobox.com>
00003  *
00004  *****************************************************************************
00005  * Copyright (c) 2001, Valient Gough
00006  *
00007  * This library is free software; you can distribute it and/or modify it under
00008  * the terms of the GNU Lesser General Public License (LGPL), as published by
00009  * the Free Software Foundation; either version 2.1 of the License, or (at your
00010  * option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE.  See the LGPL in the file COPYING for more
00015  * details.
00016  *
00017  */
00018 
00019 #ifndef _NamedStream_incl_
00020 #define _NamedStream_incl_
00021 
00022 #include <rel/TypeStream.h>
00023 
00024 namespace rel
00025 {
00026 
00027     template<class KeyType, class ValueType>
00028         class NamedValue
00029         {
00030         public:
00031             NamedValue(KeyType &key, ValueType &value)
00032                 : fKey(key)
00033                 , fValue(value)
00034                 {
00035                 }
00036 
00037             KeyType &fKey;
00038             ValueType &fValue;
00039         };
00040 
00041 } // namespace rel
00042 
00043 template<class KeyType, class ValueType>
00044 rel::TypeStream & operator << (rel::TypeStream &st, 
00045         const rel::NamedValue<KeyType,ValueType> &data)
00046 {
00047     bool ok = st.writeBeginKey()
00048     st << data.fKey << data.fValue;
00049     ok &= st.writeEndKey();
00050 
00051     if(ok)
00052         return st;
00053     else
00054         throw OperationError("<<", "NamedValue");
00055 
00056 }
00057 
00058 #if 0
00059 template<class KeyType, class ValueType>
00060 rel::TypeStream & operator >> (rel::TypeStream &st, 
00061         const rel::NamedValue<KeyType,ValueType> &data)
00062 {
00063     BeginKey key;
00064     st >> key;
00065 
00066     bool ok = st.writeBeginKey()
00067     st >> data.fKey >> data.fValue;
00068     ok &= st.writeEndKey();
00069 
00070     if(ok)
00071         return st;
00072     else
00073         throw OperationError(">>", "NamedValue");
00074 
00075 }
00076 #endif
00077 
00078 #endif
00079 

Generated at Sat Sep 22 02:20:00 2001 for librel by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001