Aegis  4.25.D505
/home/archives/aegis/branch.4/branch.25/delta28933.505/libaegis/meta_type.h
Go to the documentation of this file.
00001 //
00002 // aegis - project change supervisor
00003 // Copyright (C) 1991-1994, 2001-2008, 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 3 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 LIBAEGIS_META_TYPE_H
00020 #define LIBAEGIS_META_TYPE_H
00021 
00022 #include <common/ac/stddef.h>
00023 
00024 #include <common/str.h>
00025 #include <libaegis/aer/value.h>
00026 
00027 class meta_type; // forward
00028 
00029 struct type_table_ty
00030 {
00031     const char      *name;
00032     size_t          offset;
00033     meta_type       *type;
00034     unsigned long   mask;
00035     int             redefinition_ok;
00036     string_ty       *fast_name;
00037 };
00038 
00043 class meta_type
00044 {
00045 public:
00046     const char      *name;
00047 
00048     void *(*alloc)(void);
00049     void (*free)(void *this_thing);
00050     bool (*enum_parse)(string_ty *name, void *);
00051     void *(*list_parse)(void *this_thing, meta_type **type_pp);
00052     void *(*struct_parse)(void *this_thing, string_ty *name,
00053         meta_type **type_pp, unsigned long *maskp, int *redefinition_ok_p);
00054     string_ty *(*fuzzy)(string_ty *name);
00055     rpt_value::pointer (*convert)(void *this_thing);
00056     bool (*is_set)(void *);
00057 };
00058 
00063 class generic_struct
00064 {
00065 public:
00066     long            reference_count;
00067     unsigned long   mask;
00068     string_ty       *errpos;
00069 };
00070 
00071 extern meta_type boolean_type;
00072 #define boolean_copy(x) (x)
00073 const char *boolean_ename(bool);
00074 extern meta_type integer_type;
00075 #define integer_copy(x) (x)
00076 extern meta_type real_type;
00077 #define real_copy(x) (x)
00078 extern meta_type string_type;
00079 #define string_copy(x) str_copy(x)
00080 extern meta_type time_type;
00081 #define time_copy(x) (x)
00082 
00083 void *generic_struct_parse(void *, string_ty *, meta_type **, unsigned long *,
00084     int *, type_table_ty *, size_t);
00085 string_ty *generic_struct_fuzzy(string_ty *, type_table_ty *, size_t);
00086 bool generic_struct_is_set(void *);
00087 string_ty *generic_enum_fuzzy(string_ty *, string_ty **, size_t);
00088 rpt_value::pointer generic_struct_convert(void *, type_table_ty *,
00089     size_t);
00090 rpt_value::pointer generic_enum_convert(int, string_ty **, size_t);
00091 void generic_enum__init(const char *const *, size_t);
00092 
00093 void type_enum_option_set(void);
00094 void type_enum_option_clear(void);
00095 int type_enum_option_query(void);
00096 
00097 #endif // LIBAEGIS_META_TYPE_H
00098 // vim: set ts=8 sw=4 et :