Commit 02e563cb authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Provide a std::to_string replacement for android

parent 94b830c0
/*****************************************************************************
* Media Library
*****************************************************************************
* Copyright (C) 2015 Hugo Beauzée-Luyssen, Videolabs
*
* Authors: Hugo Beauzée-Luyssen<hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#pragma once
#include <string>
#ifndef __ANDROID__
template <typename T>
inline std::string toString(T t)
{
static_assert(std::is_fundamental<T>::value, "This only supports fundamental types");
return std::to_string(t);
}
#else
#include <sstream>
template <typename T>
inline std::string toString(T t)
{
static_assert(std::is_fundamental<T>::value, "This only supports fundamental types");
std::ostringstream ss;
ss << std::forward<T>(t);
return ss.str();
}
#endif
......@@ -23,6 +23,7 @@
#include "History.h"
#include "database/SqliteTools.h"
#include "ToString.h"
namespace policy
{
......@@ -56,7 +57,7 @@ bool History::createTable( DBConnection dbConnection )
" BEGIN "
"DELETE FROM " + policy::HistoryTable::Name + " WHERE id_record in "
"(SELECT id_record FROM " + policy::HistoryTable::Name +
" ORDER BY insertion_date DESC LIMIT -1 OFFSET " + std::to_string( MaxEntries ) + ");"
" ORDER BY insertion_date DESC LIMIT -1 OFFSET " + toString( MaxEntries ) + ");"
" END";
return sqlite::Tools::executeRequest( dbConnection, req ) &&
sqlite::Tools::executeRequest( dbConnection, triggerReq );
......
......@@ -24,6 +24,7 @@
#include <string>
#include <exception>
#include "ToString.h"
namespace sqlite
{
......@@ -52,8 +53,8 @@ class ColumnOutOfRange : public std::exception
public:
ColumnOutOfRange( unsigned int idx, unsigned int nbColumns )
{
m_reason = "Attempting to extract column at index " + std::to_string( idx ) +
" from a request with " + std::to_string( nbColumns ) + " columns";
m_reason = "Attempting to extract column at index " + toString( idx ) +
" from a request with " + toString( nbColumns ) + " columns";
}
virtual const char* what() const noexcept override
......
......@@ -28,6 +28,7 @@
#include "Genre.h"
#include "Media.h"
#include "Show.h"
#include "ToString.h"
#include "utils/Filename.h"
#include "utils/ModificationsNotifier.h"
......@@ -318,7 +319,7 @@ std::shared_ptr<AlbumTrack> MetadataParser::handleTrack( std::shared_ptr<Album>
if ( task.trackNumber != 0 )
{
title = "Track #";
title += std::to_string( task.trackNumber );
title += toString( task.trackNumber );
}
}
if ( title.empty() == false )
......
......@@ -42,6 +42,7 @@
#include "logging/Logger.h"
#include "MediaLibrary.h"
#include "utils/VLCInstance.h"
#include "ToString.h"
VLCThumbnailer::VLCThumbnailer()
: m_instance( VLCInstance::get() )
......@@ -276,7 +277,7 @@ parser::Task::Status VLCThumbnailer::compress( std::shared_ptr<Media> media, std
{
auto path = m_ml->thumbnailPath();
path += "/";
path += std::to_string( media->id() ) +
path += toString( media->id() ) +
#ifdef WITH_EVAS
".png";
#else
......
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