Commit ad493bec authored by Ronan's avatar Ronan

fix(ChatRoom): use Utils::toString instead of to_string (Android problem)

parent 289dc072
......@@ -247,7 +247,7 @@ string ChatRoomPrivate::createIsComposingXml () const {
}
if ((err >= 0) && isComposing) {
int refreshTimeout = lp_config_get_int(core->config, "sip", "composing_refresh_timeout", composingDefaultRefreshTimeout);
err = xmlTextWriterWriteElement(writer, (const xmlChar *)"refresh", (const xmlChar *)to_string(refreshTimeout).c_str());
err = xmlTextWriterWriteElement(writer, (const xmlChar *)"refresh", (const xmlChar *)Utils::toString(refreshTimeout).c_str());
}
if (err >= 0) {
/* Close the "isComposing" element. */
......
......@@ -17,6 +17,7 @@
*/
#include <cstdlib>
#include <sstream>
#include <bctoolbox/port.h>
......@@ -52,6 +53,30 @@ vector<string> Utils::split (const string &str, const string &delimiter) {
return out;
}
#ifndef __ANDROID__
#define TO_STRING_IMPL(TYPE) \
string Utils::toString(TYPE val) { \
return to_string(val); \
}
#else
#define TO_STRING_IMPL(TYPE) \
string Utils::toString(TYPE val) { \
ostringstream os; \
os << val; \
return os.str(); \
}
#endif // ifndef __ANDROID__
TO_STRING_IMPL(int)
TO_STRING_IMPL(long)
TO_STRING_IMPL(long long)
TO_STRING_IMPL(unsigned)
TO_STRING_IMPL(unsigned long)
TO_STRING_IMPL(unsigned long long)
TO_STRING_IMPL(float)
TO_STRING_IMPL(double)
TO_STRING_IMPL(long double)
int Utils::stoi (const string &str, size_t *idx, int base) {
char *p;
int v = strtol(str.c_str(), &p, base);
......
......@@ -37,6 +37,16 @@ namespace Utils {
return split(str, std::string(1, delimiter));
}
LINPHONE_PUBLIC std::string toString (int val);
LINPHONE_PUBLIC std::string toString (long val);
LINPHONE_PUBLIC std::string toString (long long val);
LINPHONE_PUBLIC std::string toString (unsigned val);
LINPHONE_PUBLIC std::string toString (unsigned long val);
LINPHONE_PUBLIC std::string toString (unsigned long long val);
LINPHONE_PUBLIC std::string toString (float val);
LINPHONE_PUBLIC std::string toString (double val);
LINPHONE_PUBLIC std::string toString (long double val);
LINPHONE_PUBLIC int stoi (const std::string &str, size_t *idx = 0, int base = 10);
// Return a buffer allocated with new.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment