unewdata.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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) 1999-2010, International Business Machines
  7. * Corporation and others. All Rights Reserved.
  8. *
  9. *******************************************************************************
  10. * file name: unewdata.h
  11. * encoding: UTF-8
  12. * tab size: 8 (not used)
  13. * indentation:4
  14. *
  15. * created on: 1999oct25
  16. * created by: Markus W. Scherer
  17. */
  18. #ifndef __UNEWDATA_H__
  19. #define __UNEWDATA_H__
  20. #include "unicode/utypes.h"
  21. #include "unicode/udata.h"
  22. /* API for writing data -----------------------------------------------------*/
  23. /** @memo Forward declaration of the data memory creation type. */
  24. typedef struct UNewDataMemory UNewDataMemory;
  25. /**
  26. * Create a new binary data file.
  27. * The file-writing <code>udata_</code> functions facilitate writing
  28. * binary data files that can be read by ICU's <code>udata</code> API.
  29. * This function opens a new file with a filename determined from its
  30. * parameters - of the form "name.type".
  31. * It then writes a short header, followed by the <code>UDataInfo</code>
  32. * structure and, optionally, by the comment string.
  33. * It then writes padding bytes to round up to a multiple of 16 bytes.
  34. * Subsequent write operations will thus start at an offset in the file
  35. * that is a multiple of 16. <code>udata_getMemory()</code> will return
  36. * a pointer to this same starting offset.
  37. *
  38. * See udata.h .
  39. *
  40. * @param dir A string that specifies the directory where the data will be
  41. * written. If <code>NULL</code>, then
  42. * <code>u_getDataDirectory</code> is used.
  43. * @param type A string that specifies the type of data to be written.
  44. * For example, resource bundles are written with type "res",
  45. * conversion tables with type "cnv".
  46. * This may be <code>NULL</code> or empty.
  47. * @param name A string that specifies the name of the data.
  48. * @param pInfo A pointer to a correctly filled <code>UDataInfo</code>
  49. * structure that will be copied into the file.
  50. * @param comment A string (e.g., a copyright statement) that will be
  51. * copied into the file if it is not <code>NULL</code>
  52. * or empty. This string serves only as a comment in the binary
  53. * file. It will not be accessible by any API.
  54. * @param pErrorCode An ICU UErrorCode parameter. It must not be <code>NULL</code>.
  55. */
  56. U_CAPI UNewDataMemory * U_EXPORT2
  57. udata_create(const char *dir, const char *type, const char *name,
  58. const UDataInfo *pInfo,
  59. const char *comment,
  60. UErrorCode *pErrorCode);
  61. /** @memo Close a newly written binary file. */
  62. U_CAPI uint32_t U_EXPORT2
  63. udata_finish(UNewDataMemory *pData, UErrorCode *pErrorCode);
  64. /** @memo Write a dummy data file. */
  65. U_CAPI void U_EXPORT2
  66. udata_createDummy(const char *dir, const char *type, const char *name, UErrorCode *pErrorCode);
  67. /** @memo Write an 8-bit byte to the file. */
  68. U_CAPI void U_EXPORT2
  69. udata_write8(UNewDataMemory *pData, uint8_t byte);
  70. /** @memo Write a 16-bit word to the file. */
  71. U_CAPI void U_EXPORT2
  72. udata_write16(UNewDataMemory *pData, uint16_t word);
  73. /** @memo Write a 32-bit word to the file. */
  74. U_CAPI void U_EXPORT2
  75. udata_write32(UNewDataMemory *pData, uint32_t wyde);
  76. /** @memo Write a block of bytes to the file. */
  77. U_CAPI void U_EXPORT2
  78. udata_writeBlock(UNewDataMemory *pData, const void *s, int32_t length);
  79. /** @memo Write a block of arbitrary padding bytes to the file. */
  80. U_CAPI void U_EXPORT2
  81. udata_writePadding(UNewDataMemory *pData, int32_t length);
  82. /** @memo Write a <code>char*</code> string of platform "invariant characters" to the file. */
  83. U_CAPI void U_EXPORT2
  84. udata_writeString(UNewDataMemory *pData, const char *s, int32_t length);
  85. /** @memo Write a <code>UChar*</code> string of Unicode character code units to the file. */
  86. U_CAPI void U_EXPORT2
  87. udata_writeUString(UNewDataMemory *pData, const UChar *s, int32_t length);
  88. /*
  89. * Hey, Emacs, please set the following:
  90. *
  91. * Local Variables:
  92. * indent-tabs-mode: nil
  93. * End:
  94. *
  95. */
  96. #endif