MCPcopy Create free account
hub / github.com/creatale/node-dv / strcodeGenerate

Function strcodeGenerate

deps/leptonica/src/stringcode.c:288–325  ·  view source on GitHub ↗

! * \brief strcodeGenerate() * * \param[in] strcode for accumulating data * \param[in] filein input file with serialized data * \param[in] type of data; use the typedef string * \return 0 if OK, 1 on error. * * * Notes: * (1) The generated function name is * l_autodecode_ () * where is the index label for the pair of output fil

Source from the content-addressed store, hash-verified

286 * </pre>
287 */
288l_int32
289strcodeGenerate(L_STRCODE *strcode,
290 const char *filein,
291 const char *type)
292{
293char *strdata, *strfunc, *strdescr;
294l_int32 itype;
295
296 PROCNAME("strcodeGenerate");
297
298 if (!strcode)
299 return ERROR_INT("strcode not defined", procName, 1);
300 if (!filein)
301 return ERROR_INT("filein not defined", procName, 1);
302 if (!type)
303 return ERROR_INT("type not defined", procName, 1);
304
305 /* Get the index corresponding to type and validate */
306 if (l_getIndexFromType(type, &itype) == 1)
307 return ERROR_INT("data type unknown", procName, 1);
308
309 /* Generate the encoded data string */
310 if ((strdata = l_genDataString(filein, strcode->ifunc)) == NULL)
311 return ERROR_INT("strdata not made", procName, 1);
312 sarrayAddString(strcode->data, strdata, L_INSERT);
313
314 /* Generate the case data for the decoding function */
315 strfunc = l_genCaseString(strcode->ifunc, itype);
316 sarrayAddString(strcode->function, strfunc, L_INSERT);
317
318 /* Generate row of table for function type selection */
319 strdescr = l_genDescrString(filein, strcode->ifunc, itype);
320 sarrayAddString(strcode->descr, strdescr, L_INSERT);
321
322 strcode->n++;
323 strcode->ifunc++;
324 return 0;
325}
326
327
328/*!

Callers 1

strcodeCreateFromFileFunction · 0.85

Calls 5

l_getIndexFromTypeFunction · 0.85
l_genDataStringFunction · 0.85
sarrayAddStringFunction · 0.85
l_genCaseStringFunction · 0.85
l_genDescrStringFunction · 0.85

Tested by

no test coverage detected