Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

prop_registry.cc

Go to the documentation of this file.
00001 /*
00002  *  File:       cucu.c
00003  *              $Id: prop_registry.cc,v 1.3 2002/06/26 20:49:32 alec Exp $
00004  *
00005  *  Author:     Alec Panoviciu (alecu@email.com)
00006  *
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: prop_registry.cc,v $
00012  *  Revision 1.3  2002/06/26 20:49:32  alec
00013  *  g++ 3.x happy
00014  *
00015  *  Revision 1.2  2002/04/29 09:34:10  alec
00016  *  scanner ptree building compiles
00017  *
00018  */
00019 
00020 /* 
00021   Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)
00022 
00023   This program is free software; you can redistribute it and/or modify
00024   it under the terms of the GNU General Public License as published by
00025   the Free Software Foundation; either version 2 of the License, or
00026   (at your option) any later version.
00027 
00028   This program is distributed in the hope that it will be useful,
00029   but WITHOUT ANY WARRANTY; without even the implied warranty of
00030   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00031   GNU General Public License for more details.
00032 
00033   You should have received a copy of the GNU General Public License
00034   along with this program; if not, write to the Free Software
00035   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00036 
00037  */
00038 
00039 #include <iostream>
00040 using namespace std;
00041 
00042 #include "prop_registry.hh"
00043 
00044 PropRegistry::PropData& PropRegistry::PropData::operator <<
00045   (const PropRegistry::PropData &o) throw (bad_cast)
00046 {
00047   if (tag == k_undef) tag = o.tag;
00048   if (tag != o.tag) throw bad_cast();
00049   
00050   switch (tag)
00051   {
00052   case k_string: s.insert(s.end(), o.s.begin(), o.s.end()); break;
00053   case k_bool: b.insert(b.end(), o.b.begin(), o.b.end()); break;
00054   case k_int: i.insert(i.end(), o.i.begin(), o.i.end()); break;
00055   case k_float: f.insert(f.begin(), o.f.begin(), o.f.end()); break;
00056   }
00057 
00058   return *this;
00059 }
00060 
00061 
00062 ostream& operator << (ostream &os, const PropRegistry::PropData &o)
00063 {
00064   switch (o.tag)
00065   {
00066   case PropRegistry::PropData::k_bool:
00067     if (!o.b.empty()) os << o.b[0];
00068     for (int k = 1; k < o.b.size(); k++) os << " " << o.b[k];
00069     break;
00070   case PropRegistry::PropData::k_string:
00071     if (!o.s.empty()) os << o.s[0];
00072     for (int k = 1; k < o.s.size(); k++) os << o.s[k];
00073     break;
00074   case PropRegistry::PropData::k_int:
00075     if (!o.i.empty()) os << o.i[0];
00076     for (int k = 1; k < o.i.size(); k++) os << " " << o.i[k];
00077     break;
00078   case PropRegistry::PropData::k_float:
00079     if (!o.f.empty()) os << o.f[0];
00080     for (int k = 1; k < o.f.size(); k++) os << " " << o.f[k];
00081     break;
00082   default:
00083     ASSERT(0, "bad PropData tag");
00084   }
00085   
00086   return os;
00087 }
00088 
00089 
00090 ostream& operator >> (ostream &os, PropRegistry::PropData &o)
00091 {
00092   UNIMPLEMENTED; // \todo
00093   
00094   return os;
00095 }
00096 
00097 ostream& operator << (ostream &os, const PropRegistry &o)
00098 {
00099   for (PropRegistry::const_iterator i = o.begin(); i != o.end(); i++)
00100   {
00101     os << (*i).first << " = " << (*i).second << endl;
00102   }
00103 
00104   return os;
00105 }
00106 
00107 
00108 ostream& operator >> (ostream &os, PropRegistry &o)
00109 {
00110   UNIMPLEMENTED; // \todo
00111 
00112   return os;
00113 }

Generated at Tue Jul 9 21:05:45 2002 for CppCC by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001