vrq
/usr/src/RPM/BUILD/vrq-1.0.96/src/cattr.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 1997-2007, Mark Hummel
00003  * This file is part of Vrq.
00004  *
00005  * Vrq is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * Vrq is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00018  * Boston, MA  02110-1301  USA
00019  *****************************************************************************
00020  */
00021 /******************************************************************************
00022  *
00023  *
00024  *         cattr.hpp
00025  *              - class definition of attribute
00026  *                definition nodes
00027  *
00028  ******************************************************************************
00029  */
00030 
00031 #ifndef CATTR_HPP
00032 #define CATTR_HPP
00033 
00034 #include <stdio.h>
00035 #include <string>
00036 #include <map>
00037 #include "glue.h"
00038 #include "cdecl.h"
00039 
00040 using namespace std;
00041 
00042 
00043 class CNode;
00044 
00045 
00050 class CAttr: public CDecl
00051 {
00052 private:
00053     struct Entry {
00054         string s;
00055         CNode* exp;
00056     };
00057     vector<Entry> table;
00058 public:
00062         CAttr( Coord_t* aLoc );
00068         virtual CDecl* Clone( CObstack* heap );
00074         void    AddAttribute( const char* name, CNode* aExp ) { 
00075             Entry entry;
00076             entry.s = name;
00077             entry.exp = aExp;
00078             table.push_back( entry );
00079         }
00084         int     GetAttributeCount() { return table.size(); }
00090         const char*     GetAttributeName( int index ) 
00091             { return table[index].s.c_str(); }
00097         CNode*  GetAttributeExpression( int index ) { return table[index].exp; }
00103         CNode*  GetAttributeExpression( const char* name );
00109         int     HasAttribute( const char* name );
00114         virtual void Dump( FILE* f );
00115 private:
00121         void Copy( CObstack* heap, CAttr& d );
00122 private:
00123         /*
00124          * Disable copy constructor.
00125          */
00126         CAttr( const CAttr& );
00127 };
00128 
00129 #endif // CATTR_HPP