2 * Copyright 2003-2006, Various Contributors.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
13 #ifndef SETUP_STRING___H
14 #define SETUP_STRING___H
19 char *new_cstr_char_array (const std::string
& s
);
21 #define __TOSTRING__(X) #X
22 /* Note the layer of indirection here is needed to allow
23 stringification of the expansion of macros, i.e. "#define foo
24 bar", "TOSTRING(foo)", to yield "bar". */
25 #define TOSTRING(X) __TOSTRING__(X)
27 std::string
format_1000s (int num
, char sep
= ',');
29 std::string
stringify (int num
);
31 int casecompare (const std::string
& a
, const std::string
& b
, size_t limit
= 0);
33 std::string
replace(const std::string
& haystack
, const std::string
& needle
,
34 const std::string
& replacement
);
36 class casecompare_lt_op
39 bool operator() (const std::string
& a
, const std::string
& b
) const
40 { return casecompare(a
, b
) < 0; }
43 inline std::string
operator+ (const char *a
, const std::string
& b
)
44 { return std::string(a
) + b
; }
46 std::wstring
string_to_wstring(const std::string
&s
);
47 std::string
wstring_to_string(const std::wstring
&w
, unsigned int encoding
= CP_UTF8
);
49 // produce a std::string using formatting like sprintf
50 std::wstring
vformat(const std::wstring
&fmt
, va_list ap
);
51 std::wstring
format(const std::wstring
&fmt
, ...);
53 #endif /* SETUP_STRING___H */