DCL 4.0
Loading...
Searching...
No Matches
HttpStream.cpp
Go to the documentation of this file.
1
2#include <dcl/Object.h>
3#if __DCL_HAVE_ALLOC_DEBUG
4#undef __DCL_ALLOC_LEVEL
5#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
6#endif
7
8#include <dcl/HttpServlet.h>
9#include <dcl/HttpStream.h>
10
11#define __DEBUG_THIS 0
12#if __DEBUG_THIS
13#define __DCL_TRACE1_N __DCL_TRACE1
14#define __DCL_TRACE2_N __DCL_TRACE2
15#define __DCL_TRACE3_N __DCL_TRACE3
16#else
17#define __DCL_TRACE1_N(fmt, arg)
18#define __DCL_TRACE2_N(fmt, arg1, arg2)
19#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
20#endif
21
22#if __DCL_DEBUG
23#undef __THIS_FILE__
24static const char_t* __THIS_FILE__ = __T("dcl/HttpStream.cpp");
25#endif
26
27__DCL_BEGIN_NAMESPACE
28
30
31HttpInputStream::HttpInputStream(
33 )
34{
35 __DCL_ASSERT(_ctx != NULL);
36 __ctx = _ctx;
37}
38
39size_t HttpInputStream::read(
40 void* _buf,
41 size_t _n
43{
44 size_t nTotalRead = 0;
45 while(nTotalRead < _n) {
46 size_t nRead = __ctx->read(
47 (void*)(((byte_t*)_buf) + nTotalRead),
48 _n - nTotalRead
49 );
50 if (nRead)
51 nTotalRead += nRead;
52 else {
53 break;
54 }
55 }
56 return nTotalRead;
57}
58
60
61HttpOutputStream::HttpOutputStream(HttpServletContext* _ctx)
62{
63 __DCL_ASSERT(_ctx != NULL);
64 __ctx = _ctx;
65}
66
67OutputStream& HttpOutputStream::write(const void* _buf, size_t _n)
69{
70 __ctx->write(_buf, _n);
71 return *this;
72}
73
74__DCL_END_NAMESPACE
#define __THIS_FILE__
Definition _trace.h:14
#define NULL
Definition Config.h:340
wchar_t char_t
Definition Config.h:275
unsigned char byte_t
Definition Config.h:274
#define __DCL_THROWS1(e)
Definition Config.h:167
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
Definition Object.h:228
#define __T(str)
Definition Object.h:44
HttpServletContext * __ctx
Definition HttpStream.h:25