deds_string.htm 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
  2. <html><head>
  3. <title>string</title>
  4. </head><body>
  5. <p>[<a href="mxdoc.htm">mainpage</a>]
  6. [<a href="tags.htm">tags</a>]<br>
  7. <h1><a name="string">module: string</a></h1><p><b>Some simple string allocation and handling functions.</b><p>
  8. This module contains functions for object-oriented handling of
  9. const char* strings in C. Strings can be either zero-terminated or have some
  10. fixed length. The contents of the string cannot be (easily) changed.
  11. <p>
  12. MX_STRING is bit-copy-correct which means that a binary copy retains
  13. proper functioning and takes over ownership of internal buffers. The copy
  14. source MX_STRING should not be used once the copy takes place.
  15. <p>
  16. Memory containing a MX_STRING can be realloc'd without affecting proper
  17. operation. Therefore it can be used inside a MX_VECTOR.
  18. (<a href="../include/deds/string.h">../include/deds/string.h</a>)<p>Part of the <a href="deds.htm">deds</a> library.<ul><li>
  19. <a name="MX_STRING"><code>MX_STRING</code></a>
  20. <p>
  21. <p><b>A string object </b><p>
  22. (<a href="../include/deds/string.h">../include/deds/string.h</a>)<p></li>
  23. <li>
  24. <a name="void mx_string_realloc(MX_STRING* string, const MX_ALLOC alloc, const MX_FREE dfree)"><code>void mx_string_realloc(MX_STRING* string, const MX_ALLOC alloc, const MX_FREE dfree)</code></a>
  25. <p>
  26. <p><b>Reallocate a MX_STRING</b><p>
  27. This function changes the memory allocation of the text inside a
  28. MX_STRING to the ones in the argumnets. Memory is allocated using the alloc
  29. function and the current contents of the string is copied to the newly
  30. allocated memory. The free function will be called when the memory
  31. associated with the text needs to be freed.
  32. (<a href="../include/deds/string/realloc.c">../include/deds/string/realloc.c</a>)<p></li>
  33. <li>
  34. <a name="void mx_string_set(MX_STRING* string, const char* text, int len, const MX_FREE dfree)"><code>void mx_string_set(MX_STRING* string, const char* text, int len, const MX_FREE dfree)</code></a>
  35. <p>
  36. <p><b>Set MX_STRING text and length</b><p>
  37. This function sets the text, length and free function of a MX_STRING
  38. object. When mx_string_free() is called the free function will be called to
  39. release the memory associated with the text. The free parameter may be 0 in
  40. which case no function will be called to release the text memory.
  41. (<a href="../include/deds/string/set.c">../include/deds/string/set.c</a>)
  42. <p>If the len parameter is less than 0 (usually -1) then the string
  43. is assumed to be zero terminated.
  44. (<a href="../include/deds/string/set.c">../include/deds/string/set.c</a>)<p></li>
  45. <li>
  46. <a name="void mx_string(MX_STRING* string)"><code>void mx_string(MX_STRING* string)</code></a>
  47. <p>
  48. <p><b>Construct a MX_STRING</b><p>
  49. This function initializes a MX_STRING object. It writes the memory
  50. full with 0 values.
  51. (<a href="../include/deds/string/string.c">../include/deds/string/string.c</a>)
  52. <p>Since a MX_STRING filled with 0 is correctly constructed then
  53. static instances dont necessarily have to be constructed before use.
  54. (<a href="../include/deds/string/string.c">../include/deds/string/string.c</a>)<p></li>
  55. <li>
  56. <a name="void mx_string_free(MX_STRING* string)"><code>void mx_string_free(MX_STRING* string)</code></a>
  57. <p>
  58. <p><b>Destruct a MX_STRING</b><p>
  59. This function frees a MX_STRING object. If the associated free
  60. will be called to release any internal memory.
  61. (<a href="../include/deds/string/string.c">../include/deds/string/string.c</a>)<p></li>
  62. <li>
  63. <a name="const char* mx_string_text(const MX_STRING* string, int* len)"><code>const char* mx_string_text(const MX_STRING* string, int* len)</code></a>
  64. <p>
  65. <p><b>Get MX_STRING text and length</b><p>
  66. This function return the text of the string along with the length
  67. of the text segment.
  68. (<a href="../include/deds/string/text.c">../include/deds/string/text.c</a>)
  69. <p>The len argument can be 0 in which case the length is not returned.
  70. (<a href="../include/deds/string/text.c">../include/deds/string/text.c</a>)<p></li>
  71. <li>
  72. <a name="int mx_string_len(const MX_STRING* string)"><code>int mx_string_len(const MX_STRING* string)</code></a>
  73. <p>
  74. <p><b>Get MX_STRING length</b><p>
  75. This function return the length of the text segment.
  76. (<a href="../include/deds/string/text.c">../include/deds/string/text.c</a>)<p></li>
  77. </ul><p>Generated by <a href="http://www.deleveld.dds.nl/mxdoc/index.htm">MXDOC</a> 2.2 on Sun Feb 4 15:16:26 2007
  78. </body></html>