source: appstream-generator/build/girepo/glib/Str.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 47.6 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software 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
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module glib.Str;
22
23private import core.stdc.stdio;
24private import core.stdc.string;
25private import gi.glib;
26public  import gi.glibtypes;
27public  import gi.gobjecttypes;
28private import glib.Str;
29
30
31/** */
32public struct Str
33{
34        /*
35         * Convert C-style 0 terminated string s to char[] string.
36         * copied from phobos
37         */
38        public static string toString(const(char)* s, size_t len = 0)
39        {
40                if ( s is null )
41                        return cast(string)null;
42               
43                if ( len == 0 )
44                        len = strlen(s);
45               
46                return s[0 .. len].idup;
47        }
48       
49        /*
50         * Convert array of chars s[] to a C-style 0 terminated string.
51         * copied from phobos
52         */
53        public static char* toStringz(string s)
54        {
55                if ( s is null ) return null;
56                char[] copy;
57               
58                if (s.length == 0)
59                {
60                        copy = "\0".dup;
61                }
62                else
63                {
64                        // Need to make a copy
65                        copy = new char[s.length + 1];
66                        copy[0..s.length] = s[];
67                        copy[s.length] = 0;
68                }
69               
70                return copy.ptr;
71        }
72       
73        /** */
74        public static char** toStringzArray(string[] args)
75        {
76                if ( args is null )
77                {
78                        return null;
79                }
80                char** argv = (new char*[args.length]).ptr;
81                int argc = 0;
82                foreach (string p; args)
83                {
84                        argv[argc++] = cast(char*)(p.dup~'\0');
85                }
86                argv[argc] = null;
87               
88                return argv;
89        }
90       
91        /** */
92        public static char*** toStringzArray(string[][] args)
93        {
94                if ( args is null )
95                {
96                        return null;
97                }
98                char**[] argv = new char**[args.length];
99                int argc = 0;
100                foreach( string[] p; args )
101                {
102                        argv[argc++] = toStringzArray(p);
103                }
104                argv[argc] = null;
105               
106                return argv.ptr;
107        }
108       
109        /** */
110        public static string[] toStringArray(const(char*)* args)
111        {
112                if ( args is null )
113                {
114                        return null;
115                }
116                string[] argv;
117               
118                while ( *args !is null )
119                {
120                        argv ~= toString(*args);
121                        args++;
122                }
123               
124                return argv;
125        }
126       
127        /** */
128        public static string[] toStringArray(const(char*)* args, size_t len)
129        {
130                string[] argv = new string[len];
131               
132                for ( int i; i < len; i++ )
133                {
134                        argv[i] = toString(args[i]);
135                }
136               
137                return argv;
138        }
139       
140        /** */
141        public static string[][] toStringArray(char*** args)
142        {
143                string[][] argv;
144               
145                if ( args is null )
146                {
147                        return null;
148                }
149               
150                while ( *args !is null )
151                {
152                        argv ~= toStringArray(*args);
153                        args++;
154                }
155               
156                return argv;
157        }
158       
159        /** */
160        public static void freeString(char* str)
161        {
162                g_free(str);
163        }
164       
165        /** */
166        public static void freeStringArray(char** str)
167        {
168                g_strfreev(str);
169        }
170       
171        /** */
172        public static void freeStringArray(char*** str)
173        {
174                while ( *str !is null )
175                {
176                        g_strfreev(*str);
177                        str++;
178                }
179               
180                g_free(str);
181        }
182
183        /**
184         */
185
186        /**
187         * Determines the numeric value of a character as a decimal digit.
188         * Differs from g_unichar_digit_value() because it takes a char, so
189         * there's no worry about sign extension if characters are signed.
190         *
191         * Params:
192         *     c = an ASCII character
193         *
194         * Returns: If @c is a decimal digit (according to g_ascii_isdigit()),
195         *     its numeric value. Otherwise, -1.
196         */
197        public static int asciiDigitValue(char c)
198        {
199                return g_ascii_digit_value(c);
200        }
201
202        /**
203         * Converts a #gdouble to a string, using the '.' as
204         * decimal point.
205         *
206         * This function generates enough precision that converting
207         * the string back using g_ascii_strtod() gives the same machine-number
208         * (on machines with IEEE compatible 64bit doubles). It is
209         * guaranteed that the size of the resulting string will never
210         * be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes, including the terminating
211         * nul character, which is always added.
212         *
213         * Params:
214         *     buffer = A buffer to place the resulting string in
215         *     bufLen = The length of the buffer.
216         *     d = The #gdouble to convert
217         *
218         * Returns: The pointer to the buffer with the converted string.
219         */
220        public static string asciiDtostr(string buffer, int bufLen, double d)
221        {
222                auto retStr = g_ascii_dtostr(Str.toStringz(buffer), bufLen, d);
223               
224                scope(exit) Str.freeString(retStr);
225                return Str.toString(retStr);
226        }
227
228        /**
229         * Converts a #gdouble to a string, using the '.' as
230         * decimal point. To format the number you pass in
231         * a printf()-style format string. Allowed conversion
232         * specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
233         *
234         * The returned buffer is guaranteed to be nul-terminated.
235         *
236         * If you just want to want to serialize the value into a
237         * string, use g_ascii_dtostr().
238         *
239         * Params:
240         *     buffer = A buffer to place the resulting string in
241         *     bufLen = The length of the buffer.
242         *     format = The printf()-style format to use for the
243         *         code to use for converting.
244         *     d = The #gdouble to convert
245         *
246         * Returns: The pointer to the buffer with the converted string.
247         */
248        public static string asciiFormatd(string buffer, int bufLen, string format, double d)
249        {
250                auto retStr = g_ascii_formatd(Str.toStringz(buffer), bufLen, Str.toStringz(format), d);
251               
252                scope(exit) Str.freeString(retStr);
253                return Str.toString(retStr);
254        }
255
256        /**
257         * Compare two strings, ignoring the case of ASCII characters.
258         *
259         * Unlike the BSD strcasecmp() function, this only recognizes standard
260         * ASCII letters and ignores the locale, treating all non-ASCII
261         * bytes as if they are not letters.
262         *
263         * This function should be used only on strings that are known to be
264         * in encodings where the bytes corresponding to ASCII letters always
265         * represent themselves. This includes UTF-8 and the ISO-8859-*
266         * charsets, but not for instance double-byte encodings like the
267         * Windows Codepage 932, where the trailing bytes of double-byte
268         * characters include all ASCII letters. If you compare two CP932
269         * strings using this function, you will get false matches.
270         *
271         * Both @s1 and @s2 must be non-%NULL.
272         *
273         * Params:
274         *     s1 = string to compare with @s2
275         *     s2 = string to compare with @s1
276         *
277         * Returns: 0 if the strings match, a negative value if @s1 < @s2,
278         *     or a positive value if @s1 > @s2.
279         */
280        public static int asciiStrcasecmp(string s1, string s2)
281        {
282                return g_ascii_strcasecmp(Str.toStringz(s1), Str.toStringz(s2));
283        }
284
285        /**
286         * Converts all upper case ASCII letters to lower case ASCII letters.
287         *
288         * Params:
289         *     str = a string
290         *     len = length of @str in bytes, or -1 if @str is nul-terminated
291         *
292         * Returns: a newly-allocated string, with all the upper case
293         *     characters in @str converted to lower case, with semantics that
294         *     exactly match g_ascii_tolower(). (Note that this is unlike the
295         *     old g_strdown(), which modified the string in place.)
296         */
297        public static string asciiStrdown(string str, ptrdiff_t len)
298        {
299                auto retStr = g_ascii_strdown(Str.toStringz(str), len);
300               
301                scope(exit) Str.freeString(retStr);
302                return Str.toString(retStr);
303        }
304
305        /**
306         * Compare @s1 and @s2, ignoring the case of ASCII characters and any
307         * characters after the first @n in each string.
308         *
309         * Unlike the BSD strcasecmp() function, this only recognizes standard
310         * ASCII letters and ignores the locale, treating all non-ASCII
311         * characters as if they are not letters.
312         *
313         * The same warning as in g_ascii_strcasecmp() applies: Use this
314         * function only on strings known to be in encodings where bytes
315         * corresponding to ASCII letters always represent themselves.
316         *
317         * Params:
318         *     s1 = string to compare with @s2
319         *     s2 = string to compare with @s1
320         *     n = number of characters to compare
321         *
322         * Returns: 0 if the strings match, a negative value if @s1 < @s2,
323         *     or a positive value if @s1 > @s2.
324         */
325        public static int asciiStrncasecmp(string s1, string s2, size_t n)
326        {
327                return g_ascii_strncasecmp(Str.toStringz(s1), Str.toStringz(s2), n);
328        }
329
330        /**
331         * Converts a string to a #gdouble value.
332         *
333         * This function behaves like the standard strtod() function
334         * does in the C locale. It does this without actually changing
335         * the current locale, since that would not be thread-safe.
336         * A limitation of the implementation is that this function
337         * will still accept localized versions of infinities and NANs.
338         *
339         * This function is typically used when reading configuration
340         * files or other non-user input that should be locale independent.
341         * To handle input from the user you should normally use the
342         * locale-sensitive system strtod() function.
343         *
344         * To convert from a #gdouble to a string in a locale-insensitive
345         * way, use g_ascii_dtostr().
346         *
347         * If the correct value would cause overflow, plus or minus %HUGE_VAL
348         * is returned (according to the sign of the value), and %ERANGE is
349         * stored in %errno. If the correct value would cause underflow,
350         * zero is returned and %ERANGE is stored in %errno.
351         *
352         * This function resets %errno before calling strtod() so that
353         * you can reliably detect overflow and underflow.
354         *
355         * Params:
356         *     nptr = the string to convert to a numeric value.
357         *     endptr = if non-%NULL, it returns the character after
358         *         the last character used in the conversion.
359         *
360         * Returns: the #gdouble value.
361         */
362        public static double asciiStrtod(string nptr, string[] endptr)
363        {
364                return g_ascii_strtod(Str.toStringz(nptr), Str.toStringzArray(endptr));
365        }
366
367        /**
368         * Converts a string to a #gint64 value.
369         * This function behaves like the standard strtoll() function
370         * does in the C locale. It does this without actually
371         * changing the current locale, since that would not be
372         * thread-safe.
373         *
374         * This function is typically used when reading configuration
375         * files or other non-user input that should be locale independent.
376         * To handle input from the user you should normally use the
377         * locale-sensitive system strtoll() function.
378         *
379         * If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
380         * is returned, and `ERANGE` is stored in `errno`.
381         * If the base is outside the valid range, zero is returned, and
382         * `EINVAL` is stored in `errno`. If the
383         * string conversion fails, zero is returned, and @endptr returns @nptr
384         * (if @endptr is non-%NULL).
385         *
386         * Params:
387         *     nptr = the string to convert to a numeric value.
388         *     endptr = if non-%NULL, it returns the character after
389         *         the last character used in the conversion.
390         *     base = to be used for the conversion, 2..36 or 0
391         *
392         * Returns: the #gint64 value or zero on error.
393         *
394         * Since: 2.12
395         */
396        public static long asciiStrtoll(string nptr, string[] endptr, uint base)
397        {
398                return g_ascii_strtoll(Str.toStringz(nptr), Str.toStringzArray(endptr), base);
399        }
400
401        /**
402         * Converts a string to a #guint64 value.
403         * This function behaves like the standard strtoull() function
404         * does in the C locale. It does this without actually
405         * changing the current locale, since that would not be
406         * thread-safe.
407         *
408         * This function is typically used when reading configuration
409         * files or other non-user input that should be locale independent.
410         * To handle input from the user you should normally use the
411         * locale-sensitive system strtoull() function.
412         *
413         * If the correct value would cause overflow, %G_MAXUINT64
414         * is returned, and `ERANGE` is stored in `errno`.
415         * If the base is outside the valid range, zero is returned, and
416         * `EINVAL` is stored in `errno`.
417         * If the string conversion fails, zero is returned, and @endptr returns
418         * @nptr (if @endptr is non-%NULL).
419         *
420         * Params:
421         *     nptr = the string to convert to a numeric value.
422         *     endptr = if non-%NULL, it returns the character after
423         *         the last character used in the conversion.
424         *     base = to be used for the conversion, 2..36 or 0
425         *
426         * Returns: the #guint64 value or zero on error.
427         *
428         * Since: 2.2
429         */
430        public static ulong asciiStrtoull(string nptr, string[] endptr, uint base)
431        {
432                return g_ascii_strtoull(Str.toStringz(nptr), Str.toStringzArray(endptr), base);
433        }
434
435        /**
436         * Converts all lower case ASCII letters to upper case ASCII letters.
437         *
438         * Params:
439         *     str = a string
440         *     len = length of @str in bytes, or -1 if @str is nul-terminated
441         *
442         * Returns: a newly allocated string, with all the lower case
443         *     characters in @str converted to upper case, with semantics that
444         *     exactly match g_ascii_toupper(). (Note that this is unlike the
445         *     old g_strup(), which modified the string in place.)
446         */
447        public static string asciiStrup(string str, ptrdiff_t len)
448        {
449                auto retStr = g_ascii_strup(Str.toStringz(str), len);
450               
451                scope(exit) Str.freeString(retStr);
452                return Str.toString(retStr);
453        }
454
455        /**
456         * Convert a character to ASCII lower case.
457         *
458         * Unlike the standard C library tolower() function, this only
459         * recognizes standard ASCII letters and ignores the locale, returning
460         * all non-ASCII characters unchanged, even if they are lower case
461         * letters in a particular character set. Also unlike the standard
462         * library function, this takes and returns a char, not an int, so
463         * don't call it on %EOF but no need to worry about casting to #guchar
464         * before passing a possibly non-ASCII character in.
465         *
466         * Params:
467         *     c = any character
468         *
469         * Returns: the result of converting @c to lower case. If @c is
470         *     not an ASCII upper case letter, @c is returned unchanged.
471         */
472        public static char asciiTolower(char c)
473        {
474                return g_ascii_tolower(c);
475        }
476
477        /**
478         * Convert a character to ASCII upper case.
479         *
480         * Unlike the standard C library toupper() function, this only
481         * recognizes standard ASCII letters and ignores the locale, returning
482         * all non-ASCII characters unchanged, even if they are upper case
483         * letters in a particular character set. Also unlike the standard
484         * library function, this takes and returns a char, not an int, so
485         * don't call it on %EOF but no need to worry about casting to #guchar
486         * before passing a possibly non-ASCII character in.
487         *
488         * Params:
489         *     c = any character
490         *
491         * Returns: the result of converting @c to upper case. If @c is not
492         *     an ASCII lower case letter, @c is returned unchanged.
493         */
494        public static char asciiToupper(char c)
495        {
496                return g_ascii_toupper(c);
497        }
498
499        /**
500         * Determines the numeric value of a character as a hexidecimal
501         * digit. Differs from g_unichar_xdigit_value() because it takes
502         * a char, so there's no worry about sign extension if characters
503         * are signed.
504         *
505         * Params:
506         *     c = an ASCII character.
507         *
508         * Returns: If @c is a hex digit (according to g_ascii_isxdigit()),
509         *     its numeric value. Otherwise, -1.
510         */
511        public static int asciiXdigitValue(char c)
512        {
513                return g_ascii_xdigit_value(c);
514        }
515
516        /**
517         * Calculates the maximum space needed to store the output
518         * of the sprintf() function.
519         *
520         * Params:
521         *     format = the format string. See the printf() documentation
522         *     args = the parameters to be inserted into the format string
523         *
524         * Returns: the maximum space needed to store the formatted string
525         */
526        public static size_t printfStringUpperBound(string format, void* args)
527        {
528                return g_printf_string_upper_bound(Str.toStringz(format), args);
529        }
530
531        /**
532         * Copies a nul-terminated string into the dest buffer, include the
533         * trailing nul, and return a pointer to the trailing nul byte.
534         * This is useful for concatenating multiple strings together
535         * without having to repeatedly scan for the end.
536         *
537         * Params:
538         *     dest = destination buffer.
539         *     src = source string.
540         *
541         * Returns: a pointer to trailing nul byte.
542         */
543        public static string stpcpy(string dest, string src)
544        {
545                auto retStr = g_stpcpy(Str.toStringz(dest), Str.toStringz(src));
546               
547                scope(exit) Str.freeString(retStr);
548                return Str.toString(retStr);
549        }
550
551        /**
552         * Looks whether the string @str begins with @prefix.
553         *
554         * Params:
555         *     str = a nul-terminated string
556         *     prefix = the nul-terminated prefix to look for
557         *
558         * Returns: %TRUE if @str begins with @prefix, %FALSE otherwise.
559         *
560         * Since: 2.2
561         */
562        public static bool hasPrefix(string str, string prefix)
563        {
564                return g_str_has_prefix(Str.toStringz(str), Str.toStringz(prefix)) != 0;
565        }
566
567        /**
568         * Looks whether the string @str ends with @suffix.
569         *
570         * Params:
571         *     str = a nul-terminated string
572         *     suffix = the nul-terminated suffix to look for
573         *
574         * Returns: %TRUE if @str end with @suffix, %FALSE otherwise.
575         *
576         * Since: 2.2
577         */
578        public static bool hasSuffix(string str, string suffix)
579        {
580                return g_str_has_suffix(Str.toStringz(str), Str.toStringz(suffix)) != 0;
581        }
582
583        /**
584         * Determines if a string is pure ASCII. A string is pure ASCII if it
585         * contains no bytes with the high bit set.
586         *
587         * Params:
588         *     str = a string
589         *
590         * Returns: %TRUE if @str is ASCII
591         *
592         * Since: 2.40
593         */
594        public static bool isAscii(string str)
595        {
596                return g_str_is_ascii(Str.toStringz(str)) != 0;
597        }
598
599        /**
600         * Checks if a search conducted for @search_term should match
601         * @potential_hit.
602         *
603         * This function calls g_str_tokenize_and_fold() on both
604         * @search_term and @potential_hit.  ASCII alternates are never taken
605         * for @search_term but will be taken for @potential_hit according to
606         * the value of @accept_alternates.
607         *
608         * A hit occurs when each folded token in @search_term is a prefix of a
609         * folded token from @potential_hit.
610         *
611         * Depending on how you're performing the search, it will typically be
612         * faster to call g_str_tokenize_and_fold() on each string in
613         * your corpus and build an index on the returned folded tokens, then
614         * call g_str_tokenize_and_fold() on the search term and
615         * perform lookups into that index.
616         *
617         * As some examples, searching for "fred" would match the potential hit
618         * "Smith, Fred" and also "Frédéric".  Searching for "Fréd" would match
619         * "Frédéric" but not "Frederic" (due to the one-directional nature of
620         * accent matching).  Searching "fo" would match "Foo" and "Bar Foo
621         * Baz", but not "SFO" (because no word as "fo" as a prefix).
622         *
623         * Params:
624         *     searchTerm = the search term from the user
625         *     potentialHit = the text that may be a hit
626         *     acceptAlternates = %TRUE to accept ASCII alternates
627         *
628         * Returns: %TRUE if @potential_hit is a hit
629         *
630         * Since: 2.40
631         */
632        public static bool matchString(string searchTerm, string potentialHit, bool acceptAlternates)
633        {
634                return g_str_match_string(Str.toStringz(searchTerm), Str.toStringz(potentialHit), acceptAlternates) != 0;
635        }
636
637        /**
638         * Transliterate @str to plain ASCII.
639         *
640         * For best results, @str should be in composed normalised form.
641         *
642         * This function performs a reasonably good set of character
643         * replacements.  The particular set of replacements that is done may
644         * change by version or even by runtime environment.
645         *
646         * If the source language of @str is known, it can used to improve the
647         * accuracy of the translation by passing it as @from_locale.  It should
648         * be a valid POSIX locale string (of the form
649         * "language[_territory][.codeset][@modifier]").
650         *
651         * If @from_locale is %NULL then the current locale is used.
652         *
653         * If you want to do translation for no specific locale, and you want it
654         * to be done independently of the currently locale, specify "C" for
655         * @from_locale.
656         *
657         * Params:
658         *     str = a string, in UTF-8
659         *     fromLocale = the source locale, if known
660         *
661         * Returns: a string in plain ASCII
662         */
663        public static string toAscii(string str, string fromLocale)
664        {
665                auto retStr = g_str_to_ascii(Str.toStringz(str), Str.toStringz(fromLocale));
666               
667                scope(exit) Str.freeString(retStr);
668                return Str.toString(retStr);
669        }
670
671        /**
672         * Tokenises @string and performs folding on each token.
673         *
674         * A token is a non-empty sequence of alphanumeric characters in the
675         * source string, separated by non-alphanumeric characters.  An
676         * "alphanumeric" character for this purpose is one that matches
677         * g_unichar_isalnum() or g_unichar_ismark().
678         *
679         * Each token is then (Unicode) normalised and case-folded.  If
680         * @ascii_alternates is non-%NULL and some of the returned tokens
681         * contain non-ASCII characters, ASCII alternatives will be generated.
682         *
683         * The number of ASCII alternatives that are generated and the method
684         * for doing so is unspecified, but @translit_locale (if specified) may
685         * improve the transliteration if the language of the source string is
686         * known.
687         *
688         * Params:
689         *     str = a string
690         *     translitLocale = the language code (like 'de' or
691         *         'en_GB') from which @string originates
692         *     asciiAlternates = a
693         *         return location for ASCII alternates
694         *
695         * Returns: the folded tokens
696         *
697         * Since: 2.40
698         */
699        public static string[] tokenizeAndFold(string str, string translitLocale, out string[] asciiAlternates)
700        {
701                char** outasciiAlternates = null;
702               
703                auto retStr = g_str_tokenize_and_fold(Str.toStringz(str), Str.toStringz(translitLocale), &outasciiAlternates);
704               
705                asciiAlternates = Str.toStringArray(outasciiAlternates);
706               
707                scope(exit) Str.freeStringArray(retStr);
708                return Str.toStringArray(retStr);
709        }
710
711        /**
712         * For each character in @string, if the character is not in @valid_chars,
713         * replaces the character with @substitutor. Modifies @string in place,
714         * and return @string itself, not a copy. The return value is to allow
715         * nesting such as
716         * |[<!-- language="C" -->
717         * g_ascii_strup (g_strcanon (str, "abc", '?'))
718         * ]|
719         *
720         * Params:
721         *     str = a nul-terminated array of bytes
722         *     validChars = bytes permitted in @string
723         *     substitutor = replacement character for disallowed bytes
724         *
725         * Returns: @string
726         */
727        public static string strcanon(string str, string validChars, char substitutor)
728        {
729                auto retStr = g_strcanon(Str.toStringz(str), Str.toStringz(validChars), substitutor);
730               
731                scope(exit) Str.freeString(retStr);
732                return Str.toString(retStr);
733        }
734
735        /**
736         * A case-insensitive string comparison, corresponding to the standard
737         * strcasecmp() function on platforms which support it.
738         *
739         * Deprecated: See g_strncasecmp() for a discussion of why this
740         * function is deprecated and how to replace it.
741         *
742         * Params:
743         *     s1 = a string
744         *     s2 = a string to compare with @s1
745         *
746         * Returns: 0 if the strings match, a negative value if @s1 < @s2,
747         *     or a positive value if @s1 > @s2.
748         */
749        public static int strcasecmp(string s1, string s2)
750        {
751                return g_strcasecmp(Str.toStringz(s1), Str.toStringz(s2));
752        }
753
754        /**
755         * Removes trailing whitespace from a string.
756         *
757         * This function doesn't allocate or reallocate any memory;
758         * it modifies @string in place. Therefore, it cannot be used
759         * on statically allocated strings.
760         *
761         * The pointer to @string is returned to allow the nesting of functions.
762         *
763         * Also see g_strchug() and g_strstrip().
764         *
765         * Params:
766         *     str = a string to remove the trailing whitespace from
767         *
768         * Returns: @string
769         */
770        public static string strchomp(string str)
771        {
772                auto retStr = g_strchomp(Str.toStringz(str));
773               
774                scope(exit) Str.freeString(retStr);
775                return Str.toString(retStr);
776        }
777
778        /**
779         * Removes leading whitespace from a string, by moving the rest
780         * of the characters forward.
781         *
782         * This function doesn't allocate or reallocate any memory;
783         * it modifies @string in place. Therefore, it cannot be used on
784         * statically allocated strings.
785         *
786         * The pointer to @string is returned to allow the nesting of functions.
787         *
788         * Also see g_strchomp() and g_strstrip().
789         *
790         * Params:
791         *     str = a string to remove the leading whitespace from
792         *
793         * Returns: @string
794         */
795        public static string strchug(string str)
796        {
797                auto retStr = g_strchug(Str.toStringz(str));
798               
799                scope(exit) Str.freeString(retStr);
800                return Str.toString(retStr);
801        }
802
803        /**
804         * Compares @str1 and @str2 like strcmp(). Handles %NULL
805         * gracefully by sorting it before non-%NULL strings.
806         * Comparing two %NULL pointers returns 0.
807         *
808         * Params:
809         *     str1 = a C string or %NULL
810         *     str2 = another C string or %NULL
811         *
812         * Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
813         *
814         * Since: 2.16
815         */
816        public static int strcmp0(string str1, string str2)
817        {
818                return g_strcmp0(Str.toStringz(str1), Str.toStringz(str2));
819        }
820
821        /**
822         * Replaces all escaped characters with their one byte equivalent.
823         *
824         * This function does the reverse conversion of g_strescape().
825         *
826         * Params:
827         *     source = a string to compress
828         *
829         * Returns: a newly-allocated copy of @source with all escaped
830         *     character compressed
831         */
832        public static string strcompress(string source)
833        {
834                auto retStr = g_strcompress(Str.toStringz(source));
835               
836                scope(exit) Str.freeString(retStr);
837                return Str.toString(retStr);
838        }
839
840        /**
841         * Converts any delimiter characters in @string to @new_delimiter.
842         * Any characters in @string which are found in @delimiters are
843         * changed to the @new_delimiter character. Modifies @string in place,
844         * and returns @string itself, not a copy. The return value is to
845         * allow nesting such as
846         * |[<!-- language="C" -->
847         * g_ascii_strup (g_strdelimit (str, "abc", '?'))
848         * ]|
849         *
850         * Params:
851         *     str = the string to convert
852         *     delimiters = a string containing the current delimiters,
853         *         or %NULL to use the standard delimiters defined in #G_STR_DELIMITERS
854         *     newDelimiter = the new delimiter character
855         *
856         * Returns: @string
857         */
858        public static string strdelimit(string str, string delimiters, char newDelimiter)
859        {
860                auto retStr = g_strdelimit(Str.toStringz(str), Str.toStringz(delimiters), newDelimiter);
861               
862                scope(exit) Str.freeString(retStr);
863                return Str.toString(retStr);
864        }
865
866        /**
867         * Converts a string to lower case.
868         *
869         * Deprecated: This function is totally broken for the reasons discussed
870         * in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
871         * instead.
872         *
873         * Params:
874         *     str = the string to convert.
875         *
876         * Returns: the string
877         */
878        public static string strdown(string str)
879        {
880                auto retStr = g_strdown(Str.toStringz(str));
881               
882                scope(exit) Str.freeString(retStr);
883                return Str.toString(retStr);
884        }
885
886        /**
887         * Duplicates a string. If @str is %NULL it returns %NULL.
888         * The returned string should be freed with g_free()
889         * when no longer needed.
890         *
891         * Params:
892         *     str = the string to duplicate
893         *
894         * Returns: a newly-allocated copy of @str
895         */
896        public static string strdup(string str)
897        {
898                auto retStr = g_strdup(Str.toStringz(str));
899               
900                scope(exit) Str.freeString(retStr);
901                return Str.toString(retStr);
902        }
903
904        /**
905         * Similar to the standard C vsprintf() function but safer, since it
906         * calculates the maximum space required and allocates memory to hold
907         * the result. The returned string should be freed with g_free() when
908         * no longer needed.
909         *
910         * See also g_vasprintf(), which offers the same functionality, but
911         * additionally returns the length of the allocated string.
912         *
913         * Params:
914         *     format = a standard printf() format string, but notice
915         *         [string precision pitfalls][string-precision]
916         *     args = the list of parameters to insert into the format string
917         *
918         * Returns: a newly-allocated string holding the result
919         */
920        public static string strdupVprintf(string format, void* args)
921        {
922                auto retStr = g_strdup_vprintf(Str.toStringz(format), args);
923               
924                scope(exit) Str.freeString(retStr);
925                return Str.toString(retStr);
926        }
927
928        /**
929         * Copies %NULL-terminated array of strings. The copy is a deep copy;
930         * the new array should be freed by first freeing each string, then
931         * the array itself. g_strfreev() does this for you. If called
932         * on a %NULL value, g_strdupv() simply returns %NULL.
933         *
934         * Params:
935         *     strArray = a %NULL-terminated array of strings
936         *
937         * Returns: a new %NULL-terminated array of strings.
938         */
939        public static string[] strdupv(string[] strArray)
940        {
941                return Str.toStringArray(g_strdupv(Str.toStringzArray(strArray)));
942        }
943
944        /**
945         * Returns a string corresponding to the given error code, e.g. "no
946         * such process". Unlike strerror(), this always returns a string in
947         * UTF-8 encoding, and the pointer is guaranteed to remain valid for
948         * the lifetime of the process.
949         *
950         * Note that the string may be translated according to the current locale.
951         *
952         * The value of %errno will not be changed by this function.
953         *
954         * Params:
955         *     errnum = the system error number. See the standard C %errno
956         *         documentation
957         *
958         * Returns: a UTF-8 string describing the error code. If the error code
959         *     is unknown, it returns a string like "unknown error (<code>)".
960         */
961        public static string strerror(int errnum)
962        {
963                return Str.toString(g_strerror(errnum));
964        }
965
966        /**
967         * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
968         * and '&quot;' in the string @source by inserting a '\' before
969         * them. Additionally all characters in the range 0x01-0x1F (everything
970         * below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
971         * replaced with a '\' followed by their octal representation.
972         * Characters supplied in @exceptions are not escaped.
973         *
974         * g_strcompress() does the reverse conversion.
975         *
976         * Params:
977         *     source = a string to escape
978         *     exceptions = a string of characters not to escape in @source
979         *
980         * Returns: a newly-allocated copy of @source with certain
981         *     characters escaped. See above.
982         */
983        public static string strescape(string source, string exceptions)
984        {
985                auto retStr = g_strescape(Str.toStringz(source), Str.toStringz(exceptions));
986               
987                scope(exit) Str.freeString(retStr);
988                return Str.toString(retStr);
989        }
990
991        /**
992         * Frees a %NULL-terminated array of strings, as well as each
993         * string it contains.
994         *
995         * If @str_array is %NULL, this function simply returns.
996         *
997         * Params:
998         *     strArray = a %NULL-terminated array of strings to free
999         */
1000        public static void strfreev(string[] strArray)
1001        {
1002                g_strfreev(Str.toStringzArray(strArray));
1003        }
1004
1005        /**
1006         * Joins a number of strings together to form one long string, with the
1007         * optional @separator inserted between each of them. The returned string
1008         * should be freed with g_free().
1009         *
1010         * Params:
1011         *     separator = a string to insert between each of the
1012         *         strings, or %NULL
1013         *     strArray = a %NULL-terminated array of strings to join
1014         *
1015         * Returns: a newly-allocated string containing all of the strings joined
1016         *     together, with @separator between them
1017         */
1018        public static string strjoinv(string separator, string[] strArray)
1019        {
1020                auto retStr = g_strjoinv(Str.toStringz(separator), Str.toStringzArray(strArray));
1021               
1022                scope(exit) Str.freeString(retStr);
1023                return Str.toString(retStr);
1024        }
1025
1026        /**
1027         * Portability wrapper that calls strlcat() on systems which have it,
1028         * and emulates it otherwise. Appends nul-terminated @src string to @dest,
1029         * guaranteeing nul-termination for @dest. The total size of @dest won't
1030         * exceed @dest_size.
1031         *
1032         * At most @dest_size - 1 characters will be copied. Unlike strncat(),
1033         * @dest_size is the full size of dest, not the space left over. This
1034         * function does not allocate memory. It always nul-terminates (unless
1035         * @dest_size == 0 or there were no nul characters in the @dest_size
1036         * characters of dest to start with).
1037         *
1038         * Caveat: this is supposedly a more secure alternative to strcat() or
1039         * strncat(), but for real security g_strconcat() is harder to mess up.
1040         *
1041         * Params:
1042         *     dest = destination buffer, already containing one nul-terminated string
1043         *     src = source buffer
1044         *     destSize = length of @dest buffer in bytes (not length of existing string
1045         *         inside @dest)
1046         *
1047         * Returns: size of attempted result, which is MIN (dest_size, strlen
1048         *     (original dest)) + strlen (src), so if retval >= dest_size,
1049         *     truncation occurred.
1050         */
1051        public static size_t strlcat(string dest, string src, size_t destSize)
1052        {
1053                return g_strlcat(Str.toStringz(dest), Str.toStringz(src), destSize);
1054        }
1055
1056        /**
1057         * Portability wrapper that calls strlcpy() on systems which have it,
1058         * and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
1059         * guaranteed to be nul-terminated; @src must be nul-terminated;
1060         * @dest_size is the buffer size, not the number of bytes to copy.
1061         *
1062         * At most @dest_size - 1 characters will be copied. Always nul-terminates
1063         * (unless @dest_size is 0). This function does not allocate memory. Unlike
1064         * strncpy(), this function doesn't pad @dest (so it's often faster). It
1065         * returns the size of the attempted result, strlen (src), so if
1066         * @retval >= @dest_size, truncation occurred.
1067         *
1068         * Caveat: strlcpy() is supposedly more secure than strcpy() or strncpy(),
1069         * but if you really want to avoid screwups, g_strdup() is an even better
1070         * idea.
1071         *
1072         * Params:
1073         *     dest = destination buffer
1074         *     src = source buffer
1075         *     destSize = length of @dest in bytes
1076         *
1077         * Returns: length of @src
1078         */
1079        public static size_t strlcpy(string dest, string src, size_t destSize)
1080        {
1081                return g_strlcpy(Str.toStringz(dest), Str.toStringz(src), destSize);
1082        }
1083
1084        /**
1085         * A case-insensitive string comparison, corresponding to the standard
1086         * strncasecmp() function on platforms which support it. It is similar
1087         * to g_strcasecmp() except it only compares the first @n characters of
1088         * the strings.
1089         *
1090         * Deprecated: The problem with g_strncasecmp() is that it does
1091         * the comparison by calling toupper()/tolower(). These functions
1092         * are locale-specific and operate on single bytes. However, it is
1093         * impossible to handle things correctly from an internationalization
1094         * standpoint by operating on bytes, since characters may be multibyte.
1095         * Thus g_strncasecmp() is broken if your string is guaranteed to be
1096         * ASCII, since it is locale-sensitive, and it's broken if your string
1097         * is localized, since it doesn't work on many encodings at all,
1098         * including UTF-8, EUC-JP, etc.
1099         *
1100         * There are therefore two replacement techniques: g_ascii_strncasecmp(),
1101         * which only works on ASCII and is not locale-sensitive, and
1102         * g_utf8_casefold() followed by strcmp() on the resulting strings,
1103         * which is good for case-insensitive sorting of UTF-8.
1104         *
1105         * Params:
1106         *     s1 = a string
1107         *     s2 = a string to compare with @s1
1108         *     n = the maximum number of characters to compare
1109         *
1110         * Returns: 0 if the strings match, a negative value if @s1 < @s2,
1111         *     or a positive value if @s1 > @s2.
1112         */
1113        public static int strncasecmp(string s1, string s2, uint n)
1114        {
1115                return g_strncasecmp(Str.toStringz(s1), Str.toStringz(s2), n);
1116        }
1117
1118        /**
1119         * Duplicates the first @n bytes of a string, returning a newly-allocated
1120         * buffer @n + 1 bytes long which will always be nul-terminated. If @str
1121         * is less than @n bytes long the buffer is padded with nuls. If @str is
1122         * %NULL it returns %NULL. The returned value should be freed when no longer
1123         * needed.
1124         *
1125         * To copy a number of characters from a UTF-8 encoded string,
1126         * use g_utf8_strncpy() instead.
1127         *
1128         * Params:
1129         *     str = the string to duplicate
1130         *     n = the maximum number of bytes to copy from @str
1131         *
1132         * Returns: a newly-allocated buffer containing the first @n bytes
1133         *     of @str, nul-terminated
1134         */
1135        public static string strndup(string str, size_t n)
1136        {
1137                auto retStr = g_strndup(Str.toStringz(str), n);
1138               
1139                scope(exit) Str.freeString(retStr);
1140                return Str.toString(retStr);
1141        }
1142
1143        /**
1144         * Creates a new string @length bytes long filled with @fill_char.
1145         * The returned string should be freed when no longer needed.
1146         *
1147         * Params:
1148         *     length = the length of the new string
1149         *     fillChar = the byte to fill the string with
1150         *
1151         * Returns: a newly-allocated string filled the @fill_char
1152         */
1153        public static string strnfill(size_t length, char fillChar)
1154        {
1155                auto retStr = g_strnfill(length, fillChar);
1156               
1157                scope(exit) Str.freeString(retStr);
1158                return Str.toString(retStr);
1159        }
1160
1161        /**
1162         * Reverses all of the bytes in a string. For example,
1163         * `g_strreverse ("abcdef")` will result in "fedcba".
1164         *
1165         * Note that g_strreverse() doesn't work on UTF-8 strings
1166         * containing multibyte characters. For that purpose, use
1167         * g_utf8_strreverse().
1168         *
1169         * Params:
1170         *     str = the string to reverse
1171         *
1172         * Returns: the same pointer passed in as @string
1173         */
1174        public static string strreverse(string str)
1175        {
1176                auto retStr = g_strreverse(Str.toStringz(str));
1177               
1178                scope(exit) Str.freeString(retStr);
1179                return Str.toString(retStr);
1180        }
1181
1182        /**
1183         * Searches the string @haystack for the last occurrence
1184         * of the string @needle.
1185         *
1186         * Params:
1187         *     haystack = a nul-terminated string
1188         *     needle = the nul-terminated string to search for
1189         *
1190         * Returns: a pointer to the found occurrence, or
1191         *     %NULL if not found.
1192         */
1193        public static string strrstr(string haystack, string needle)
1194        {
1195                auto retStr = g_strrstr(Str.toStringz(haystack), Str.toStringz(needle));
1196               
1197                scope(exit) Str.freeString(retStr);
1198                return Str.toString(retStr);
1199        }
1200
1201        /**
1202         * Searches the string @haystack for the last occurrence
1203         * of the string @needle, limiting the length of the search
1204         * to @haystack_len.
1205         *
1206         * Params:
1207         *     haystack = a nul-terminated string
1208         *     haystackLen = the maximum length of @haystack
1209         *     needle = the nul-terminated string to search for
1210         *
1211         * Returns: a pointer to the found occurrence, or
1212         *     %NULL if not found.
1213         */
1214        public static string strrstrLen(string haystack, ptrdiff_t haystackLen, string needle)
1215        {
1216                auto retStr = g_strrstr_len(Str.toStringz(haystack), haystackLen, Str.toStringz(needle));
1217               
1218                scope(exit) Str.freeString(retStr);
1219                return Str.toString(retStr);
1220        }
1221
1222        /**
1223         * Returns a string describing the given signal, e.g. "Segmentation fault".
1224         * You should use this function in preference to strsignal(), because it
1225         * returns a string in UTF-8 encoding, and since not all platforms support
1226         * the strsignal() function.
1227         *
1228         * Params:
1229         *     signum = the signal number. See the `signal` documentation
1230         *
1231         * Returns: a UTF-8 string describing the signal. If the signal is unknown,
1232         *     it returns "unknown signal (<signum>)".
1233         */
1234        public static string strsignal(int signum)
1235        {
1236                return Str.toString(g_strsignal(signum));
1237        }
1238
1239        /**
1240         * Splits a string into a maximum of @max_tokens pieces, using the given
1241         * @delimiter. If @max_tokens is reached, the remainder of @string is
1242         * appended to the last token.
1243         *
1244         * As an example, the result of g_strsplit (":a:bc::d:", ":", -1) is a
1245         * %NULL-terminated vector containing the six strings "", "a", "bc", "", "d"
1246         * and "".
1247         *
1248         * As a special case, the result of splitting the empty string "" is an empty
1249         * vector, not a vector containing a single string. The reason for this
1250         * special case is that being able to represent a empty vector is typically
1251         * more useful than consistent handling of empty elements. If you do need
1252         * to represent empty elements, you'll need to check for the empty string
1253         * before calling g_strsplit().
1254         *
1255         * Params:
1256         *     str = a string to split
1257         *     delimiter = a string which specifies the places at which to split
1258         *         the string. The delimiter is not included in any of the resulting
1259         *         strings, unless @max_tokens is reached.
1260         *     maxTokens = the maximum number of pieces to split @string into.
1261         *         If this is less than 1, the string is split completely.
1262         *
1263         * Returns: a newly-allocated %NULL-terminated array of strings. Use
1264         *     g_strfreev() to free it.
1265         */
1266        public static string[] strsplit(string str, string delimiter, int maxTokens)
1267        {
1268                return Str.toStringArray(g_strsplit(Str.toStringz(str), Str.toStringz(delimiter), maxTokens));
1269        }
1270
1271        /**
1272         * Splits @string into a number of tokens not containing any of the characters
1273         * in @delimiter. A token is the (possibly empty) longest string that does not
1274         * contain any of the characters in @delimiters. If @max_tokens is reached, the
1275         * remainder is appended to the last token.
1276         *
1277         * For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
1278         * %NULL-terminated vector containing the three strings "abc", "def",
1279         * and "ghi".
1280         *
1281         * The result of g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
1282         * vector containing the four strings "", "def", "ghi", and "".
1283         *
1284         * As a special case, the result of splitting the empty string "" is an empty
1285         * vector, not a vector containing a single string. The reason for this
1286         * special case is that being able to represent a empty vector is typically
1287         * more useful than consistent handling of empty elements. If you do need
1288         * to represent empty elements, you'll need to check for the empty string
1289         * before calling g_strsplit_set().
1290         *
1291         * Note that this function works on bytes not characters, so it can't be used
1292         * to delimit UTF-8 strings for anything but ASCII characters.
1293         *
1294         * Params:
1295         *     str = The string to be tokenized
1296         *     delimiters = A nul-terminated string containing bytes that are used
1297         *         to split the string.
1298         *     maxTokens = The maximum number of tokens to split @string into.
1299         *         If this is less than 1, the string is split completely
1300         *
1301         * Returns: a newly-allocated %NULL-terminated array of strings. Use
1302         *     g_strfreev() to free it.
1303         *
1304         * Since: 2.4
1305         */
1306        public static string[] strsplitSet(string str, string delimiters, int maxTokens)
1307        {
1308                return Str.toStringArray(g_strsplit_set(Str.toStringz(str), Str.toStringz(delimiters), maxTokens));
1309        }
1310
1311        /**
1312         * Searches the string @haystack for the first occurrence
1313         * of the string @needle, limiting the length of the search
1314         * to @haystack_len.
1315         *
1316         * Params:
1317         *     haystack = a string
1318         *     haystackLen = the maximum length of @haystack. Note that -1 is
1319         *         a valid length, if @haystack is nul-terminated, meaning it will
1320         *         search through the whole string.
1321         *     needle = the string to search for
1322         *
1323         * Returns: a pointer to the found occurrence, or
1324         *     %NULL if not found.
1325         */
1326        public static string strstrLen(string haystack, ptrdiff_t haystackLen, string needle)
1327        {
1328                auto retStr = g_strstr_len(Str.toStringz(haystack), haystackLen, Str.toStringz(needle));
1329               
1330                scope(exit) Str.freeString(retStr);
1331                return Str.toString(retStr);
1332        }
1333
1334        /**
1335         * Converts a string to a #gdouble value.
1336         * It calls the standard strtod() function to handle the conversion, but
1337         * if the string is not completely converted it attempts the conversion
1338         * again with g_ascii_strtod(), and returns the best match.
1339         *
1340         * This function should seldom be used. The normal situation when reading
1341         * numbers not for human consumption is to use g_ascii_strtod(). Only when
1342         * you know that you must expect both locale formatted and C formatted numbers
1343         * should you use this. Make sure that you don't pass strings such as comma
1344         * separated lists of values, since the commas may be interpreted as a decimal
1345         * point in some locales, causing unexpected results.
1346         *
1347         * Params:
1348         *     nptr = the string to convert to a numeric value.
1349         *     endptr = if non-%NULL, it returns the character after
1350         *         the last character used in the conversion.
1351         *
1352         * Returns: the #gdouble value.
1353         */
1354        public static double strtod(string nptr, string[] endptr)
1355        {
1356                return g_strtod(Str.toStringz(nptr), Str.toStringzArray(endptr));
1357        }
1358
1359        /**
1360         * Converts a string to upper case.
1361         *
1362         * Deprecated: This function is totally broken for the reasons
1363         * discussed in the g_strncasecmp() docs - use g_ascii_strup()
1364         * or g_utf8_strup() instead.
1365         *
1366         * Params:
1367         *     str = the string to convert
1368         *
1369         * Returns: the string
1370         */
1371        public static string strup(string str)
1372        {
1373                auto retStr = g_strup(Str.toStringz(str));
1374               
1375                scope(exit) Str.freeString(retStr);
1376                return Str.toString(retStr);
1377        }
1378
1379        /** */
1380        public static GType strvGetType()
1381        {
1382                return g_strv_get_type();
1383        }
1384
1385        /**
1386         * Returns the length of the given %NULL-terminated
1387         * string array @str_array.
1388         *
1389         * Params:
1390         *     strArray = a %NULL-terminated array of strings
1391         *
1392         * Returns: length of @str_array.
1393         *
1394         * Since: 2.6
1395         */
1396        public static uint strvLength(string[] strArray)
1397        {
1398                return g_strv_length(Str.toStringzArray(strArray));
1399        }
1400
1401        /**
1402         * Checks if @strv contains @str. @strv must not be %NULL.
1403         *
1404         * Params:
1405         *     strv = a %NULL-terminated array of strings
1406         *     str = a string
1407         *
1408         * Returns: %TRUE if @str is an element of @strv, according to g_str_equal().
1409         *
1410         * Since: 2.44
1411         */
1412        public static bool strvContains(string strv, string str)
1413        {
1414                return g_strv_contains(Str.toStringz(strv), Str.toStringz(str)) != 0;
1415        }
1416
1417        /**
1418         * An implementation of the GNU vasprintf() function which supports
1419         * positional parameters, as specified in the Single Unix Specification.
1420         * This function is similar to g_vsprintf(), except that it allocates a
1421         * string to hold the output, instead of putting the output in a buffer
1422         * you allocate in advance.
1423         *
1424         * Params:
1425         *     str = the return location for the newly-allocated string.
1426         *     format = a standard printf() format string, but notice
1427         *         [string precision pitfalls][string-precision]
1428         *     args = the list of arguments to insert in the output.
1429         *
1430         * Returns: the number of bytes printed.
1431         *
1432         * Since: 2.4
1433         */
1434        public static int vasprintf(string[] str, string format, void* args)
1435        {
1436                return g_vasprintf(Str.toStringzArray(str), Str.toStringz(format), args);
1437        }
1438
1439        /**
1440         * An implementation of the standard fprintf() function which supports
1441         * positional parameters, as specified in the Single Unix Specification.
1442         *
1443         * Params:
1444         *     file = the stream to write to.
1445         *     format = a standard printf() format string, but notice
1446         *         [string precision pitfalls][string-precision]
1447         *     args = the list of arguments to insert in the output.
1448         *
1449         * Returns: the number of bytes printed.
1450         *
1451         * Since: 2.2
1452         */
1453        public static int vfprintf(FILE* file, string format, void* args)
1454        {
1455                return g_vfprintf(file, Str.toStringz(format), args);
1456        }
1457
1458        /**
1459         * An implementation of the standard vprintf() function which supports
1460         * positional parameters, as specified in the Single Unix Specification.
1461         *
1462         * Params:
1463         *     format = a standard printf() format string, but notice
1464         *         [string precision pitfalls][string-precision]
1465         *     args = the list of arguments to insert in the output.
1466         *
1467         * Returns: the number of bytes printed.
1468         *
1469         * Since: 2.2
1470         */
1471        public static int vprintf(string format, void* args)
1472        {
1473                return g_vprintf(Str.toStringz(format), args);
1474        }
1475
1476        /**
1477         * A safer form of the standard vsprintf() function. The output is guaranteed
1478         * to not exceed @n characters (including the terminating nul character), so
1479         * it is easy to ensure that a buffer overflow cannot occur.
1480         *
1481         * See also g_strdup_vprintf().
1482         *
1483         * In versions of GLib prior to 1.2.3, this function may return -1 if the
1484         * output was truncated, and the truncated string may not be nul-terminated.
1485         * In versions prior to 1.3.12, this function returns the length of the output
1486         * string.
1487         *
1488         * The return value of g_vsnprintf() conforms to the vsnprintf() function
1489         * as standardized in ISO C99. Note that this is different from traditional
1490         * vsnprintf(), which returns the length of the output string.
1491         *
1492         * The format string may contain positional parameters, as specified in
1493         * the Single Unix Specification.
1494         *
1495         * Params:
1496         *     str = the buffer to hold the output.
1497         *     n = the maximum number of bytes to produce (including the
1498         *         terminating nul character).
1499         *     format = a standard printf() format string, but notice
1500         *         string precision pitfalls][string-precision]
1501         *     args = the list of arguments to insert in the output.
1502         *
1503         * Returns: the number of bytes which would be produced if the buffer
1504         *     was large enough.
1505         */
1506        public static int vsnprintf(string str, gulong n, string format, void* args)
1507        {
1508                return g_vsnprintf(Str.toStringz(str), n, Str.toStringz(format), args);
1509        }
1510
1511        /**
1512         * An implementation of the standard vsprintf() function which supports
1513         * positional parameters, as specified in the Single Unix Specification.
1514         *
1515         * Params:
1516         *     str = the buffer to hold the output.
1517         *     format = a standard printf() format string, but notice
1518         *         [string precision pitfalls][string-precision]
1519         *     args = the list of arguments to insert in the output.
1520         *
1521         * Returns: the number of bytes printed.
1522         *
1523         * Since: 2.2
1524         */
1525        public static int vsprintf(string str, string format, void* args)
1526        {
1527                return g_vsprintf(Str.toStringz(str), Str.toStringz(format), args);
1528        }
1529}
Note: See TracBrowser for help on using the repository browser.