OROCHI
 
Loading...
Searching...
No Matches
GxCurl.h
Go to the documentation of this file.
1//===========================================================================
9//===========================================================================
10#pragma once
11
12#if GX_EDITOR
13GX_NETWORK_NAMESPACE_BEGIN()
14
15//===========================================================================
17//===========================================================================
18class GxCurl : public GxClassBase
19{
20 //-----------------------------------------------------------
22 //-----------------------------------------------------------
24public:
26 class GxDownloadThread : public GxThread
27 {
28 //-------------------------------------------------------------
30 //-------------------------------------------------------------
32 public:
33 GX_RTTI_CLASS(GxDownloadThread, GxThread)
34 // GxClassBase継承クラス用禁止宣言
35 GX_PROHIBIT_CLASS_BASE(GxDownloadThread)
36
37
38 //-----------------------------------------------------------
40 //-----------------------------------------------------------
42
44 GxDownloadThread(void){}
45
47 //-----------------------------------------------------------
49 //-----------------------------------------------------------
51 public:
53 void threadMain(void* pArgument) override;
55 GX_FORCE_INLINE void stopRequest(void) { _stopRequest = true; }
56 private:
58 static size_t bufferWriter(GX_STR pSrc, size_t size, size_t count, void* pFilePointer);
59
61 //-----------------------------------------------------------
63 //-----------------------------------------------------------
65 private:
66 b32 _stopRequest;
67
69 };
70
71private:
73 struct GxDownloadRequest
74 {
75 GxString _url;
76 GxString _outputPath;
77 b32 _unzip;
79 };
80
81public:
82 // RTTI定義
83 GX_RTTI_CLASS( GxCurl, GxClassBase )
84
85
86 //-----------------------------------------------------------
88 //-----------------------------------------------------------
90public:
92 GxCurl(void);
94 ~GxCurl(void) override;
95
97 //-----------------------------------------------------------
99 //-----------------------------------------------------------
101public:
103 void downloadAsync(GX_CSTR url, GX_CSTR outputPath, b32 unzip = false, GxCallback::GxHandlerBase* pCallback = nullptr);
105 GX_FORCE_INLINE u32 getDownloadRequestCount(void) const { return (_requests.isEmpty() && _downloadProgress >= 100) ? 0 : _requests.getCount() + 1; }
106private:
108 s32 progressCallback(s64 downloadTotal, s64 downloadNow, s64 uploadTotal, s64 uploadNow);
109
111 //-----------------------------------------------------------
113 //-----------------------------------------------------------
115public:
117 constexpr f64 getDownloadProgress(void) const { return _downloadProgress; }
119 constexpr f64 getUploadProgress(void) const { return _uploadProgress; }
120public:
122 constexpr void setProgress(f64 downloadProgress, f64 uploadProgress) { _downloadProgress = downloadProgress; _uploadProgress = uploadProgress; }
123
125 //-----------------------------------------------------------
127 //-----------------------------------------------------------
129private:
130 CURL* _pCurl;
131 GxDownloadThread _downloadThread;
133 f64 _downloadProgress;
134 f64 _uploadProgress;
135
137};
138
139GX_NETWORK_NAMESPACE_END()
140#endif //GX_EDITOR
#define GX_PROHIBIT_CLASS_BASE(__CLASS__)
GxClassBase継承の禁止宣言
Definition GxBase.h:240
ハンドラ基本クラス
Definition GxCallback.h:27
オブジェクト基底クラス
Definition GxBase.h:88
キュー (ロック不要)
Definition GxLockFreeQueue.h:19
スレッドクラス
Definition GxThread.h:177
virtual void threadMain(void *pArgument)=0
メインループ
文字列型クラス
Definition GxString.h:18
32bitブーリアン
Definition GxDefine.h:173