Advertisement
Guest User

str.h

a guest
Oct 28th, 2015
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. /*! \file str.h
  2.  
  3. * \brief Declarations of the string methods.
  4.  
  5. * \author Peter C. Chapin <PChapin@vtc.vsc.edu>
  6.  
  7. * \date September 11, 2015
  8.  
  9. */
  10.  
  11.  
  12.  
  13. #ifndef STR_H
  14.  
  15. #define STR_H
  16.  
  17.  
  18.  
  19. #include <stddef.h>
  20.  
  21. #include <stdio.h>
  22.  
  23.  
  24.  
  25. //! Abstract type representing unbounded, dynamic strings.
  26.  
  27. typedef /*@abstract@*/ struct {
  28.  
  29. /*@null@*/ char *start; //!< Start of string allocation.
  30.  
  31. size_t size; //!< Number of characters in string.
  32.  
  33. size_t capacity; //!< Number of bytes of reserved space.
  34.  
  35. } string;
  36.  
  37.  
  38.  
  39.  
  40.  
  41. #ifdef __cplusplus
  42.  
  43. extern "C" {
  44.  
  45. #endif
  46.  
  47.  
  48.  
  49. int string_construct(/*@out@*/ string *object );
  50.  
  51. void string_destroy( string *object );
  52.  
  53. int string_erase( string *object );
  54.  
  55. int string_copy( string *object, const string *other );
  56.  
  57. int string_copycharp( string *object, /*@null@*/ const char *other );
  58.  
  59. int string_copychar( string *object, char other );
  60.  
  61. int string_copyf( string *object, const char *format, ... );
  62.  
  63. int string_append( string *object, const string *other );
  64.  
  65. int string_appendcharp( string *object, /*@null@*/ const char *other );
  66.  
  67. int string_appendchar( string *object, char other );
  68.  
  69. int string_appendf( string *object, const char *format, ... );
  70.  
  71. int string_prepend( string *object, const string *other );
  72.  
  73. int string_prependcharp( string *object, /*@null@*/ const char *other );
  74.  
  75. int string_prependchar( string *object, char other );
  76.  
  77. size_t string_length( const string *object );
  78.  
  79. char string_getcharat( const string *object, size_t char_index );
  80.  
  81. char *string_getcharp( string *object );
  82.  
  83. void string_putcharat( string *object, char other, size_t char_index );
  84.  
  85. int string_equal( const string *left, const string *right );
  86.  
  87. int string_less( string left, string right );
  88.  
  89. size_t string_findchar( const string *haystack, char needle );
  90.  
  91. size_t string_findstring( const string *haystack, const string *needle );
  92.  
  93. int string_substring( const string *source, string *target, size_t index, size_t length );
  94.  
  95. void string_reverse( string *object );
  96.  
  97. void string_swap( string *left, string *right );
  98.  
  99. int string_read( string *object, FILE *infile );
  100.  
  101. int string_readline( string *object, FILE *infile );
  102.  
  103. int string_write( const string *object, FILE *outfile );
  104.  
  105. int string_writeline( const string *object, FILE *outfile );
  106.  
  107.  
  108.  
  109. #ifdef __cplusplus
  110.  
  111. }
  112.  
  113. #endif
  114.  
  115.  
  116.  
  117. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement