nis-util  1.0.D108
lib/symtab.h
Go to the documentation of this file.
00001 //
00002 // nis-util - NIS Administration Utilities
00003 // Copyright (C) 2001, 2008, 2009, 2011, 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or (at
00008 // your option) any later version.
00009 //
00010 // This program 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 License
00016 // along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef LIB_SYMTAB_H
00020 #define LIB_SYMTAB_H
00021 
00022 #include <lib/rcstring.h>
00023 #include <vector>
00024 
00029 class symtab
00030 {
00031 public:
00035     virtual ~symtab();
00036 
00040     symtab();
00041 
00042 private:
00046     symtab(const symtab &);
00047 
00051     symtab &operator=(const symtab &);
00052 
00053     struct row_ty
00054     {
00055         row_ty() : data(0), overflow(0) { }
00056 
00057         rcstring key;
00058         void *data;
00059         row_ty *overflow;
00060     };
00061 
00062     void (*reap)(void *);
00063     row_ty **hash_table;
00064     typedef rcstring::hash_ty hash_ty;
00065     hash_ty hash_modulus;
00066     hash_ty hash_cutover;
00067     hash_ty hash_cutover_mask;
00068     hash_ty hash_cutover_split_mask;
00069     hash_ty hash_split;
00070     hash_ty hash_load;
00071 
00072 public:
00082     void *query(const rcstring &name) const;
00083 
00087     void assign(const rcstring &name, void *value);
00088 
00089     void remove(const rcstring &name);
00090 
00096     void dump(const char *caption) const;
00097 
00098     struct walk_t
00099     {
00100         virtual ~walk_t() {}
00101         virtual void action(const rcstring &key, void *value) = 0;
00102     };
00103 
00104     void walk(walk_t &);
00105 
00106     typedef std::vector<rcstring> key_list_t;
00107 
00113     key_list_t keys() const;
00114 
00119     void set_reaper(void(*)(void *));
00120 
00121 private:
00127     void split(void);
00128 };
00129 
00130 // vim: set ts=8 sw=4 et :
00131 #endif // LIB_SYMTAB_H