2 * @brief Convert types to std::string
4 /* Copyright (C) 2009,2015 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_STR_H
22 #define XAPIAN_INCLUDED_STR_H
29 /// Convert int to std::string.
30 std::string
str(int value
);
32 /// Convert unsigned int to std::string.
33 std::string
str(unsigned int value
);
35 /// Convert long to std::string.
36 std::string
str(long value
);
38 /// Convert unsigned long to std::string.
39 std::string
str(unsigned long value
);
41 /// Convert long long to std::string.
42 std::string
str(long long value
);
44 /// Convert unsigned long long to std::string.
45 std::string
str(unsigned long long value
);
47 /// Convert double to std::string.
48 std::string
str(double value
);
50 /// Convert const void * to std::string.
51 std::string
str(const void * value
);
53 /** Convert std::string to std::string.
55 * This is useful as it allows macros and templates to apply str() to a
56 * type and have it work if that type is std::string.
58 inline std::string
str(const std::string
& value
) { return value
; }
60 /// Convert const char * to std::string.
61 inline std::string
str(const char * value
) { return value
; }
63 /// Convert bool to std::string.
64 inline std::string
str(bool value
) {
65 return std::string(1, '0' | static_cast<char>(value
));
71 using Xapian::Internal::str
;
73 #endif // XAPIAN_INCLUDED_STR_H