glib-2.0.vapi 206 KB
Newer Older
1
/* glib-2.0.vala
2
 *
3
 * Copyright (C) 2006-2014  Jürg Billeter
4
 * Copyright (C) 2006-2008  Raffaele Sandrini
5
 * Copyright (C) 2007  Mathias Hasselmann
6 7 8 9
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12 13 14 15
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
16
 *
17 18 19 20
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
21 22 23
 * As a special exception, if you use inline functions from this file, this
 * file does not by itself cause the resulting executable to be covered by
 * the GNU Lesser General Public License.
24
 *
25 26
 * Author:
 * 	Jürg Billeter <j@bitron.ch>
27
 *	Raffaele Sandrini <rasa@gmx.ch>
28
 *	Mathias Hasselmann <mathias.hasselmann@gmx.de>
29 30
 */

31
[SimpleType]
32
[GIR (name = "gboolean")]
33
[CCode (cname = "gboolean", cheader_filename = "glib.h", type_id = "G_TYPE_BOOLEAN", marshaller_type_name = "BOOLEAN", get_value_function = "g_value_get_boolean", set_value_function = "g_value_set_boolean", default_value = "FALSE", type_signature = "b")]
34
[BooleanType]
35
public struct bool {
36 37 38 39 40 41 42
	public string to_string () {
		if (this) {
			return "true";
		} else {
			return "false";
		}
	}
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

	public static bool parse (string str) {
		if (str == "true") {
			return true;
		} else {
			return false;
		}
	}
	public static bool try_parse (string str, out bool result = null) {
		if (str == "true") {
			result = true;
			return true;
		} else if (str == "false") {
			result = false;
			return true;
		} else {
			result = false;
			return false;
		}
	}
63 64
}

65
[SimpleType]
66
[GIR (name = "gint8")]
67
[CCode (cname = "gchar", cprefix = "g_ascii_", cheader_filename = "glib.h", type_id = "G_TYPE_CHAR", marshaller_type_name = "CHAR", get_value_function = "g_value_get_schar", set_value_function = "g_value_set_schar", default_value = "\'\\0\'", type_signature = "y")]
68
[IntegerType (rank = 2, min = 0, max = 127)]
69
public struct char {
70
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
71
	public string to_string (string format = "%c");
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
	public bool isalnum ();
	public bool isalpha ();
	public bool iscntrl ();
	public bool isdigit ();
	public bool isgraph ();
	public bool islower ();
	public bool isprint ();
	public bool ispunct ();
	public bool isspace ();
	public bool isupper ();
	public bool isxdigit ();
	public int digit_value ();
	public int xdigit_value ();
	public char tolower ();
	public char toupper ();
87

88 89 90 91
	[CCode (cname = "MIN")]
	public static char min (char a, char b);
	[CCode (cname = "MAX")]
	public static char max (char a, char b);
92 93
	[CCode (cname = "CLAMP")]
	public char clamp (char low, char high);
94 95
}

96
[SimpleType]
97
[GIR (name = "guint8")]
98
[CCode (cname = "guchar", cheader_filename = "glib.h", type_id = "G_TYPE_UCHAR", marshaller_type_name = "UCHAR", get_value_function = "g_value_get_uchar", set_value_function = "g_value_set_uchar", default_value = "\'\\0\'", type_signature = "y")]
99
[IntegerType (rank = 3, min = 0, max = 255)]
100
public struct uchar {
101
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
102
	public string to_string (string format = "%hhu");
103

104 105 106 107
	[CCode (cname = "MIN")]
	public static uchar min (uchar a, uchar b);
	[CCode (cname = "MAX")]
	public static uchar max (uchar a, uchar b);
108 109
	[CCode (cname = "CLAMP")]
	public uchar clamp (uchar low, uchar high);
110 111
}

