annotate m_struct.h @ 19910:8e3785c20752

show in the osd the number of the button selected by the mouse
author nicodvb
date Tue, 19 Sep 2006 22:44:19 +0000
parents 5949a654e2d4
children 0b262e00bc99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 9586
diff changeset
1 #ifndef _M_STRUCT_H
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 9586
diff changeset
2 #define _M_STRUCT_H
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
3
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
4 /// \defgroup OptionsStruct Options struct
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
5 /// \ingroup Options
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
6 /// An API to manipulate structs using m_option.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
7 ///@{
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
8
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
9 /// \file m_struct.h
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
10
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
11 struct m_option;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
12
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
13 /// Struct definition
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
14 typedef struct m_struct_st {
18283
67d35fe89c8d Fix most of the mistakes pointed out by Diego.
albeu
parents: 18258
diff changeset
15 /// For error messages and debugging
19194
5949a654e2d4 marks some read-only char* inside structs as const, patch by Stefan Huehner, stefan At huehner-org
reynaldo
parents: 19104
diff changeset
16 const char* name;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
17 /// size of the whole struct
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
18 unsigned int size;
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
19 /// Pointer to a struct filled with the default settings
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
20 void* defaults;
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
21 /// Field list.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
22 /** The p field of the \ref m_option struct must contain the offset
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
23 * of the member in the struct (use M_ST_OFF macro for this).
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
24 */
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
25 struct m_option* fields;
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
26 } m_struct_t;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
27
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
28
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
29 // From glib.h (modified ;-)
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
30
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
31 /// Get the offset of a struct field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
32 /** \param struct_type Struct type.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
33 * \param member Name of the field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
34 * \return The offset of the field in bytes.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
35 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
36 #define M_ST_OFF(struct_type, member) \
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
37 ((void*) &((struct_type*) 0)->member)
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
38
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
39 /// Get a pointer to a struct field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
40 /** \param struct_p Pointer to the struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
41 * \param struct_offset Offset of the field in the struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
42 * \return Pointer to the struct field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
43 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
44 #define M_ST_MB_P(struct_p, struct_offset) \
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
45 ((void*) (struct_p) + (unsigned long) (struct_offset))
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
46
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
47 /// Acces a struct field at a given offset.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
48 /** \param member_type Type of the field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
49 * \param struct_p Pointer to the struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
50 * \param struct_offset Offset of the field in the struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
51 * \return The struct field at the given offset.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
52 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
53 #define M_ST_MB(member_type, struct_p, struct_offset) \
9586
albeu
parents: 8169
diff changeset
54 (*(member_type*) M_ST_MB_P ((struct_p), (struct_offset)))
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
55
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
56
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
57
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
58 /// Allocate the struct and set it to the defaults.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
59 /** \param st Struct definition.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
60 * \return The newly allocated object set to default.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
61 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
62 void*
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
63 m_struct_alloc(m_struct_t* st);
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
64
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
65 /// Set a field of the struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
66 /** \param st Struct definition.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
67 * \param obj Pointer to the struct to set.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
68 * \param field Name of the field to set.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
69 * \param param New value of the field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
70 * \return 0 on error, 1 on success.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
71 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
72 int
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
73 m_struct_set(m_struct_t* st, void* obj, char* field, char* param);
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
74
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
75 /// Reset a field (or all if field == NULL) to defaults.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
76 /** \param st Struct definiton.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
77 * \param obj Pointer to the struct to set.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
78 * \param field Name of the field to reset, if NULL all fields are reseted.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
79 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
80 void
19104
2ec2301183cd marks several read-only string parameters which aren't modified inside the called function as const. Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents: 18283
diff changeset
81 m_struct_reset(m_struct_t* st, void* obj, const char* field);
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
82
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
83 /// Create a copy of an existing struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
84 /** \param st Struct definiton.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
85 * \param obj Pointer to the struct to copy.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
86 * \return Newly allocated copy of obj.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
87 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
88 void*
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
89 m_struct_copy(m_struct_t* st, void* obj);
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
90
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
91 /// Free an allocated struct.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
92 /** \param st Struct definiton.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
93 * \param obj Pointer to the struct to copy.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
94 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
95 void
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
96 m_struct_free(m_struct_t* st, void* obj);
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
97
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
98 /// Get a field description.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
99 /** \param st Struct definiton.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
100 * \param f Name of the field.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
101 * \return The \ref m_option struct describing the field or NULL if not found.
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
102 */
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
103 struct m_option*
19104
2ec2301183cd marks several read-only string parameters which aren't modified inside the called function as const. Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents: 18283
diff changeset
104 m_struct_get_field(m_struct_t* st,const char* f);
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
105
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
106 ///@}
96568be4bfdc Doxygen attack!
albeu
parents: 10594
diff changeset
107
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 9586
diff changeset
108 #endif /* _M_STRUCT_H */