writesrc.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. *
  6. * Copyright (C) 2005-2012, International Business Machines
  7. * Corporation and others. All Rights Reserved.
  8. *
  9. *******************************************************************************
  10. * file name: writesrc.h
  11. * encoding: UTF-8
  12. * tab size: 8 (not used)
  13. * indentation:4
  14. *
  15. * created on: 2005apr23
  16. * created by: Markus W. Scherer
  17. *
  18. * Helper functions for writing source code for data.
  19. */
  20. #ifndef __WRITESRC_H__
  21. #define __WRITESRC_H__
  22. #include <stdio.h>
  23. #include "unicode/utypes.h"
  24. #include "unicode/ucptrie.h"
  25. #include "utrie2.h"
  26. /**
  27. * Creates a source text file and writes a header comment with the ICU copyright.
  28. * Writes a C/Java-style comment with the generator name.
  29. */
  30. U_CAPI FILE * U_EXPORT2
  31. usrc_create(const char *path, const char *filename, int32_t copyrightYear, const char *generator);
  32. /**
  33. * Creates a source text file and writes a header comment with the ICU copyright.
  34. * Writes the comment with # lines, as used in scripts and text data.
  35. */
  36. U_CAPI FILE * U_EXPORT2
  37. usrc_createTextData(const char *path, const char *filename, const char *generator);
  38. /**
  39. * Writes the contents of an array of 8/16/32-bit words.
  40. * The prefix and postfix are optional (can be NULL) and are written first/last.
  41. * The prefix may contain a %ld or similar field for the array length.
  42. * The {} and declaration etc. need to be included in prefix/postfix or
  43. * printed before and after the array contents.
  44. */
  45. U_CAPI void U_EXPORT2
  46. usrc_writeArray(FILE *f,
  47. const char *prefix,
  48. const void *p, int32_t width, int32_t length,
  49. const char *postfix);
  50. /**
  51. * Calls usrc_writeArray() for the index and data arrays of a frozen UTrie2.
  52. * Only the index array is written for a 16-bit UTrie2. In this case, dataPrefix
  53. * is ignored and can be NULL.
  54. */
  55. U_CAPI void U_EXPORT2
  56. usrc_writeUTrie2Arrays(FILE *f,
  57. const char *indexPrefix, const char *dataPrefix,
  58. const UTrie2 *pTrie,
  59. const char *postfix);
  60. /**
  61. * Writes the UTrie2 struct values.
  62. * The {} and declaration etc. need to be included in prefix/postfix or
  63. * printed before and after the array contents.
  64. */
  65. U_CAPI void U_EXPORT2
  66. usrc_writeUTrie2Struct(FILE *f,
  67. const char *prefix,
  68. const UTrie2 *pTrie,
  69. const char *indexName, const char *dataName,
  70. const char *postfix);
  71. /**
  72. * Calls usrc_writeArray() for the index and data arrays of a UCPTrie.
  73. */
  74. U_CAPI void U_EXPORT2
  75. usrc_writeUCPTrieArrays(FILE *f,
  76. const char *indexPrefix, const char *dataPrefix,
  77. const UCPTrie *pTrie,
  78. const char *postfix);
  79. /**
  80. * Writes the UCPTrie struct values.
  81. * The {} and declaration etc. need to be included in prefix/postfix or
  82. * printed before and after the array contents.
  83. */
  84. U_CAPI void U_EXPORT2
  85. usrc_writeUCPTrieStruct(FILE *f,
  86. const char *prefix,
  87. const UCPTrie *pTrie,
  88. const char *indexName, const char *dataName,
  89. const char *postfix);
  90. /**
  91. * Writes the UCPTrie arrays and struct values.
  92. */
  93. U_CAPI void U_EXPORT2
  94. usrc_writeUCPTrie(FILE *f, const char *name, const UCPTrie *pTrie);
  95. /**
  96. * Writes the contents of an array of mostly invariant characters.
  97. * Characters 0..0x1f are printed as numbers,
  98. * others as characters with single quotes: '%c'.
  99. *
  100. * The prefix and postfix are optional (can be NULL) and are written first/last.
  101. * The prefix may contain a %ld or similar field for the array length.
  102. * The {} and declaration etc. need to be included in prefix/postfix or
  103. * printed before and after the array contents.
  104. */
  105. U_CAPI void U_EXPORT2
  106. usrc_writeArrayOfMostlyInvChars(FILE *f,
  107. const char *prefix,
  108. const char *p, int32_t length,
  109. const char *postfix);
  110. #endif