112
[SimpleType]
113
[GIR (name = "gint")]
114
[CCode (cname = "gint", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0", type_signature = "i")]
115
[IntegerType (rank = 6)]
116
public struct int {
117
	[CCode (cname = "G_MININT")]
118
	public const int MIN;
119
	[CCode (cname = "G_MAXINT")]
120
	public const int MAX;
121

122
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
123
	public string to_string (string format = "%i");
124

125 126 127 128
	[CCode (cname = "MIN")]
	public static int min (int a, int b);
	[CCode (cname = "MAX")]
	public static int max (int a, int b);
129 130
	[CCode (cname = "CLAMP")]
	public int clamp (int low, int high);
131

Jürg Billeter's avatar
Jürg Billeter committed
132
	[CCode (cname = "GINT_TO_POINTER")]
133
	public void* to_pointer ();
134 135
	[CCode (cname = "GPOINTER_TO_INT")]
	public static int from_pointer (void* p);
136

137
	[CCode (cname = "abs", cheader_filename = "stdlib.h")]
138
	public int abs ();
139 140 141 142 143 144 145 146 147 148

	[CCode (cname = "GINT_TO_BE")]
	public int to_big_endian ();
	[CCode (cname = "GINT_TO_LE")]
	public int to_little_endian ();

	[CCode (cname = "GINT_FROM_BE")]
	public static int from_big_endian (int val);
	[CCode (cname = "GINT_FROM_LE")]
	public static int from_little_endian (int val);
149 150 151

	[CCode (cname = "atoi", cheader_filename = "stdlib.h")]
	public static int parse (string str);
152 153
}

154
[SimpleType]
155
[GIR (name = "guint")]
156
[CCode (cname = "guint", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "u")]
157
[IntegerType (rank = 7)]
158
public struct uint {
159
	[CCode (cname = "0")]
160
	public const uint MIN;
161
	[CCode (cname = "G_MAXUINT")]
162
	public const uint MAX;
163

164
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
165
	public string to_string (string format = "%u");
166

167 168 169 170
	[CCode (cname = "MIN")]
	public static uint min (uint a, uint b);
	[CCode (cname = "MAX")]
	public static uint max (uint a, uint b);
171 172
	[CCode (cname = "CLAMP")]
	public uint clamp (uint low, uint high);
173

Jürg Billeter's avatar
Jürg Billeter committed
174
	[CCode (cname = "GUINT_TO_POINTER")]
175
	public void* to_pointer ();
176 177
	[CCode (cname = "GPOINTER_TO_UINT")]
	public static uint from_pointer (void* p);
178 179 180 181 182 183 184 185 186 187

	[CCode (cname = "GUINT_TO_BE")]
	public uint to_big_endian ();
	[CCode (cname = "GUINT_TO_LE")]
	public uint to_little_endian ();

	[CCode (cname = "GUINT_FROM_BE")]
	public static uint from_big_endian (uint val);
	[CCode (cname = "GUINT_FROM_LE")]
	public static uint from_little_endian (uint val);
188 189
}

190
[SimpleType]
191
[GIR (name = "gshort")]
192
[CCode (cname = "gshort", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0", type_signature = "n")]
193
[IntegerType (rank = 4, min = -32768, max = 32767)]
194
public struct short {
195
	[CCode (cname = "G_MINSHORT")]
196
	public const short MIN;
197
	[CCode (cname = "G_MAXSHORT")]
198
	public const short MAX;
199

200
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
201
	public string to_string (string format = "%hi");
202

203 204 205 206
	[CCode (cname = "MIN")]
	public static short min (short a, short b);
	[CCode (cname = "MAX")]
	public static short max (short a, short b);
207 208
	[CCode (cname = "CLAMP")]
	public short clamp (short low, short high);
209
	[CCode (cname = "abs", cheader_filename = "stdlib.h")]
210
	public short abs ();
211 212
}

213
[SimpleType]
214
[GIR (name = "gushort")]
215
[CCode (cname = "gushort", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "q")]
216
[IntegerType (rank = 5, min = 0, max = 65535)]
217
public struct ushort {
218
	[CCode (cname = "0U")]
219
	public const ushort MIN;
220
	[CCode (cname = "G_MAXUSHORT")]
221
	public const ushort MAX;
222

223
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
224
	public string to_string (string format = "%hu");
225

226 227 228 229
	[CCode (cname = "MIN")]
	public static ushort min (ushort a, ushort b);
	[CCode (cname = "MAX")]
	public static ushort max (ushort a, ushort b);
230 231
	[CCode (cname = "CLAMP")]
	public ushort clamp (ushort low, ushort high);
232 233
}

234
[SimpleType]
235
[GIR (name = "glong")]
236
[CCode (cname = "glong", cheader_filename = "glib.h", type_id = "G_TYPE_LONG", marshaller_type_name = "LONG", get_value_function = "g_value_get_long", set_value_function = "g_value_set_long", default_value = "0L")]
237
[IntegerType (rank = 8)]
238
public struct long {
239
	[CCode (cname = "G_MINLONG")]
240
	public const long MIN;
241
	[CCode (cname = "G_MAXLONG")]
242
	public const long MAX;
243

244
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
245
	public string to_string (string format = "%li");
246

247 248 249 250
	[CCode (cname = "MIN")]
	public static long min (long a, long b);
	[CCode (cname = "MAX")]
	public static long max (long a, long b);
251 252
	[CCode (cname = "CLAMP")]
	public long clamp (long low, long high);
253
	[CCode (cname = "labs", cheader_filename = "stdlib.h")]
254
	public long abs ();
255 256 257 258 259 260 261 262 263 264

	[CCode (cname = "GLONG_TO_BE")]
	public long to_big_endian ();
	[CCode (cname = "GLONG_TO_LE")]
	public long to_little_endian ();

	[CCode (cname = "GLONG_FROM_BE")]
	public static long from_big_endian (long val);
	[CCode (cname = "GLONG_FROM_LE")]
	public static long from_little_endian (long val);
265 266 267

	[CCode (cname = "atol", cheader_filename = "stdlib.h")]
	public static long parse (string str);
268 269
}

270
[SimpleType]
271
[GIR (name = "gulong")]
272
[CCode (cname = "gulong", cheader_filename = "glib.h", type_id = "G_TYPE_ULONG", marshaller_type_name = "ULONG", get_value_function = "g_value_get_ulong", set_value_function = "g_value_set_ulong", default_value = "0UL")]
273
[IntegerType (rank = 9)]
274
public struct ulong {
275
	[CCode (cname = "0UL")]
276
	public const ulong MIN;
277
	[CCode (cname = "G_MAXULONG")]
278
	public const ulong MAX;
279

280
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
281
	public string to_string (string format = "%lu");
282

283 284 285 286
	[CCode (cname = "MIN")]
	public static ulong min (ulong a, ulong b);
	[CCode (cname = "MAX")]
	public static ulong max (ulong a, ulong b);
287 288
	[CCode (cname = "CLAMP")]
	public ulong clamp (ulong low, ulong high);
289 290 291 292 293 294 295 296 297 298

	[CCode (cname = "GULONG_TO_BE")]
	public ulong to_big_endian ();
	[CCode (cname = "GULONG_TO_LE")]
	public ulong to_little_endian ();

	[CCode (cname = "GULONG_FROM_BE")]
	public static ulong from_big_endian (ulong val);
	[CCode (cname = "GULONG_FROM_LE")]
	public static ulong from_little_endian (ulong val);
299 300
}

Jürg Billeter's avatar
Jürg Billeter committed
301
[SimpleType]
302
[GIR (name = "gulong")]
Jürg Billeter's avatar
Jürg Billeter committed
303
[CCode (cname = "gsize", cheader_filename = "glib.h", type_id = "G_TYPE_ULONG", marshaller_type_name = "ULONG", get_value_function = "g_value_get_ulong", set_value_function = "g_value_set_ulong", default_value = "0UL")]
304
[IntegerType (rank = 9)]
Jürg Billeter's avatar
Jürg Billeter committed
305 306
public struct size_t {
	[CCode (cname = "0UL")]
307
	public const ulong MIN;
308
	[Version (since = "2.4")]
Jürg Billeter's avatar
Jürg Billeter committed
309
	[CCode (cname = "G_MAXSIZE")]
310
	public const ulong MAX;
Jürg Billeter's avatar
Jürg Billeter committed
311

312
	[Version (since = "2.6")]
313 314
	[CCode (cname = "G_GSIZE_FORMAT")]
	public const string FORMAT;
315
	[Version (since = "2.6")]
316 317 318
	[CCode (cname = "G_GSIZE_MODIFIER")]
	public const string FORMAT_MODIFIER;

319
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
320
	public string to_string (string format = "%" + FORMAT);
Jürg Billeter's avatar
Jürg Billeter committed
321 322

	[CCode (cname = "GSIZE_TO_POINTER")]
323
	public void* to_pointer ();
324 325
	[CCode (cname = "GPOINTER_TO_SIZE")]
	public static size_t from_pointer (void* p);
326

327 328 329 330
	[CCode (cname = "MIN")]
	public static size_t min (size_t a, size_t b);
	[CCode (cname = "MAX")]
	public static size_t max (size_t a, size_t b);
331 332
	[CCode (cname = "CLAMP")]
	public size_t clamp (size_t low, size_t high);
Jürg Billeter's avatar
Jürg Billeter committed
333 334 335
}

[SimpleType]
336
[GIR (name = "glong")]
Jürg Billeter's avatar
Jürg Billeter committed
337
[CCode (cname = "gssize", cheader_filename = "glib.h", type_id = "G_TYPE_LONG", marshaller_type_name = "LONG", get_value_function = "g_value_get_long", set_value_function = "g_value_set_long", default_value = "0L")]
338
[IntegerType (rank = 8)]
Jürg Billeter's avatar
Jürg Billeter committed
339
public struct ssize_t {
340
	[Version (since = "2.14")]
Jürg Billeter's avatar
Jürg Billeter committed
341
	[CCode (cname = "G_MINSSIZE")]
342
	public const long MIN;
343
	[Version (since = "2.14")]
Jürg Billeter's avatar
Jürg Billeter committed
344
	[CCode (cname = "G_MAXSSIZE")]
345
	public const long MAX;
Jürg Billeter's avatar
Jürg Billeter committed
346

347
	[Version (since = "2.6")]
348 349 350 351 352
	[CCode (cname = "G_GSSIZE_FORMAT")]
	public const string FORMAT;
	[CCode (cname = "G_GSIZE_MODIFIER")]
	public const string FORMAT_MODIFIER;

353
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
354
	public string to_string (string format = "%" + FORMAT);
355

356 357 358 359
	[CCode (cname = "MIN")]
	public static ssize_t min (ssize_t a, ssize_t b);
	[CCode (cname = "MAX")]
	public static ssize_t max (ssize_t a, ssize_t b);
360 361
	[CCode (cname = "CLAMP")]
	public ssize_t clamp (ssize_t low, ssize_t high);
Jürg Billeter's avatar
Jürg Billeter committed
362 363
}

364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
[SimpleType]
[GIR (name = "gulong")]
[CCode (cname = "guintptr", cheader_filename = "glib.h", type_id = "G_TYPE_ULONG", marshaller_type_name = "ULONG", get_value_function = "g_value_get_ulong", set_value_function = "g_value_set_ulong", default_value = "0UL")]
[IntegerType (rank = 9)]
public struct uintptr {
	[CCode (cname = "0UL")]
	public const ulong MIN;
	[CCode (cname = "G_MAXSIZE")]
	public const ulong MAX;

	[CCode (cname = "G_GUINTPTR_FORMAT")]
	public const string FORMAT;
	[CCode (cname = "G_GINTPTR_MODIFIER")]
	public const string FORMAT_MODIFIER;

	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
	public string to_string (string format = "%" + FORMAT);

	[CCode (cname = "GSIZE_TO_POINTER")]
	public void* to_pointer ();
384 385
	[CCode (cname = "GPOINTER_TO_SIZE")]
	public static uintptr from_pointer (void* p);
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420

	[CCode (cname = "MIN")]
	public static uintptr min (uintptr a, uintptr b);
	[CCode (cname = "MAX")]
	public static uintptr max (uintptr a, uintptr b);
	[CCode (cname = "CLAMP")]
	public uintptr clamp (uintptr low, uintptr high);
}

[SimpleType]
[GIR (name = "glong")]
[CCode (cname = "gintptr", cheader_filename = "glib.h", type_id = "G_TYPE_LONG", marshaller_type_name = "LONG", get_value_function = "g_value_get_long", set_value_function = "g_value_set_long", default_value = "0L")]
[IntegerType (rank = 8)]
public struct intptr {
	[CCode (cname = "G_MINSSIZE")]
	public const long MIN;
	[CCode (cname = "G_MAXSSIZE")]
	public const long MAX;

	[CCode (cname = "G_GINTPTR_FORMAT")]
	public const string FORMAT;
	[CCode (cname = "G_GINTPTR_MODIFIER")]
	public const string FORMAT_MODIFIER;

	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
	public string to_string (string format = "%" + FORMAT);

	[CCode (cname = "MIN")]
	public static intptr min (intptr a, intptr b);
	[CCode (cname = "MAX")]
	public static intptr max (intptr a, intptr b);
	[CCode (cname = "CLAMP")]
	public intptr clamp (intptr low, intptr high);
}

421
[SimpleType]
422
[GIR (name = "gint8")]
423
[CCode (cname = "gint8", cheader_filename = "glib.h", type_id = "G_TYPE_CHAR", marshaller_type_name = "CHAR", get_value_function = "g_value_get_char", set_value_function = "g_value_set_char", default_value = "0", type_signature = "y")]
424
[IntegerType (rank = 1, min = -128, max = 127)]
425
public struct int8 {
426
	[Version (since = "2.4")]
427
	[CCode (cname = "G_MININT8")]
428
	public const int8 MIN;
429
	[Version (since = "2.4")]
430
	[CCode (cname = "G_MAXINT8")]
431
	public const int8 MAX;
432

433
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
434
	public string to_string (string format = "%hhi");
435

436 437 438 439
	[CCode (cname = "MIN")]
	public static int8 min (int8 a, int8 b);
	[CCode (cname = "MAX")]
	public static int8 max (int8 a, int8 b);
440 441
	[CCode (cname = "CLAMP")]
	public int8 clamp (int8 low, int8 high);
442 443
}

444
[SimpleType]
445
[GIR (name = "guint8")]
446
[CCode (cname = "guint8", cheader_filename = "glib.h", type_id = "G_TYPE_UCHAR", marshaller_type_name = "UCHAR", get_value_function = "g_value_get_uchar", set_value_function = "g_value_set_uchar", default_value = "0U", type_signature = "y")]
447
[IntegerType (rank = 3, min = 0, max = 255)]
448 449
public struct uint8 {
	[CCode (cname = "0U")]
450
	public const uint8 MIN;
451
	[Version (since = "2.4")]
452
	[CCode (cname = "G_MAXUINT8")]
453
	public const uint8 MAX;
454

455
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
456
	public string to_string (string format = "%hhu");
457

458 459 460 461
	[CCode (cname = "MIN")]
	public static uint8 min (uint8 a, uint8 b);
	[CCode (cname = "MAX")]
	public static uint8 max (uint8 a, uint8 b);
462 463
	[CCode (cname = "CLAMP")]
	public uint8 clamp (uint8 low, uint8 high);
464 465
}

466
[SimpleType]
467
[GIR (name = "gint16")]
468
[CCode (cname = "gint16", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0", type_signature = "n")]
469
[IntegerType (rank = 4, min = -32768, max = 32767)]
470
public struct int16 {
471
	[Version (since = "2.4")]
472
	[CCode (cname = "G_MININT16")]
473
	public const int16 MIN;
474
	[Version (since = "2.4")]
475
	[CCode (cname = "G_MAXINT16")]
476
	public const int16 MAX;
477

478 479
	[CCode (cname = "G_GINT16_FORMAT")]
	public const string FORMAT;
480
	[Version (since = "2.4")]
481 482 483
	[CCode (cname = "G_GINT16_MODIFIER")]
	public const string FORMAT_MODIFIER;

484
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
485
	public string to_string (string format = "%" + FORMAT);
486

487 488 489 490
	[CCode (cname = "MIN")]
	public static int16 min (int16 a, int16 b);
	[CCode (cname = "MAX")]
	public static int16 max (int16 a, int16 b);
491 492
	[CCode (cname = "CLAMP")]
	public int16 clamp (int16 low, int16 high);
493 494 495 496 497 498 499 500 501 502

	[CCode (cname = "GINT16_TO_BE")]
	public int16 to_big_endian ();
	[CCode (cname = "GINT16_TO_LE")]
	public int16 to_little_endian ();

	[CCode (cname = "GINT16_FROM_BE")]
	public static int16 from_big_endian (int16 val);
	[CCode (cname = "GINT16_FROM_LE")]
	public static int16 from_little_endian (int16 val);
503 504
}

505
[SimpleType]
506
[GIR (name = "guint16")]
507
[CCode (cname = "guint16", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "q")]
508
[IntegerType (rank = 5, min = 0, max = 65535)]
509
public struct uint16 {
510
	[CCode (cname = "0U")]
511
	public const uint16 MIN;
512
	[Version (since = "2.4")]
513
	[CCode (cname = "G_MAXUINT16")]
514
	public const uint16 MAX;
515

516 517 518 519 520
	[CCode (cname = "G_GUINT16_FORMAT")]
	public const string FORMAT;
	[CCode (cname = "G_GINT16_MODIFIER")]
	public const string FORMAT_MODIFIER;

521
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
522
	public string to_string (string format = "%hu");
523

524 525 526 527
	[CCode (cname = "MIN")]
	public static uint16 min (uint16 a, uint16 b);
	[CCode (cname = "MAX")]
	public static uint16 max (uint16 a, uint16 b);
528 529
	[CCode (cname = "CLAMP")]
	public uint16 clamp (uint16 low, uint16 high);
530 531 532 533 534 535 536 537 538 539

	[CCode (cname = "GUINT16_TO_BE")]
	public uint16 to_big_endian ();
	[CCode (cname = "GUINT16_TO_LE")]
	public uint16 to_little_endian ();

	[CCode (cname = "GUINT16_FROM_BE")]
	public static uint16 from_big_endian (uint16 val);
	[CCode (cname = "GUINT16_FROM_LE")]
	public static uint16 from_little_endian (uint16 val);
540

541 542 543 544 545
	[CCode (cname = "g_htons")]
	public static uint16 to_network (uint16 val);
	[CCode (cname = "g_ntohs")]
	public static uint16 from_network (uint16 val);

546 547 548 549 550 551
	[CCode (cname = "GUINT16_SWAP_BE_PDP")]
	public uint16 swap_big_endian_pdp ();
	[CCode (cname = "GUINT16_SWAP_LE_BE")]
	public uint16 swap_little_endian_big_endian ();
	[CCode (cname = "GUINT16_SWAP_LE_PDP")]
	public uint16 swap_little_endian_pdp ();
552 553
}

554
[SimpleType]
555
[GIR (name = "gint32")]
556
[CCode (cname = "gint32", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0", type_signature = "i")]
557
[IntegerType (rank = 6)]
558
public struct int32 {
559
	[Version (since = "2.4")]
560
	[CCode (cname = "G_MININT32")]
561
	public const int32 MIN;
562
	[Version (since = "2.4")]
563
	[CCode (cname = "G_MAXINT32")]
564
	public const int32 MAX;
565

566 567
	[CCode (cname = "G_GINT32_FORMAT")]
	public const string FORMAT;
568
	[Version (since = "2.4")]
569 570 571
	[CCode (cname = "G_GINT32_MODIFIER")]
	public const string FORMAT_MODIFIER;

572
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
573
	public string to_string (string format = "%i");
574

575 576 577 578
	[CCode (cname = "MIN")]
	public static int32 min (int32 a, int32 b);
	[CCode (cname = "MAX")]
	public static int32 max (int32 a, int32 b);
579 580
	[CCode (cname = "CLAMP")]
	public int32 clamp (int32 low, int32 high);
581 582 583 584 585 586 587 588 589 590

	[CCode (cname = "GINT32_TO_BE")]
	public int32 to_big_endian ();
	[CCode (cname = "GINT32_TO_LE")]
	public int32 to_little_endian ();

	[CCode (cname = "GINT32_FROM_BE")]
	public static int32 from_big_endian (int32 val);
	[CCode (cname = "GINT32_FROM_LE")]
	public static int32 from_little_endian (int32 val);
591 592
}

593
[SimpleType]
594
[GIR (name = "guint32")]
595
[CCode (cname = "guint32", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "u")]
596
[IntegerType (rank = 7)]
597
public struct uint32 {
598
	[CCode (cname = "0U")]
599
	public const uint32 MIN;
600
	[Version (since = "2.4")]
601
	[CCode (cname = "G_MAXUINT32")]
602
	public const uint32 MAX;
603

604 605 606 607 608
	[CCode (cname = "G_GUINT32_FORMAT")]
	public const string FORMAT;
	[CCode (cname = "G_GINT32_MODIFIER")]
	public const string FORMAT_MODIFIER;

609
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
610
	public string to_string (string format = "%u");
611

612 613 614 615
	[CCode (cname = "MIN")]
	public static uint32 min (uint32 a, uint32 b);
	[CCode (cname = "MAX")]
	public static uint32 max (uint32 a, uint32 b);
616 617
	[CCode (cname = "CLAMP")]
	public uint32 clamp (uint32 low, uint32 high);
618 619 620 621 622 623 624 625 626 627

	[CCode (cname = "GUINT32_TO_BE")]
	public uint32 to_big_endian ();
	[CCode (cname = "GUINT32_TO_LE")]
	public uint32 to_little_endian ();

	[CCode (cname = "GUINT32_FROM_BE")]
	public static uint32 from_big_endian (uint32 val);
	[CCode (cname = "GUINT32_FROM_LE")]
	public static uint32 from_little_endian (uint32 val);
628

629 630 631 632 633
	[CCode (cname = "g_htonl")]
	public static uint32 to_network (uint32 val);
	[CCode (cname = "g_ntohl")]
	public static uint32 from_network (uint32 val);

634 635 636 637 638 639
	[CCode (cname = "GUINT32_SWAP_BE_PDP")]
	public uint32 swap_big_endian_pdp ();
	[CCode (cname = "GUINT32_SWAP_LE_BE")]
	public uint32 swap_little_endian_big_endian ();
	[CCode (cname = "GUINT32_SWAP_LE_PDP")]
	public uint32 swap_little_endian_pdp ();
640 641
}

642
[SimpleType]
643
[GIR (name = "gint64")]
644
[CCode (cname = "gint64", cheader_filename = "glib.h", type_id = "G_TYPE_INT64", marshaller_type_name = "INT64", get_value_function = "g_value_get_int64", set_value_function = "g_value_set_int64", default_value = "0LL", type_signature = "x")]
645
[IntegerType (rank = 10)]
646
public struct int64 {
647
	[CCode (cname = "G_MININT64")]
648
	public const int64 MIN;
649
	[CCode (cname = "G_MAXINT64")]
650
	public const int64 MAX;
651

652 653
	[CCode (cname = "G_GINT64_FORMAT")]
	public const string FORMAT;
654
	[Version (since = "2.4")]
655 656 657
	[CCode (cname = "G_GINT64_MODIFIER")]
	public const string FORMAT_MODIFIER;

658
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
659
	public string to_string (string format = "%" + FORMAT);
660

661 662 663 664
	[CCode (cname = "MIN")]
	public static int64 min (int64 a, int64 b);
	[CCode (cname = "MAX")]
	public static int64 max (int64 a, int64 b);
665 666
	[CCode (cname = "CLAMP")]
	public int64 clamp (int64 low, int64 high);
667
	[CCode (cname = "llabs", cheader_filename = "stdlib.h")]
668
	public int64 abs ();
669 670 671 672 673 674 675 676 677 678

	[CCode (cname = "GINT64_TO_BE")]
	public int64 to_big_endian ();
	[CCode (cname = "GINT64_TO_LE")]
	public int64 to_little_endian ();

	[CCode (cname = "GINT64_FROM_BE")]
	public static int64 from_big_endian (int64 val);
	[CCode (cname = "GINT64_FROM_LE")]
	public static int64 from_little_endian (int64 val);
679 680 681

	[CCode (cname = "GUINT64_SWAP_LE_BE")]
	public uint64 swap_little_endian_big_endian ();
682 683 684 685

	[CCode (cname = "g_ascii_strtoll")]
	static int64 ascii_strtoll (string nptr, out char* endptr, uint _base);

686
	[Version (since = "2.12")]
687 688 689
	public static int64 parse (string str) {
		return ascii_strtoll (str, null, 0);
	}
690 691

	[Version (since = "2.12")]
692
	public static bool try_parse (string str, out int64 result = null, out unowned string unparsed = null) {
693 694 695
		char* endptr;
		result = ascii_strtoll (str, out endptr, 0);
		if (endptr == (char*) str + str.length) {
696
			unparsed = "";
697 698
			return true;
		} else {
699
			unparsed = (string) endptr;
700 701 702
			return false;
		}
	}
703 704 705 706

	[CCode (cname = "g_ascii_string_to_signed")]
	[Version (since = "2.54")]
	public static bool from_string (string str, [CCode (pos = 5.1)] out int64 out_num = null, uint @base = 10U, int64 min = int64.MIN, int64 max = int64.MAX) throws GLib.NumberParserError;
707 708
}

709
[SimpleType]
710
[GIR (name = "guint64")]
711
[CCode (cname = "guint64", cheader_filename = "glib.h", type_id = "G_TYPE_UINT64", marshaller_type_name = "UINT64", get_value_function = "g_value_get_uint64", set_value_function = "g_value_set_uint64", default_value = "0ULL", type_signature = "t")]
712
[IntegerType (rank = 11)]
713
public struct uint64 {
714
	[CCode (cname = "0ULL")]
715
	public const uint64 MIN;
716
	[CCode (cname = "G_MAXUINT64")]
717
	public const uint64 MAX;
718

719 720 721 722 723
	[CCode (cname = "G_GUINT64_FORMAT")]
	public const string FORMAT;
	[CCode (cname = "G_GINT64_MODIFIER")]
	public const string FORMAT_MODIFIER;

724
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
725
	public string to_string (string format = "%" + FORMAT);
726

727 728 729 730
	[CCode (cname = "MIN")]
	public static uint64 min (uint64 a, uint64 b);
	[CCode (cname = "MAX")]
	public static uint64 max (uint64 a, uint64 b);
731 732
	[CCode (cname = "CLAMP")]
	public uint64 clamp (uint64 low, uint64 high);
733 734 735 736 737 738 739 740 741 742

	[CCode (cname = "GUINT64_TO_BE")]
	public uint64 to_big_endian ();
	[CCode (cname = "GUINT64_TO_LE")]
	public uint64 to_little_endian ();

	[CCode (cname = "GUINT64_FROM_BE")]
	public static uint64 from_big_endian (uint64 val);
	[CCode (cname = "GUINT64_FROM_LE")]
	public static uint64 from_little_endian (uint64 val);
743 744 745 746 747 748 749

	[CCode (cname = "g_ascii_strtoull")]
	static uint64 ascii_strtoull (string nptr, out char* endptr, uint _base);

	public static uint64 parse (string str) {
		return ascii_strtoull (str, null, 0);
	}
750
	public static bool try_parse (string str, out uint64 result = null, out unowned string unparsed = null) {
751 752 753
		char* endptr;
		result = ascii_strtoull (str, out endptr, 0);
		if (endptr == (char*) str + str.length) {
754
			unparsed = "";
755 756
			return true;
		} else {
757
			unparsed = (string) endptr;
758 759 760
			return false;
		}
	}
761 762 763 764

	[CCode (cname = "g_ascii_string_to_unsigned")]
	[Version (since = "2.54")]
	public static bool from_string (string str, [CCode (pos = 5.1)] out uint64 out_num = null, uint @base = 10U, uint64 min = uint64.MIN, uint64 max = uint64.MAX) throws GLib.NumberParserError;
765 766
}

767
[SimpleType]
768
[GIR (name = "gfloat")]
769
[CCode (cname = "gfloat", cheader_filename = "glib.h,float.h,math.h", type_id = "G_TYPE_FLOAT", marshaller_type_name = "FLOAT", get_value_function = "g_value_get_float", set_value_function = "g_value_set_float", default_value = "0.0F")]
770
[FloatingType (rank = 1)]
771
public struct float {
772
	[CCode (cname = "FLT_ROUNDS")]
773
	public const int ROUNDS;
774
	[CCode (cname = "FLT_RADIX")]
775
	public const int RADIX;
776
	[CCode (cname = "FLT_MANT_DIG")]
777
	public const int MANT_DIG;
778
	[CCode (cname = "FLT_DIG")]
779
	public const int DIG;
780 781

	[CCode (cname = "FLT_MIN_EXP")]
782
	public const int MIN_EXP;
783
	[CCode (cname = "FLT_MAX_EXP")]
784
	public const int MAX_EXP;
785 786

	[CCode (cname = "FLT_MIN_10_EXP")]
787
	public const int MIN_10_EXP;
788
	[CCode (cname = "FLT_MAX_10_EXP")]
789
	public const int MAX_10_EXP;
790 791

	[CCode (cname = "FLT_EPSILON")]
792
	public const float EPSILON;
793
	[CCode (cname = "FLT_MIN")]
794
	public const float MIN;
795
	[CCode (cname = "FLT_MAX")]
796
	public const float MAX;
797 798

	[CCode (cname = "NAN")]
799
	public const float NAN;
800
	[CCode (cname = "INFINITY")]
801
	public const float INFINITY;
802 803 804 805 806 807 808 809 810 811

	[CCode (cname = "isnan")]
	public bool is_nan ();
	[CCode (cname = "isfinite")]
	public bool is_finite ();
	[CCode (cname = "isnormal")]
	public bool is_normal ();
	[CCode (cname = "isinf")]
	public int is_infinity ();

812
	[CCode (cname = "g_strdup_printf", instance_pos = -1)]
813
	public string to_string (string format = "%g");
814

815 816 817 818
	[CCode (cname = "MIN")]
	public static float min (float a, float b);
	[CCode (cname = "MAX")]
	public static float max (float a, float b);
819 820
	[CCode (cname = "CLAMP")]
	public float clamp (float low, float high);
821 822
	[CCode (cname = "fabsf")]
	public float abs ();
823 824
}

825
[SimpleType]
826
[GIR (name = "gdouble")]
827
[CCode (cname = "gdouble", cheader_filename = "glib.h,float.h,math.h", type_id = "G_TYPE_DOUBLE", marshaller_type_name = "DOUBLE", get_value_function = "g_value_get_double", set_value_function = "g_value_set_double", default_value = "0.0", type_signature = "d")]
828
[FloatingType (rank = 2)]
829
public struct double {
830
	[CCode (cname = "DBL_MANT_DIG")]
831
	public const int MANT_DIG;
832
	[CCode (cname = "DBL_DIG")]
833
	public const int DIG;
834 835

	[CCode (cname = "DBL_MIN_EXP")]
836
	public const int MIN_EXP;
837
	[CCode (cname = "DBL_MAX_EXP")]
838
	public const int MAX_EXP;
839 840

	[CCode (cname = "DBL_MIN_10_EXP")]
841
	public const int MIN_10_EXP;
842
	[CCode (cname = "DBL_MAX_10_EXP")]
843
	public const int MAX_10_EXP;
844 845

	[CCode (cname = "DBL_EPSILON")]
846
	public const double EPSILON;
847
	[CCode (cname = "DBL_MIN")]
848
	public const double MIN;
849
	[CCode (cname = "DBL_MAX")]
850
	public const double MAX;
851 852

	[CCode (cname = "((double) NAN)")]
853
	public const double NAN;
854
	[CCode (cname = "((double) INFINITY)")]
855
	public const double INFINITY;
856 857 858 859 860 861 862 863 864 865

	[CCode (cname = "isnan")]
	public bool is_nan ();
	[CCode (cname = "isfinite")]
	public bool is_finite ();
	[CCode (cname = "isnormal")]
	public bool is_normal ();
	[CCode (cname = "isinf")]
	public int is_infinity ();

866 867 868 869
	[CCode (cname = "MIN")]
	public static double min (double a, double b);
	[CCode (cname = "MAX")]
	public static double max (double a, double b);
870 871
	[CCode (cname = "CLAMP")]
	public double clamp (double low, double high);
872 873
	[CCode (cname = "fabs")]
	public double abs ();
874 875 876 877

	[CCode (cname = "G_ASCII_DTOSTR_BUF_SIZE")]
	public const int DTOSTR_BUF_SIZE;
	[CCode (cname = "g_ascii_dtostr", instance_pos = -1)]
878
	public unowned string to_str (char[] buffer);
879
	[CCode (cname = "g_ascii_formatd", instance_pos = -1)]
880
	public unowned string format (char[] buffer, string format = "%g");
881 882 883 884

	public string to_string () {
		return this.to_str(new char[DTOSTR_BUF_SIZE]);
	}
885 886 887 888 889 890 891

	[CCode (cname = "g_ascii_strtod")]
	static double ascii_strtod (string nptr, out char* endptr);

	public static double parse (string str) {
		return ascii_strtod (str, null);
	}
892
	public static bool try_parse (string str, out double result = null, out unowned string unparsed = null) {
893 894 895
		char* endptr;
		result = ascii_strtod (str, out endptr);
		if (endptr == (char*) str + str.length) {
896
			unparsed = "";
897 898
			return true;
		} else {
899
			unparsed = (string) endptr;
900 901 902
			return false;
		}
	}
903 904
}

905
[GIR (name = "glong")]
906
[CCode (cheader_filename = "time.h", has_type_id = false, default_value = "0")]
907
[IntegerType (rank = 8)]
908 909
public struct time_t {
	[CCode (cname = "time")]
Jürg Billeter's avatar
Jürg Billeter committed
910
	public time_t (out time_t result = null);
911 912
}

Jürg Billeter's avatar
Jürg Billeter committed
913
[SimpleType]
914
[CCode (cheader_filename="stdarg.h", cprefix="va_", has_type_id = false, destroy_function = "va_end", lvalue_access = false)]
Jürg Billeter's avatar
Jürg Billeter committed
915 916 917 918 919
public struct va_list {
	[CCode (cname = "va_start")]
	public va_list ();
	[CCode (cname = "va_copy")]
	public va_list.copy (va_list src);
920
	[CCode (generic_type_pos = 1.1, simple_generics = true)]
Jürg Billeter's avatar
Jürg Billeter committed
921 922 923
	public unowned G arg<G> ();
}

924
[SimpleType]
925
[GIR (name = "gunichar")]
926
[CCode (cname = "gunichar", cprefix = "g_unichar_", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "u")]
927
[IntegerType (rank = 7)]
928
public struct unichar {
929
	public bool validate ();
930
	public bool isalnum ();
931 932
	public bool isalpha ();
	public bool iscntrl ();
933
	public bool isdigit ();
934 935
	public bool isgraph ();
	public bool islower ();
936
	[Version (since = "2.14")]
937
	public bool ismark ();
938 939
	public bool isprint ();
	public bool ispunct ();
940
	public bool isspace ();
941
	public bool isupper ();
942
	public bool isxdigit ();
943 944 945
	public bool istitle ();
	public bool isdefined ();
	public bool iswide ();
946
	[Version (since = "2.12")]
947
	public bool iswide_cjk ();
948
	[Version (since = "2.14")]
949
	public bool iszerowidth ();
950
	public unichar toupper ();
951
	public unichar tolower ();
952
	public unichar totitle ();
953 954
	public int digit_value ();
	public int xdigit_value ();
955 956
	public GLib.UnicodeType type ();
	public GLib.UnicodeBreakType break_type ();
957
	[Version (since = "2.14")]
958
	public GLib.UnicodeScript get_script();
959

960
	public int to_utf8 (string? outbuf);
961

962
	public string to_string () {
963 964 965 966 967
		string str = (string) new char[7];
		this.to_utf8 (str);
		return str;
	}

968
	[Version (since = "2.30")]
969
	public bool compose (unichar b, out unichar ch);
970
	[Version (since = "2.30")]
971
	public bool decompose (out unichar a, out unichar b);
972
	[Version (since = "2.30")]
973 974
	public size_t fully_decompose (bool compat, unichar[] result);

975 976 977 978
	[CCode (cname = "MIN")]
	public static unichar min (unichar a, unichar b);
	[CCode (cname = "MAX")]
	public static unichar max (unichar a, unichar b);
979 980
	[CCode (cname = "CLAMP")]
	public unichar clamp (unichar low, unichar high);
981 982 983

	[CCode (cname = "G_UNICHAR_MAX_DECOMPOSITION_LENGTH")]
	public const int MAX_DECOMPOSITION_LENGTH;
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999

	[CCode (cname = "G_GUINT32_FORMAT")]
	public const string FORMAT;
	[CCode (cname = "G_GINT32_MODIFIER")]
	public const string FORMAT_MODIFIER;
}

[SimpleType]
[GIR (name = "guint16")]
[CCode (cname = "gunichar2", cheader_filename = "glib.h", default_value = "0U", type_signature = "q", has_type_id = false)]
[IntegerType (rank = 5)]
public struct unichar2 {
	[CCode (cname = "G_GUINT16_FORMAT")]
	public const string FORMAT;
	[CCode (cname = "G_GINT16_MODIFIER")]
	public const string FORMAT_MODIFIER;
1000 1001
}

1002
[Compact]
1003
[Immutable]
1004
[GIR (name = "utf8")]
1005
[CCode (cname = "gchar", const_cname = "const gchar", copy_function = "g_strdup", free_function = "g_free", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", param_spec_function = "g_param_spec_string", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string", take_value_function = "g_value_take_string", type_signature = "s")]
1006
public class string {
1007
	[Version (replacement = "string.index_of")]
1008
	[CCode (cname = "strstr")]
1009
	public unowned string? str (string needle);
1010
	[Version (replacement = "string.last_index_of")]
1011 1012 1013 1014
	[CCode (cname = "g_strrstr")]
	public unowned string? rstr (string needle);
	[CCode (cname = "g_strrstr_len")]
	public unowned string? rstr_len (ssize_t haystack_len, string needle);
1015 1016 1017

	[CCode (cname = "strstr")]
	static char* strstr (char* haystack, char* needle);
1018 1019
	[CCode (cname = "g_strrstr")]
	static char* strrstr (char* haystack, char* needle);
1020 1021
	[CCode (cname = "g_utf8_strchr")]
	static char* utf8_strchr (char* str, ssize_t len, unichar c);
1022 1023
	[CCode (cname = "g_utf8_strrchr")]
	static char* utf8_strrchr (char* str, ssize_t len, unichar c);
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034

	public int index_of (string needle, int start_index = 0) {
		char* result = strstr ((char*) this + start_index, (char*) needle);

		if (result != null) {
			return (int) (result - (char*) this);
		} else {
			return -1;
		}
	}

1035 1036 1037 1038 1039 1040 1041 1042 1043 1044
	public int last_index_of (string needle, int start_index = 0) {
		char* result = strrstr ((char*) this + start_index, (char*) needle);

		if (result != null) {
			return (int) (result - (char*) this);
		} else {
			return -1;
		}
	}

1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
	public int index_of_char (unichar c, int start_index = 0) {
		char* result = utf8_strchr ((char*) this + start_index, -1, c);

		if (result != null) {
			return (int) (result - (char*) this);
		} else {
			return -1;
		}
	}

1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
	public int last_index_of_char (unichar c, int start_index = 0) {
		char* result = utf8_strrchr ((char*) this + start_index, -1, c);

		if (result != null) {
			return (int) (result - (char*) this);
		} else {
			return -1;
		}
	}

1065
	[Version (since = "2.2")]
1066
	[CCode (cname = "g_str_has_prefix")]
1067
	public bool has_prefix (string prefix);
1068
	[Version (since = "2.2")]
1069
	[CCode (cname = "g_str_has_suffix")]
1070
	public bool has_suffix (string suffix);
1071
	[CCode (cname = "g_strdup_printf"), PrintfFormat]
1072
	public string printf (...);
1073 1074
	[CCode (cname = "g_strdup_vprintf")]
	public string vprintf (va_list args);
1075
	[CCode (cname = "sscanf", cheader_filename = "stdio.h"), ScanfFormat]
1076
	public int scanf (string format, ...);
1077
	[CCode (cname = "g_strconcat")]
1078
	public string concat (string string2, ...);
1079
	[CCode (cname = "g_strescape")]
1080
	public string escape (string? exceptions = null);
1081
	[CCode (cname = "g_strcompress")]
1082
	public string compress ();
1083
	[CCode (cname = "g_strsplit", array_length = false, array_null_terminated = true)]
1084
	public string[] split (string delimiter, int max_tokens = 0);
1085
	[Version (since = "2.4")]
1086
	[CCode (cname = "g_strsplit_set", array_length = false, array_null_terminated = true)]
1087
	public string[] split_set (string delimiters, int max_tokens = 0);
1088 1089 1090
	[CCode (cname = "g_stpcpy")]
	private static void* copy_to_buffer (void* dest, string src);
	[CCode (cname = "_vala_g_strjoinv")]
1091
	public static string joinv (string? separator, string?[]? str_array) {
1092 1093 1094
		if (separator == null) {
			separator = "";
		}
1095
		if (str_array != null && (str_array.length > 0 || (str_array.length == -1 && str_array[0] != null))) {
1096 1097 1098
			int i;
			size_t len = 1;
			for (i = 0 ; (str_array.length != -1 && i < str_array.length) || (str_array.length == -1 && str_array[i] != null) ; i++) {
1099
				len += (str_array[i] != null) ? ((!) str_array[i]).length : 0;
1100
			}
1101 1102 1103 1104
			if (i == 0) {
				return "";
			}
			str_array.length = i;
1105
			len += ((!) separator).length * (i - 1);
1106 1107

			string* res = GLib.malloc (len);
1108
			void* ptr = string.copy_to_buffer ((void*) res, (!) str_array[0]);
1109
			for (i = 1 ; i < str_array.length ; i++) {
1110 1111
				ptr = string.copy_to_buffer (ptr, (!) separator);
				ptr = string.copy_to_buffer (ptr, (str_array[i] != null) ? ((!) str_array[i]) : "");
1112 1113 1114 1115 1116 1117 1118
			}

			return (owned) res;
		} else {
			return "";
		}
	}
1119 1120
	[CCode (cname = "g_strjoin")]
	public static string join (string separator, ...);
Jürg Billeter's avatar
Jürg Billeter committed
1121
	[CCode (cname = "g_strnfill")]
1122
	public static string nfill (size_t length, char fill_char);
Jürg Billeter's avatar
Jürg Billeter committed
1123

1124 1125 1126 1127
	public char get (long index) {
		return ((char*) this)[index];
	}

1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138
	// checks whether valid string character starts at specified index
	// embedded NULs are not supported by the string class
	public bool valid_char (int index) {
		uint8 c = ((uint8*) this)[index];
		if (c == 0x00 || (c >= 0x80 && c < 0xc2) || c >= 0xf5) {
			return false;
		} else {
			return true;
		}
	}

1139
	[CCode (cname = "g_utf8_next_char")]
1140
	public unowned string next_char ();
1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151
	[CCode (cname = "g_utf8_next_char")]
	static char* utf8_next_char (char* str);
	public bool get_next_char (ref int index, out unichar c) {
		c = utf8_get_char ((char*) this + index);
		if (c != 0) {
			index = (int) (utf8_next_char ((char*) this + index) - (char*) this);
			return true;
		} else {
			return false;
		}
	}
1152
	[CCode (cname = "g_utf8_get_char")]
1153
	static unichar utf8_get_char (char* str);
1154
	public unichar get_char (long index = 0) {
1155 1156
		return utf8_get_char ((char*) this + index);
	}
1157
	[CCode (cname = "g_utf8_get_char_validated")]
1158
	public unichar get_char_validated (ssize_t max_len = -1);
1159

1160
	[Version (replacement = "string.index_of_nth_char")]
1161 1162
	[CCode (cname = "g_utf8_offset_to_pointer")]
	public unowned string utf8_offset (long offset);
1163 1164 1165
	public unowned string offset (long offset) {
		return (string) ((char*) this + offset);
	}
1166
	[Version (replacement = "string.char_count")]
1167 1168 1169
	public long pointer_to_offset (string pos) {
		return (long) ((char*) pos - (char*) this);
	}
1170 1171 1172 1173 1174 1175 1176 1177

	[CCode (cname = "g_utf8_offset_to_pointer")]
	char* utf8_offset_to_pointer (long offset);

	public int index_of_nth_char (long c) {
		return (int) (this.utf8_offset_to_pointer (c) - (char*) this);
	}

1178
	[CCode (cname = "g_utf8_prev_char")]
1179
	public unowned string prev_char ();
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192
	[CCode (cname = "g_utf8_prev_char")]
	static char* utf8_prev_char (char* str);
	public bool get_prev_char (ref int index, out unichar c) {
		if (0 < index) {
			index = (int) (utf8_prev_char ((char*) this + index) - (char*) this);
			c = utf8_get_char ((char*) this + index);
			return true;
		} else {
			c = 0;
			return false;
		}
	}

1193
	[Version (replacement = "string.length")]
1194 1195
	[CCode (cname = "strlen")]
	public long len ();
1196
	[Version (replacement = "string.index_of_char")]
1197
	[CCode (cname = "g_utf8_strchr")]
1198
	public unowned string chr (ssize_t len, unichar c);
1199
	[Version (replacement = "string.last_index_of_char")]
1200
	[CCode (cname = "g_utf8_strrchr")]
1201
	public unowned string rchr (ssize_t len, unichar c);
1202
	[Version (since = "2.2")]
1203
	[CCode (cname = "g_utf8_strreverse")]
1204
	public string reverse (ssize_t len = -1);
1205
	[CCode (cname = "g_utf8_validate")]
1206
	public bool validate (ssize_t max_len = -1, out char* end = null);
1207 1208
	[Version (since = "2.52")]
	[CCode (cname = "g_utf8_make_valid")]
Rico Tzschichholz's avatar