Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

270 wiersze
10 KiB

  1. /* GLIB - Library of useful routines for C programming
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17. * Boston, MA 02111-1307, USA.
  18. */
  19. /*
  20. * Modified by the GLib Team and others 1997-2000. See the AUTHORS
  21. * file for a list of people on the GLib Team. See the ChangeLog
  22. * files for a list of changes. These files are distributed with
  23. * GLib at ftp://ftp.gtk.org/pub/gtk/.
  24. */
  25. #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  26. #error "Only <glib.h> can be included directly."
  27. #endif
  28. #ifndef __G_STRFUNCS_H__
  29. #define __G_STRFUNCS_H__
  30. #include <stdarg.h>
  31. #include <glib/gmacros.h>
  32. #include <glib/gtypes.h>
  33. G_BEGIN_DECLS
  34. /* Functions like the ones in <ctype.h> that are not affected by locale. */
  35. typedef enum {
  36. G_ASCII_ALNUM = 1 << 0,
  37. G_ASCII_ALPHA = 1 << 1,
  38. G_ASCII_CNTRL = 1 << 2,
  39. G_ASCII_DIGIT = 1 << 3,
  40. G_ASCII_GRAPH = 1 << 4,
  41. G_ASCII_LOWER = 1 << 5,
  42. G_ASCII_PRINT = 1 << 6,
  43. G_ASCII_PUNCT = 1 << 7,
  44. G_ASCII_SPACE = 1 << 8,
  45. G_ASCII_UPPER = 1 << 9,
  46. G_ASCII_XDIGIT = 1 << 10
  47. } GAsciiType;
  48. GLIB_VAR const guint16 * const g_ascii_table;
  49. #define g_ascii_isalnum(c) \
  50. ((g_ascii_table[(guchar) (c)] & G_ASCII_ALNUM) != 0)
  51. #define g_ascii_isalpha(c) \
  52. ((g_ascii_table[(guchar) (c)] & G_ASCII_ALPHA) != 0)
  53. #define g_ascii_iscntrl(c) \
  54. ((g_ascii_table[(guchar) (c)] & G_ASCII_CNTRL) != 0)
  55. #define g_ascii_isdigit(c) \
  56. ((g_ascii_table[(guchar) (c)] & G_ASCII_DIGIT) != 0)
  57. #define g_ascii_isgraph(c) \
  58. ((g_ascii_table[(guchar) (c)] & G_ASCII_GRAPH) != 0)
  59. #define g_ascii_islower(c) \
  60. ((g_ascii_table[(guchar) (c)] & G_ASCII_LOWER) != 0)
  61. #define g_ascii_isprint(c) \
  62. ((g_ascii_table[(guchar) (c)] & G_ASCII_PRINT) != 0)
  63. #define g_ascii_ispunct(c) \
  64. ((g_ascii_table[(guchar) (c)] & G_ASCII_PUNCT) != 0)
  65. #define g_ascii_isspace(c) \
  66. ((g_ascii_table[(guchar) (c)] & G_ASCII_SPACE) != 0)
  67. #define g_ascii_isupper(c) \
  68. ((g_ascii_table[(guchar) (c)] & G_ASCII_UPPER) != 0)
  69. #define g_ascii_isxdigit(c) \
  70. ((g_ascii_table[(guchar) (c)] & G_ASCII_XDIGIT) != 0)
  71. gchar g_ascii_tolower (gchar c) G_GNUC_CONST;
  72. gchar g_ascii_toupper (gchar c) G_GNUC_CONST;
  73. gint g_ascii_digit_value (gchar c) G_GNUC_CONST;
  74. gint g_ascii_xdigit_value (gchar c) G_GNUC_CONST;
  75. /* String utility functions that modify a string argument or
  76. * return a constant string that must not be freed.
  77. */
  78. #define G_STR_DELIMITERS "_-|> <."
  79. gchar* g_strdelimit (gchar *string,
  80. const gchar *delimiters,
  81. gchar new_delimiter);
  82. gchar* g_strcanon (gchar *string,
  83. const gchar *valid_chars,
  84. gchar substitutor);
  85. G_CONST_RETURN gchar* g_strerror (gint errnum) G_GNUC_CONST;
  86. G_CONST_RETURN gchar* g_strsignal (gint signum) G_GNUC_CONST;
  87. gchar* g_strreverse (gchar *string);
  88. gsize g_strlcpy (gchar *dest,
  89. const gchar *src,
  90. gsize dest_size);
  91. gsize g_strlcat (gchar *dest,
  92. const gchar *src,
  93. gsize dest_size);
  94. gchar * g_strstr_len (const gchar *haystack,
  95. gssize haystack_len,
  96. const gchar *needle);
  97. gchar * g_strrstr (const gchar *haystack,
  98. const gchar *needle);
  99. gchar * g_strrstr_len (const gchar *haystack,
  100. gssize haystack_len,
  101. const gchar *needle);
  102. gboolean g_str_has_suffix (const gchar *str,
  103. const gchar *suffix);
  104. gboolean g_str_has_prefix (const gchar *str,
  105. const gchar *prefix);
  106. /* String to/from double conversion functions */
  107. gdouble g_strtod (const gchar *nptr,
  108. gchar **endptr);
  109. gdouble g_ascii_strtod (const gchar *nptr,
  110. gchar **endptr);
  111. guint64 g_ascii_strtoull (const gchar *nptr,
  112. gchar **endptr,
  113. guint base);
  114. gint64 g_ascii_strtoll (const gchar *nptr,
  115. gchar **endptr,
  116. guint base);
  117. /* 29 bytes should enough for all possible values that
  118. * g_ascii_dtostr can produce.
  119. * Then add 10 for good measure */
  120. #define G_ASCII_DTOSTR_BUF_SIZE (29 + 10)
  121. gchar * g_ascii_dtostr (gchar *buffer,
  122. gint buf_len,
  123. gdouble d);
  124. gchar * g_ascii_formatd (gchar *buffer,
  125. gint buf_len,
  126. const gchar *format,
  127. gdouble d);
  128. /* removes leading spaces */
  129. gchar* g_strchug (gchar *string);
  130. /* removes trailing spaces */
  131. gchar* g_strchomp (gchar *string);
  132. /* removes leading & trailing spaces */
  133. #define g_strstrip( string ) g_strchomp (g_strchug (string))
  134. gint g_ascii_strcasecmp (const gchar *s1,
  135. const gchar *s2);
  136. gint g_ascii_strncasecmp (const gchar *s1,
  137. const gchar *s2,
  138. gsize n);
  139. gchar* g_ascii_strdown (const gchar *str,
  140. gssize len) G_GNUC_MALLOC;
  141. gchar* g_ascii_strup (const gchar *str,
  142. gssize len) G_GNUC_MALLOC;
  143. #ifndef G_DISABLE_DEPRECATED
  144. /* The following four functions are deprecated and will be removed in
  145. * the next major release. They use the locale-specific tolower and
  146. * toupper, which is almost never the right thing.
  147. */
  148. gint g_strcasecmp (const gchar *s1,
  149. const gchar *s2);
  150. gint g_strncasecmp (const gchar *s1,
  151. const gchar *s2,
  152. guint n);
  153. gchar* g_strdown (gchar *string);
  154. gchar* g_strup (gchar *string);
  155. #endif /* G_DISABLE_DEPRECATED */
  156. /* String utility functions that return a newly allocated string which
  157. * ought to be freed with g_free from the caller at some point.
  158. */
  159. gchar* g_strdup (const gchar *str) G_GNUC_MALLOC;
  160. gchar* g_strdup_printf (const gchar *format,
  161. ...) G_GNUC_PRINTF (1, 2) G_GNUC_MALLOC;
  162. gchar* g_strdup_vprintf (const gchar *format,
  163. va_list args) G_GNUC_MALLOC;
  164. gchar* g_strndup (const gchar *str,
  165. gsize n) G_GNUC_MALLOC;
  166. gchar* g_strnfill (gsize length,
  167. gchar fill_char) G_GNUC_MALLOC;
  168. gchar* g_strconcat (const gchar *string1,
  169. ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
  170. gchar* g_strjoin (const gchar *separator,
  171. ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
  172. /* Make a copy of a string interpreting C string -style escape
  173. * sequences. Inverse of g_strescape. The recognized sequences are \b
  174. * \f \n \r \t \\ \" and the octal format.
  175. */
  176. gchar* g_strcompress (const gchar *source) G_GNUC_MALLOC;
  177. /* Copy a string escaping nonprintable characters like in C strings.
  178. * Inverse of g_strcompress. The exceptions parameter, if non-NULL, points
  179. * to a string containing characters that are not to be escaped.
  180. *
  181. * Deprecated API: gchar* g_strescape (const gchar *source);
  182. * Luckily this function wasn't used much, using NULL as second parameter
  183. * provides mostly identical semantics.
  184. */
  185. gchar* g_strescape (const gchar *source,
  186. const gchar *exceptions) G_GNUC_MALLOC;
  187. gpointer g_memdup (gconstpointer mem,
  188. guint byte_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(2);
  189. /* NULL terminated string arrays.
  190. * g_strsplit(), g_strsplit_set() split up string into max_tokens tokens
  191. * at delim and return a newly allocated string array.
  192. * g_strjoinv() concatenates all of str_array's strings, sliding in an
  193. * optional separator, the returned string is newly allocated.
  194. * g_strfreev() frees the array itself and all of its strings.
  195. * g_strdupv() copies a NULL-terminated array of strings
  196. * g_strv_length() returns the length of a NULL-terminated array of strings
  197. */
  198. gchar** g_strsplit (const gchar *string,
  199. const gchar *delimiter,
  200. gint max_tokens) G_GNUC_MALLOC;
  201. gchar ** g_strsplit_set (const gchar *string,
  202. const gchar *delimiters,
  203. gint max_tokens) G_GNUC_MALLOC;
  204. gchar* g_strjoinv (const gchar *separator,
  205. gchar **str_array) G_GNUC_MALLOC;
  206. void g_strfreev (gchar **str_array);
  207. gchar** g_strdupv (gchar **str_array) G_GNUC_MALLOC;
  208. guint g_strv_length (gchar **str_array);
  209. gchar* g_stpcpy (gchar *dest,
  210. const char *src);
  211. G_CONST_RETURN gchar *g_strip_context (const gchar *msgid,
  212. const gchar *msgval) G_GNUC_FORMAT(1);
  213. G_CONST_RETURN gchar *g_dgettext (const gchar *domain,
  214. const gchar *msgid) G_GNUC_FORMAT(2);
  215. G_CONST_RETURN gchar *g_dcgettext (const gchar *domain,
  216. const gchar *msgid,
  217. int category) G_GNUC_FORMAT(2);
  218. G_CONST_RETURN gchar *g_dngettext (const gchar *domain,
  219. const gchar *msgid,
  220. const gchar *msgid_plural,
  221. gulong n) G_GNUC_FORMAT(3);
  222. G_CONST_RETURN gchar *g_dpgettext (const gchar *domain,
  223. const gchar *msgctxtid,
  224. gsize msgidoffset) G_GNUC_FORMAT(2);
  225. G_CONST_RETURN gchar *g_dpgettext2 (const gchar *domain,
  226. const gchar *context,
  227. const gchar *msgid) G_GNUC_FORMAT(3);
  228. G_END_DECLS
  229. #endif /* __G_STRFUNCS_H__ */