Sciter: F:/hsmile5/sdk/include/sciter-x-request.hpp Source File

Sciter  3.3.2.5
Sciter API
sciter-x-request.hpp
Go to the documentation of this file.
1 /*
2  * The Sciter Engine of Terra Informatica Software, Inc.
3  * http://sciter.com
4  *
5  * The code and information provided "as-is" without
6  * warranty of any kind, either expressed or implied.
7  *
8  * (C) Terra Informatica Software, Inc.
9  */
10 
11 /*
12  * Sciter's get resource request object - represents requests made by Element/View.request() functions.
13  *
14  *
15  * C++ wrapper
16  */
17 
18 
19 #ifndef __sciter_request_hpp__
20 #define __sciter_request_hpp__
21 
22 #include "sciter-x-request.h"
23 #include "sciter-x-api.h"
24 
25 #if defined(__cplusplus) && !defined( PLAIN_API_ONLY )
26 
27 #include "aux-slice.h"
28 
29 namespace sciter
30 {
31 
32  inline VOID SC_CALLBACK _LPCWSTR2STRING( LPCWSTR str, UINT str_length, LPVOID param )
33  {
34  sciter::string* s = (sciter::string*)param;
35  *s = sciter::string(str,str_length);
36  }
37  inline VOID SC_CALLBACK _LPCSTR2STRING( LPCSTR str, UINT str_length, LPVOID param )
38  {
39  sciter::astring* s = (sciter::astring*)param;
40  *s = sciter::astring(str,str_length);
41  }
42 
43 
44 /* struct writer
45  {
46  virtual bool write( aux::bytes data ) = 0; // redefine to do actual writing of data.start/data.length
47  static BOOL SCAPI image_write_function(LPVOID prm, const BYTE* data, UINT data_length)
48  {
49  writer* pw = (writer* )prm;
50  return pw->write( aux::bytes(data,data_length) );
51  }
52  }; */
53 
54  class request
55  {
56  protected:
57  HREQUEST hrq;
58 
59  request(): hrq(0) { ; }
60 
61  public:
62 
63  request(HREQUEST h): hrq(h) { if(hrq) rapi()->RequestUse(hrq); }
64  request(const request& im): hrq(im.hrq) { if(hrq) rapi()->RequestUse(hrq); }
65  request& operator = (const request& im)
66  {
67  if(hrq) rapi()->RequestUnUse(hrq);
68  hrq = im.hrq; rapi()->RequestUse(hrq);
69  return *this;
70  }
71 
72  bool is_valid() const { return hrq != 0; }
73 
74  ~request() {
75  rapi()->RequestUnUse( hrq );
76  }
77 
78  sciter::astring url() {
79  sciter::astring rv;
80  rapi()->RequestUrl( hrq, _LPCSTR2STRING, &rv );
81  return rv;
82  }
83 
84  sciter::astring content_url() {
85  sciter::astring rv;
86  rapi()->RequestContentUrl( hrq, _LPCSTR2STRING, &rv );
87  return rv;
88  }
89 
90  SciterResourceType requested_type() {
91  SciterResourceType rv = SciterResourceType();
92  rapi()->RequestGetRequestedDataType( hrq, &rv );
93  return rv;
94  }
95 
96  void succeeded( UINT status, LPCBYTE dataOrNull = NULL, UINT dataLength = 0 )
97  {
98  rapi()->RequestSetSucceeded( hrq, status, dataOrNull, dataLength);
99  }
100 
101  void failed( UINT status, LPCBYTE dataOrNull = NULL, UINT dataLength = 0 )
102  {
103  rapi()->RequestSetFailed( hrq, status, dataOrNull, dataLength);
104  }
105 
106  void append_data( LPCBYTE data, UINT dataLength)
107  {
108  rapi()->RequestAppendDataChunk( hrq, data, dataLength);
109  }
110 
111  };
112 
113 }
114 
115 #endif //defined(__cplusplus) && !defined( PLAIN_API_ONLY )
116 
117 
118 #endif
119 
REQUEST_RESULT SCFN() RequestGetRequestedDataType(HREQUEST rq, SciterResourceType *pData)
REQUEST_RESULT SCFN() RequestUrl(HREQUEST rq, LPCSTR_RECEIVER *rcv, LPVOID rcv_param)
REQUEST_RESULT SCFN() RequestUse(HREQUEST rq)
size_t str_length(const TC *src)
Definition: value.hpp:35
html::request * HREQUEST
REQUEST_RESULT SCFN() RequestSetSucceeded(HREQUEST rq, UINT status, LPCBYTE dataOrNull, UINT dataLength)
std::basic_string< char > astring
Definition: value.hpp:44
REQUEST_RESULT SCFN() RequestSetFailed(HREQUEST rq, UINT status, LPCBYTE dataOrNull, UINT dataLength)
const BYTE * LPCBYTE
REQUEST_RESULT SCFN() RequestUnUse(HREQUEST rq)
SciterResourceType
REQUEST_RESULT SCFN() RequestContentUrl(HREQUEST rq, LPCSTR_RECEIVER *rcv, LPVOID rcv_param)
VOID SC_CALLBACK _LPCWSTR2STRING(LPCWSTR str, UINT str_length, LPVOID param)
Definition: sciter-x-dom.hpp:46
LPSciterRequestAPI rapi()
Definition: sciter-x-api.h:425
REQUEST_RESULT SCFN() RequestAppendDataChunk(HREQUEST rq, LPCBYTE data, UINT dataLength)
std::basic_string< WCHAR > string
Definition: value.hpp:42

AltStyle によって変換されたページ (->オリジナル) /