• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiónabc10232bc18ef1bb46c957ceec0a9e1805f4182 (tree)
Tiempo2012-03-30 07:59:01
Autorqwerty2501 <qwerty2501@user...>
Commiterqwerty2501

Log Message

xmlhttpapi実装

Cambiar Resumen

Diferencia incremental

Binary files a/nlite.suo and b/nlite.suo differ
--- a/nlite_common/http.cpp
+++ b/nlite_common/http.cpp
@@ -1,4 +1,5 @@
11 #include "stdafx.h"
2+#include "nexception.h"
23 #include "define.h"
34 #include "http.h"
45
@@ -11,8 +12,10 @@ CWinHttpClient::CWinHttpClient(){
1112
1213 CHResult CWinHttpClient::Open(const NString &method,const NString &url,const _variant_t &async){
1314
14- return m_ptr->Open(method.c_str(),url.c_str(),async);
15-
15+ CHResult result = m_ptr->Open(method.c_str(),url.c_str(),async);
16+ CHECK_HRESULT(result);
17+
18+ return result;
1619 }
1720
1821
@@ -27,13 +30,17 @@ CHResult CWinHttpClient::get_Response(IStream **ppStream){
2730
2831
2932 }
33+ CHECK_HRESULT(result);
3034
3135 return result;
3236 }
3337
3438 CHResult CWinHttpClient::SetRequestHeader(const NString &headerName,const NString &headerBody){
3539
36- return m_ptr->SetRequestHeader(headerName.c_str(),headerBody.c_str());
40+ CHResult result = m_ptr->SetRequestHeader(headerName.c_str(),headerBody.c_str());
41+ CHECK_HRESULT(result);
42+
43+ return result;
3744 }
3845
3946 CHResult CWinHttpClient::SetRequestHeader(const cookie::CCookie &val){
@@ -44,12 +51,16 @@ CHResult CWinHttpClient::SetRequestHeader(const cookie::CCookie &val){
4451 ss << _T("=");
4552 ss << val.GetCookieValue();
4653
47- return m_ptr->SetRequestHeader(_T("Cookie"),ss.str().c_str());
54+ CHResult result = m_ptr->SetRequestHeader(_T("Cookie"),ss.str().c_str());
4855
56+ CHECK_HRESULT(result);
57+ return result;
4958 }
5059
5160 CHResult CWinHttpClient::Send(const _variant_t &value){
5261
53- return m_ptr->Send(value);
62+ CHResult result = m_ptr->Send(value);
63+ CHECK_HRESULT(result);
64+ return result;
5465 }
5566 #include "namespace_end.h"
\ No newline at end of file
--- a/nlite_common/http.h
+++ b/nlite_common/http.h
@@ -53,17 +53,14 @@ public:
5353
5454 CXmlReader xmlReader;
5555
56- result = xmlReader.Create();
56+ xmlReader.Create();
5757
58- if(result.IsSucceded()){
58+ xmlReader.SetInput(pStream);
5959
60- result = xmlReader.SetInput(pStream);
6160
62- if(result.IsSucceded()){
63-
64- result = func(xmlReader);
65- }
66- }
61+ result = func(xmlReader);
62+
63+ CHECK_HRESULT(result);
6764
6865 }
6966
--- a/nlite_common/nexception.h
+++ b/nlite_common/nexception.h
@@ -57,4 +57,8 @@ class Exception:public std::runtime_error{
5757
5858 #define THROW_EXCEPTION(E,M) throw E(M,__LINE__,_T(__FILE__),_T(__FUNCTION__))
5959
60+#define THROW_HRESULTEXCEPTION() THROW_EXCEPTION(Exception,_T("HResult例外値が発生しました"))
61+
62+#define CHECK_HRESULT(r) if(r.IsFailed())THROW_HRESULTEXCEPTION()
63+
6064 #include "namespace_end.h"
\ No newline at end of file
--- a/nlite_common/windowsAPI.h
+++ b/nlite_common/windowsAPI.h
@@ -47,6 +47,7 @@ static_assert(sizeof(CHResult) <= 4,"CHResult size error");
4747
4848
4949
50+
5051 ///
5152 ///レジストリキークラス
5253 ///
--- a/nlite_common/xmlReader.cpp
+++ b/nlite_common/xmlReader.cpp
@@ -1,4 +1,5 @@
11 #include "stdafx.h"
2+#include "nexception.h"
23 #include "xmlReader.h"
34
45 #include "namespace_start.h"
@@ -13,28 +14,38 @@ CHResult CXmlReader::Create(REFIID riid,IMalloc *pMalloc){
1314
1415 CHResult CXmlReader::SetInput(IStream *pStream){
1516
16- return m_xmlReader->SetInput(pStream);
17+ CHResult result = m_xmlReader->SetInput(pStream);
18+ CHECK_HRESULT(result);
19+ return result;
1720 }
1821
1922
2023 CHResult CXmlReader::Read(XmlNodeType *pXmlNodeType){
2124
2225
23- return m_xmlReader->Read(pXmlNodeType);
26+ CHResult result = m_xmlReader->Read(pXmlNodeType);
27+ CHECK_HRESULT(result);
28+ return result;
2429 }
2530
2631 CHResult CXmlReader::GetLocalName(const NChar **ppLocalName,UInt *pLocalNameLen){
2732
28- return m_xmlReader->GetLocalName(ppLocalName,pLocalNameLen);
33+ CHResult result = m_xmlReader->GetLocalName(ppLocalName,pLocalNameLen);
34+ CHECK_HRESULT(result);
35+ return result;
2936 }
3037
31-CHResult CXmlReader::GetValue(const NChar **ppValue,UInt *pValueLen = nullptr){
38+CHResult CXmlReader::GetValue(const NChar **ppValue,UInt *pValueLen){
3239
33- return m_xmlReader->GetValue(ppValue,pValueLen);
40+ CHResult result = m_xmlReader->GetValue(ppValue,pValueLen);
41+ CHECK_HRESULT(result);
42+ return result;
3443 }
3544 CHResult CXmlReader::MoveToFirstAttribute(){
3645
37- return m_xmlReader->MoveToFirstAttribute();
46+ CHResult result = m_xmlReader->MoveToFirstAttribute();
47+ CHECK_HRESULT(result);
48+ return result;
3849 }
3950
4051 #include "namespace_end.h"
\ No newline at end of file
--- a/nlite_nicoapi/nlite_nicoapi.vcxproj
+++ b/nlite_nicoapi/nlite_nicoapi.vcxproj
@@ -109,6 +109,7 @@
109109 <ClInclude Include="stdafx.h" />
110110 <ClInclude Include="targetver.h" />
111111 <ClInclude Include="unit_test.h" />
112+ <ClInclude Include="xmlHttpApi.h" />
112113 </ItemGroup>
113114 <ItemGroup>
114115 <ClCompile Include="auth.cpp" />
--- a/nlite_nicoapi/nlite_nicoapi.vcxproj.filters
+++ b/nlite_nicoapi/nlite_nicoapi.vcxproj.filters
@@ -39,6 +39,9 @@
3939 <ClInclude Include="auth.h">
4040 <Filter>ヘッダー ファイル</Filter>
4141 </ClInclude>
42+ <ClInclude Include="xmlHttpApi.h">
43+ <Filter>ヘッダー ファイル</Filter>
44+ </ClInclude>
4245 </ItemGroup>
4346 <ItemGroup>
4447 <ClCompile Include="stdafx.cpp">
--- /dev/null
+++ b/nlite_nicoapi/xmlHttpApi.h
@@ -0,0 +1,30 @@
1+#pragma once
2+
3+
4+#include <nlite_common\http.h>
5+
6+
7+
8+#include "namespace_start.h"
9+
10+class CXmlHttpAPI{
11+
12+private:
13+ CWinHttpClient httpClient;
14+
15+public:
16+
17+ template<typename F>
18+
19+ Bool Get(const NString &method,const NString &url,F func){
20+
21+ httpClient.Open(method,url);
22+ CHResult result =httpClient.get_ResponseXml(func);
23+ return result.IsSucceded();
24+ }
25+
26+};
27+
28+
29+
30+#include "namespace_end.h"
\ No newline at end of file