upgrade libvpx+lv2, fix dbl tap play bug, add multi nest/unnest clips, add del top...
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bchash.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef BCHASH_H
23 #define BCHASH_H
24
25
26
27 // Key/value table with persistent storage in stringfiles.
28
29
30 #include "bcwindowbase.inc"
31 #include "bctextbox.inc"
32 #include "units.h"
33
34
35 class BC_Hash
36 {
37 public:
38         BC_Hash();
39         BC_Hash(const char *filename);
40         virtual ~BC_Hash();
41
42         int load_file(FILE *fp);
43         int load();        // load from disk file
44         int save_file(FILE *fp);
45         int save();        // save to disk file
46         int load_string(const char *string);        // load from string
47         int save_string(char* &string);       // save to new string
48         int update(const char *name, double value); // update a value if it exists
49         int update(const char *name, float value); // update a value if it exists
50         int update(const char *name, int32_t value); // update a value if it exists
51         int update(const char *name, int64_t value); // update a value if it exists
52         int update(const char *name, const char *value); // create it if it doesn't
53
54         double get(const char *name, double default_);   // retrieve a value if it exists
55         float get(const char *name, float default_);   // retrieve a value if it exists
56         int32_t get(const char *name, int32_t default_);   // retrieve a value if it exists
57         int64_t get(const char *name, int64_t default_);   // retrieve a value if it exists
58         char* get(const char *name, char *default_); // return 1 if it doesn't
59
60 // same as above using vararg format to specify name
61         int updatef(double value, const char *fmt, ...);
62         int updatef(float value, const char *fmt, ...);
63         int updatef(int32_t value, const char *fmt, ...);
64         int updatef(int64_t value, const char *fmt, ...);
65         int updatef(const char *value, const char *fmt, ...);
66
67         double getf(double default_, const char *fmt, ...);
68         float getf(float default_, const char *fmt, ...);
69         int32_t getf(int32_t default_, const char *fmt, ...);
70         int64_t getf(int64_t default_, const char *fmt, ...);
71         char* getf(char *default_, const char *fmt, ...);
72
73 // Update values with values from another table.
74 // Adds values that don't exist and updates existing values.
75         void copy_from(BC_Hash *src);
76 // Return 1 if the tables are equivalent
77         int equivalent(BC_Hash *src);
78
79         void dump();
80
81         int size();
82         char* get_key(int number);
83         char* get_value(int number);
84         void clear();
85
86 private:
87 // Reallocate table so at least total entries exist
88         void reallocate_table(int total);
89
90         char **names;  // list of string names
91         char **values;    // list of values
92         int total;             // number of defaults
93         int allocated;         // allocated defaults
94         char filename[BCTEXTLEN];        // filename the defaults are stored in
95 };
96
97 #endif