1XmParseMapping(library call) XmParseMapping(library call)
2
3
4
6 XmParseMapping — Data type for a compound string parse mapping
7
9 #include <Xm/Xm.h>
10
12 XmParseMapping is an opaque data type for a parse mapping used by
13 XmStringParseText to create a compound string. A parse mapping con‐
14 tains a pattern to be matched in text being parsed to create a compound
15 string. It also contains a compound string, or a function to be
16 invoked to provide a compound string, to be included in the compound
17 string being created whenever the pattern is matched.
18
19 An application uses a resource-style interface to specify components
20 for an XmParseMapping. XmParseMappingCreate creates a parse mapping,
21 using a resource-style argument list. XmParseMappingGetValues and
22 XmParseMappingSetValues retrieve and set the components of a parse map‐
23 ping. XmParseMappingFree recovers memory used by a parse mapping.
24 XmParseTable is an array of XmParseMapping objects.
25
26 The XmNinvokeParseProc resource is a function of type XmParseProc,
27 which is defined as follows:
28
29 XmIncludeStatus (*XmParseProc) (text_in_out, text_end, type, tag, entry, pattern_length,
30 str_include, call_data)
31 XtPointer *text_in_out;
32 XtPointer text_end;
33 XmTextType type;
34 XmStringTag tag;
35 XmParseMapping entry;
36 int pattern_length;
37 XmString *str_include;
38 XtPointer call_data;
39
40 A parse procedure provides an escape mechanism for arbitrarily complex
41 parsing. This procedure is invoked when a pattern in the input text is
42 matched with a pattern in a parse mapping whose XmNincludeStatus is
43 XmINVOKE.
44
45 The input text is a pointer to the first byte of the pattern that was
46 matched to trigger the call to the parse procedure. The parse proce‐
47 dure consumes as many bytes of the input string as it needs and sets
48 the input text pointer to the following byte. It returns a compound
49 string to be included in the compound string being constructed, and it
50 also returns an XmIncludeStatus indicating how the returned compound
51 string should be handled. If the parse procedure does not set the
52 input text pointer ahead by at least one byte, the parsing routine con‐
53 tinues trying to match the input text with the patterns in the remain‐
54 ing parse mappings in the parse table. Otherwise, the parsing routine
55 begins with the new input text pointer and tries to match the input
56 text with patterns in the parse mappings starting at the beginning of
57 the parse table.
58
59 text_in_out
60 Specifies the text being parsed. The value is a pointer to
61 the first byte of text matching the pattern that triggered
62 the call to the parse procedure. When the parse procedure
63 returns, this argument is set to the position in the text
64 where parsing should resume—that is, to the byte following
65 the last character parsed by the parse procedure.
66
67 text_end Specifies a pointer to the end of the text_in_out string. If
68 text_end is NULL, the string is scanned until a NULL charac‐
69 ter is found. Otherwise, the string is scanned up to but not
70 including the character whose address is text_end.
71
72 type Specifies the type of text and the tag type. If a locale tag
73 should be created, type has a value of either XmMULTI‐
74 BYTE_TEXT or XmWIDECHAR_TEXT. If a charset should be cre‐
75 ated, type has a value of XmCHARSET_TEXT.
76
77 tag Specifies the tag to be used in creating the result. The
78 type of string tag created (charset or locale) depends on the
79 text type and the passed in tag value. If the tag value is
80 NULL and if type indicates that a charset string tag should
81 be created, the string tag has the value that is the result
82 of mapping XmSTRING_DEFAULT_CHARSET. If type indicates a
83 locale string tag, the string tag has the value
84 _MOTIF_DEFAULT_LOCALE.
85
86 entry Specifies the parse mapping that triggered the call to the
87 parse procedure.
88
89 pattern_length
90 Specifies the number of bytes in the input text, following
91 text_in_out, that constitute the matched pattern.
92
93 str_include
94 Specifies a pointer to a compound string. The parse proce‐
95 dure creates a compound string to be included in the compound
96 string being constructed. The parse procedure then returns
97 the compound string in this argument.
98
99 call_data Specifies data passed by the application to the parsing rou‐
100 tine.
101
102 The parse procedure returns an XmIncludeStatus indicating how
103 str_include is to be included in the compound string being constructed.
104 Following are the possible values:
105
106 XmINSERT Concatenate the result to the compound string being con‐
107 structed and continue parsing.
108
109 XmTERMINATE
110 Concatenate the result to the compound string being con‐
111 structed and terminate parsing.
112
113 New Resources
114 The following table defines a set of resources used by the programmer
115 to specify data. The codes in the access column indicate if the given
116 resource can be set at creation time (C), set by using XmParseMap‐
117 pingSetValues (S), retrieved by using XmParseMappingGetValues (G), or
118 is not applicable (N/A).
119
120 ┌───────────────────────────────────────────────────────────────────────┐
121 │ │ XmPars│eMapping Resource │Set │ │
122 │Name │ Class │ Type │ Default │ Access │
123 ├───────────────────┼───────┼─────────────────┼────────────────┼────────┤
124 │XmNclientData │ │ XtPointer │ NULL │ CSG │
125 ├───────────────────┼───────┼─────────────────┼────────────────┼────────┤
126 │XmNincludeStatus │ │ XmIncludeStatus │ XmINSERT │ CSG │
127 ├───────────────────┼───────┼─────────────────┼────────────────┼────────┤
128 │XmNinvokeParseProc │ │ XmParseProc │ NULL │ CSG │
129 ├───────────────────┼───────┼─────────────────┼────────────────┼────────┤
130 │XmNpattern │ │ XtPointer │ NULL │ CSG │
131 ├───────────────────┼───────┼─────────────────┼────────────────┼────────┤
132 │XmNpatternType │ │ XmTextType │ XmCHARSET_TEXT │ CSG │
133 ├───────────────────┼───────┼─────────────────┼────────────────┼────────┤
134 │XmNsubstitute │ │ XmString │ NULL │ CSG │
135 ├───────────────────┼───────┼─────────────────┼────────────────┼────────┤
136 └───────────────────┴───────┴─────────────────┴────────────────┴────────┘
137 XmNclientData
138 Specifies data to be used by the parse procedure.
139
140 XmNincludeStatus
141 Specifies how the result of the mapping is to be included in
142 the compound string being constructed. Unless the value is
143 XmINVOKE, the result of the mapping is the value of XmNsub‐
144 stitute. Following are the possible values for XmNinclud‐
145 eStatus:
146
147 XmINSERT Concatenate the result to the compound string being
148 constructed and continue parsing.
149
150 XmINVOKE Invoke the XmNinvokeParseProc on the text being
151 parsed and use the returned compound string instead
152 of XmNsubstitute as the result to be inserted into
153 the compound string being constructed. The include
154 status returned by the parse procedure (XmINSERT or
155 XmTERMINATE) determines how the returned compound
156 string is included.
157
158 XmTERMINATE
159 Concatenate the result to the compound string being
160 constructed and terminate parsing.
161
162 XmNinvokeParseProc
163 Specifies the parse procedure to be invoked when XmNinclud‐
164 eStatus is XmINVOKE.
165
166 XmNpattern
167 Specifies a pattern to be matched in the text being parsed.
168 This is a maximum of one character.
169
170 XmNpatternType
171 Specifies the type of the pattern that is the value of XmN‐
172 pattern. Following are the possible values:
173
174 · XmCHARSET_TEXT
175
176 · XmMULTIBYTE_TEXT
177
178 · XmWIDECHAR_TEXT
179
180 XmNsubstitute
181 Specifies the compound string to be included in the compound
182 string being constructed when XmNincludeStatus is XmINSERT or
183 XmTERMINATE.
184
186 XmParseMappingCreate(3), XmParseMappingFree(3), XmParseMappingGetVal‐
187 ues(3), XmParseMappingSetValues(3), XmParseTable(3), and XmString(3).
188
189
190
191 XmParseMapping(library call)