value to string as template function

pull/23/head
JuanJakobo 2020-10-23 17:03:46 +02:00
parent 84b91bd97e
commit 2028adf22f
4 changed files with 15 additions and 15 deletions

View File

@ -25,7 +25,7 @@ EventHandler::EventHandler()
//create a event to create handlers
_eventHandlerStatic = this;
_menu = new MenuHandler("nextcloud");
_menu = new MenuHandler("Nextcloud");
_nextcloud = new Nextcloud();
_loginView = nullptr;
_listView = nullptr;

View File

@ -79,7 +79,7 @@ void ListView::drawHeader(string headerText)
void ListView::drawFooter()
{
string footer = Util::intToString(_shownPage) + "/" + Util::intToString(_page);
string footer = Util::valueToString<int>(_shownPage) + "/" + Util::valueToString<int>(_page);
SetFont(_font, WHITE);
FillAreaRect(&_pageButton, BLACK);
DrawTextRect2(&_pageButton, footer.c_str());

View File

@ -9,20 +9,10 @@
#include "inkview.h"
#include <string>
#include <sstream>
#include <math.h>
#include <fstream>
using std::ostringstream;
using std::string;
string Util::intToString(const int value)
{
ostringstream stm;
stm << value;
return stm.str();
}
size_t Util::writeCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((string *)userp)->append((char *)contents, size * nmemb);

View File

@ -12,6 +12,10 @@
#include "inkview.h"
#include <string>
#include <fstream>
#include <sstream>
using std::ostringstream;
using std::string;
@ -19,12 +23,18 @@ class Util
{
public:
/**
* Converts an int to an string, as C++11 command is not supported
* Converts an value to an string, as C++11 command is not supported
*
* @param value the int value that shall be converted
* @return same value in string format
*/
static string intToString(const int value);
template <typename T>
static string valueToString(const T value)
{
ostringstream stm;
stm << value;
return stm.str();
};
/**
* Handles the return of curl command
@ -57,7 +67,7 @@ public:
*/
static string getXMLAttribute(const string &buffer, const string &name);
static string replaceString(string item,const string& find,const string& to);
static string replaceString(string item, const string &find, const string &to);
private:
Util() {}