1 #ifndef IVL_Attrib_H 2 #define IVL_Attrib_H 3 /* 4 * Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com) 5 * 6 * This source code is free software; you can redistribute it 7 * and/or modify it in source code form under the terms of the GNU 8 * General Public License as published by the Free Software 9 * Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22 # include "StringHeap.h" 23 # include "verinum.h" 24 25 /* 26 * This class keeps a map of key/value pairs. The map can be set from 27 * an STL map, or by setting individual mappings. 28 */ 29 class Attrib { 30 31 public: 32 Attrib(); 33 virtual ~Attrib(); 34 35 const verinum&attribute(perm_string key) const; 36 void attribute(perm_string key, const verinum&value); 37 bool has_compat_attributes(const Attrib&that) const; 38 39 40 /* Provide a means of iterating over the entries in the map. */ 41 unsigned attr_cnt() const; 42 perm_string attr_key(unsigned idx) const; 43 const verinum& attr_value(unsigned idx) const; 44 45 46 private: 47 struct cell_ { 48 perm_string key; 49 verinum val; 50 }; 51 52 unsigned nlist_; 53 struct cell_*list_; 54 55 private: // not implemented 56 Attrib(const Attrib&); 57 Attrib& operator= (const Attrib&); 58 }; 59 60 #endif /* IVL_Attrib_H */ 61