| 1 | /* Copyright 2012 Kjetil S. Matheussen |
| 2 | |
| 3 | This program is free software; you can redistribute it and/or |
| 4 | modify it under the terms of the GNU General Public License |
| 5 | as published by the Free Software Foundation; either version 2 |
| 6 | of the License, or (at your option) any later version. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 16 | |
| 17 | |
| 18 | #ifndef HASHMAP_PROC_H |
| 19 | #define HASHMAP_PROC_Hcxx . . $ `common/hashmap_proc.h:19:9`! |
| 20 | |
| 21 | |
| 22 | // Warning: Writing two elements with the same key to the same hash table just adds two elements with the same key into the table. |
| 23 | // Nothing is ever deleted from the tables. |
| 24 | |
| 25 | // A key can not contain lineshift since lineshifts are used as delimiter character when loading/saving. |
| 26 | |
| 27 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! hash_tcxx . . $ hash_t# *HASH_create(int approx_size); |
| 28 | |
| 29 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! bool HASH_has_key(hash_tcxx . . $ hash_t# *hash, const char *key); |
| 30 | |
| 31 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! int HASH_get_num_elements(hash_tcxx . . $ hash_t# *hash); |
| 32 | |
| 33 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! hash_tcxx . . $ hash_t# *HASH_get_keys(hash_tcxx . . $ hash_t# *hash); // Returns all keys in a new hash array. |
| 34 | |
| 35 | // HASH_put_*: char *key is not copied. I.e. the key is used directly, not a copy of it. |
| 36 | // HASH_put_string: A copy of char *val is used, not val itself. |
| 37 | |
| 38 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! void HASH_put_string(hash_tcxx . . $ hash_t# *hash, const char *key, const char *val); |
| 39 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! void HASH_put_int(hash_tcxx . . $ hash_t# *hash, const char *key, int64_t val); |
| 40 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! void HASH_put_float(hash_tcxx . . $ hash_t# *hash, const char *key, double val); |
| 41 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! void HASH_put_hash(hash_tcxx . . $ hash_t# *hash, const char *key, hash_tcxx . . $ hash_t# *val); |
| 42 | |
| 43 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! const char *HASH_get_string(hash_tcxx . . $ hash_t# *hash, const char *key); |
| 44 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! int64_t HASH_get_int(hash_tcxx . . $ hash_t# *hash, const char *key); |
| 45 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! double HASH_get_float(hash_tcxx . . $ hash_t# *hash, const char *key); |
| 46 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! hash_tcxx . . $ hash_t# *HASH_get_hash(hash_tcxx . . $ hash_t# *hash, const char *key); |
| 47 | |
| 48 | |
| 49 | // Array interface |
| 50 | |
| 51 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! int HASH_get_array_size(hash_tcxx . . $ hash_t# *hash); |
| 52 | |
| 53 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! void HASH_put_string_at(hash_tcxx . . $ hash_t# *hash, int i, const char *val); |
| 54 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! void HASH_put_int_at(hash_tcxx . . $ hash_t# *hash, int i, int64_t val); |
| 55 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! void HASH_put_float_at(hash_tcxx . . $ hash_t# *hash, int i, double val); |
| 56 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! void HASH_put_hash_at(hash_tcxx . . $ hash_t# *hash, int i, hash_tcxx . . $ hash_t# *val); |
| 57 | |
| 58 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! const char *HASH_get_string_at(hash_tcxx . . $ hash_t# *hash, int i); |
| 59 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! int64_t HASH_get_int_at(hash_tcxx . . $ hash_t# *hash, int i); |
| 60 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! double HASH_get_float_at(hash_tcxx . . $ hash_t# *hash, int i); |
| 61 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! hash_tcxx . . $ hash_t# *HASH_get_hash_at(hash_tcxx . . $ hash_t# *hash, int i); |
| 62 | |
| 63 | |
| 64 | // Loading and saving (serializing and deserializing to string. (The 'file' argument can be stdout for debugging)) |
| 65 | |
| 66 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! void HASH_save(hash_tcxx . . $ hash_t# *hash, FILEcxx . . $ FILE# *file); |
| 67 | extern LANGSPECcxx . . $ `common/nsmtracker.h:34:11`! hash_tcxx . . $ hash_t# *HASH_load(FILEcxx . . $ FILE# *file); |
| 68 | |
| 69 | // This function was used before the array interface was introduced. |
| 70 | // extern LANGSPEC const char *HASH_get_int_hash(int i); |
| 71 | |
| 72 | #endif // HASHMAP_PROC_H |