]>
Commit | Line | Data |
---|---|---|
3c054baf | 1 | /* |
5f9ac473 | 2 | * Copyright 2003-2006, Various Contributors. |
3c054baf RC |
3 | * |
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. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
3c054baf RC |
11 | */ |
12 | ||
c93bc6d0 MB |
13 | #ifndef SETUP_STRING___H |
14 | #define SETUP_STRING___H | |
3c054baf | 15 | |
b401ef47 | 16 | #include <string> |
3c054baf | 17 | |
cb026227 | 18 | char *new_cstr_char_array (const std::string& s); |
3a8630fd | 19 | |
346627e7 IP |
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) | |
25 | ||
cb026227 | 26 | std::string format_1000s (int num, char sep = ','); |
0ac305ec | 27 | |
5f9ac473 | 28 | std::string stringify (int num); |
8300be9c | 29 | |
afa76033 MB |
30 | int casecompare (const std::string& a, const std::string& b, size_t limit = 0); |
31 | ||
2b791966 | 32 | std::string replace(const std::string& haystack, const std::string& needle, |
5f9ac473 | 33 | const std::string& replacement); |
2b791966 | 34 | |
cb026227 MB |
35 | class casecompare_lt_op |
36 | { | |
5f9ac473 MB |
37 | public: |
38 | bool operator() (const std::string& a, const std::string& b) const | |
39 | { return casecompare(a, b) < 0; } | |
cb026227 MB |
40 | }; |
41 | ||
42 | inline std::string operator+ (const char *a, const std::string& b) | |
43 | { return std::string(a) + b; } | |
44 | ||
e32e0a4a | 45 | std::wstring string_to_wstring(const std::string &s); |
dd0631fa JT |
46 | std::string wstring_to_string(const std::wstring &w); |
47 | ||
48 | // produce a std::string using formatting like sprintf | |
49 | std::wstring vformat(const std::wstring &fmt, va_list ap); | |
e32e0a4a | 50 | |
c93bc6d0 | 51 | #endif /* SETUP_STRING___H */ |