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
18 char *new_cstr_char_array (const std::string
& s
);
20 #define __TOSTRING__(X) #X
21 /* Note the layer of indirection here is needed to allow
22 stringification of the expansion of macros, i.e. "#define foo
23 bar", "TOSTRING(foo)", to yield "bar". */
24 #define TOSTRING(X) __TOSTRING__(X)
26 std::string
format_1000s (int num
, char sep
= ',');
28 std::string
stringify (int num
);
30 int casecompare (const std::string
& a
, const std::string
& b
, size_t limit
= 0);
32 std::string
replace(const std::string
& haystack
, const std::string
& needle
,
33 const std::string
& replacement
);
35 class casecompare_lt_op
38 bool operator() (const std::string
& a
, const std::string
& b
) const
39 { return casecompare(a
, b
) < 0; }
42 inline std::string
operator+ (const char *a
, const std::string
& b
)
43 { return std::string(a
) + b
; }
45 std::wstring
string_to_wstring(const std::string
&s
);
46 std::string
wstring_to_string(const std::wstring
&w
);
48 // produce a std::string using formatting like sprintf
49 std::wstring
vformat(const std::wstring
&fmt
, va_list ap
);
50 std::wstring
format(const std::wstring
&fmt
, ...);
52 #endif /* SETUP_STRING___H */