mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
[Common][Network] change typedef style func to c++11 std::function
This commit is contained in:
@ -32,15 +32,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include "../../../kernel_config.h"
|
||||
|
||||
namespace NSNetwork
|
||||
{
|
||||
namespace NSFileTransport
|
||||
{
|
||||
typedef void (*CFileTransporter_OnComplete)(int error);
|
||||
//typedef void (*CFileTransporter_OnComplete)(int error);
|
||||
// <return> cancel: 1, else 0
|
||||
typedef int (*CFileTransporter_OnProgress)(int percent);
|
||||
//typedef int (*CFileTransporter_OnProgress)(int percent);
|
||||
|
||||
class KERNEL_DECL IFileTransporter
|
||||
{
|
||||
@ -58,8 +59,8 @@ namespace NSNetwork
|
||||
virtual int IsRunned() = 0;
|
||||
|
||||
//events
|
||||
virtual void SetEvent_OnProgress(CFileTransporter_OnProgress) = 0;
|
||||
virtual void SetEvent_OnComplete(CFileTransporter_OnComplete) = 0;
|
||||
virtual void SetEvent_OnProgress(std::function<void(int)>) = 0;
|
||||
virtual void SetEvent_OnComplete(std::function<void(int)>) = 0;
|
||||
};
|
||||
|
||||
#ifdef _MAC
|
||||
@ -92,8 +93,8 @@ namespace NSNetwork
|
||||
virtual void Resume();
|
||||
virtual void Stop();
|
||||
virtual int IsRunned();
|
||||
virtual void SetEvent_OnProgress(CFileTransporter_OnProgress);
|
||||
virtual void SetEvent_OnComplete(CFileTransporter_OnComplete);
|
||||
virtual void SetEvent_OnProgress(std::function<void(int)>);
|
||||
virtual void SetEvent_OnComplete(std::function<void(int)>);
|
||||
|
||||
private:
|
||||
CFileTransporter_private* m_pInternal;
|
||||
@ -122,8 +123,8 @@ namespace NSNetwork
|
||||
virtual void Resume();
|
||||
virtual void Stop();
|
||||
virtual int IsRunned();
|
||||
virtual void SetEvent_OnProgress(CFileTransporter_OnProgress);
|
||||
virtual void SetEvent_OnComplete(CFileTransporter_OnComplete);
|
||||
virtual void SetEvent_OnProgress(std::function<void(int)>);
|
||||
virtual void SetEvent_OnComplete(std::function<void(int)>);
|
||||
|
||||
private:
|
||||
CFileTransporter_private* m_pInternal;
|
||||
|
||||
@ -103,11 +103,11 @@ namespace NSNetwork
|
||||
void CFileDownloader::Stop() { m_pInternal->Stop(); }
|
||||
int CFileDownloader::IsRunned() { return m_pInternal->IsRunned(); }
|
||||
|
||||
void CFileDownloader::SetEvent_OnProgress(CFileTransporter_OnProgress func)
|
||||
void CFileDownloader::SetEvent_OnProgress(std::function<void(int)> func)
|
||||
{
|
||||
m_pInternal->GetInternal()->m_func_onProgress = func;
|
||||
}
|
||||
void CFileDownloader::SetEvent_OnComplete(CFileTransporter_OnComplete func)
|
||||
void CFileDownloader::SetEvent_OnComplete(std::function<void(int)> func)
|
||||
{
|
||||
m_pInternal->GetInternal()->m_func_onComplete = func;
|
||||
}
|
||||
@ -166,11 +166,11 @@ namespace NSNetwork
|
||||
void CFileUploader::Stop() { m_pInternal->Stop(); }
|
||||
int CFileUploader::IsRunned() { return m_pInternal->IsRunned(); }
|
||||
|
||||
void CFileUploader::SetEvent_OnProgress(CFileTransporter_OnProgress func)
|
||||
void CFileUploader::SetEvent_OnProgress(std::function<void(int)> func)
|
||||
{
|
||||
m_pInternal->GetInternal()->m_func_onProgress = func;
|
||||
}
|
||||
void CFileUploader::SetEvent_OnComplete(CFileTransporter_OnComplete func)
|
||||
void CFileUploader::SetEvent_OnComplete(std::function<void(int)> func)
|
||||
{
|
||||
m_pInternal->GetInternal()->m_func_onComplete = func;
|
||||
}
|
||||
|
||||
@ -141,8 +141,8 @@ namespace NSNetwork
|
||||
|
||||
std::wstring m_sResponse; // Ответ сервера
|
||||
|
||||
CFileTransporter_OnComplete m_func_onComplete;
|
||||
CFileTransporter_OnProgress m_func_onProgress;
|
||||
std::function<void(int)> m_func_onComplete;
|
||||
std::function<void(int)> m_func_onProgress;
|
||||
};
|
||||
|
||||
class CFileTransporter_private : public NSThreads::CBaseThread
|
||||
|
||||
Reference in New Issue
Block a user