Skip to content

Commit c11e06c

Browse files
committed
Ubuntu std::to_string workaround
1 parent d9277f8 commit c11e06c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

hardware/Kodi.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include <iostream>
1818

19+
#define SSTR( x ) dynamic_cast< std::ostringstream & >(( std::ostringstream() << std::dec << x ) ).str()
20+
1921
// http://<ip_address>:8080/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22Player.GetActivePlayers%22,%22id%22:1}
2022
// {"id":1,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}
2123

@@ -166,7 +168,7 @@ void CKodi::Do_Node_Work(const KodiNode &Node)
166168
if (sMedia == "video") nStatus = MSTAT_VIDEO;
167169
if (sMedia == "audio") nStatus = MSTAT_AUDIO;
168170
if (sMedia == "picture") nStatus = MSTAT_PHOTO;
169-
sPlayerId = std::to_string((int)root["result"][0]["playerid"].asInt());
171+
sPlayerId = SSTR((int)root["result"][0]["playerid"].asInt());
170172
}
171173

172174
// If player is active then pick up additional details
@@ -204,12 +206,12 @@ void CKodi::Do_Node_Work(const KodiNode &Node)
204206
if (root["result"]["item"]["season"].empty() != true)
205207
{
206208
sTitle += " [S";
207-
sTitle += std::to_string((int)root["result"]["item"]["season"].asInt());
209+
sTitle += SSTR((int)root["result"]["item"]["season"].asInt());
208210
}
209211
if (root["result"]["item"]["episode"].empty() != true)
210212
{
211213
sTitle += "E";
212-
sTitle += std::to_string((int)root["result"]["item"]["episode"].asInt());
214+
sTitle += SSTR((int)root["result"]["item"]["episode"].asInt());
213215
sTitle += "], ";
214216
}
215217
}
@@ -233,7 +235,7 @@ void CKodi::Do_Node_Work(const KodiNode &Node)
233235
}
234236
if (root["result"]["item"]["year"].empty() != true)
235237
{
236-
std::string sYear = std::to_string((int)root["result"]["item"]["year"].asInt());
238+
std::string sYear = SSTR((int)root["result"]["item"]["year"].asInt());
237239
if (sYear.length() > 2) sTitle += " (" + sYear + ")";
238240
}
239241
}
@@ -249,7 +251,7 @@ void CKodi::Do_Node_Work(const KodiNode &Node)
249251
int iSpeed = root["result"]["speed"].asInt();
250252
if (iSpeed == 0) nStatus = MSTAT_PAUSED;
251253
float fPercent = root["result"]["percentage"].asFloat();
252-
if (fPercent > 1.0) sPercent = std::to_string((int)round(fPercent)) + "%";
254+
if (fPercent > 1.0) sPercent = SSTR((int)round(fPercent)) + "%";
253255
}
254256
}
255257

0 commit comments

Comments
 (0)