DCL 3.7.4
Loading...
Searching...
No Matches
BytesInputStream.cpp
Go to the documentation of this file.
1#include <string.h> // memcpy
3#include <dcl/size_t.h>
4
5#if __DCL_HAVE_ALLOC_DEBUG
6#undef __DCL_ALLOC_LEVEL
7#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
8#endif
9
10#if __DCL_HAVE_THIS_FILE__
11#undef __THIS_FILE__
12static const char_t __THIS_FILE__[] = __T("dcl/BytesInputStream.cpp");
13#endif
14
15__DCL_BEGIN_NAMESPACE
16
18
19String BytesInputStream::toString() const
20{
21 StringBuilder r = className();
22 r.format(__T("(%ubytes)"), __str.length());
23 return r;
24}
25
26BytesInputStream::BytesInputStream(const ByteString& _str)
27{
28 __str = _str;
29 __begin = _str;
30 __end = __begin + _str.length();
31}
32
33size_t BytesInputStream::available() const
35{
36 return __end - __begin;
37}
38
39size_t BytesInputStream::read(void* _buf, size_t _n)
41{
42 __DCL_ASSERT_PARAM(_buf != NULL);
43
44 size_t n = __MIN(__end - __begin, _n);
45 memcpy(_buf, __begin, n);
46 __begin += n;
47
48 return n;
49}
50
51__DCL_END_NAMESPACE
52
#define __THIS_FILE__
Definition _trace.h:14
#define NULL
Definition Config.h:312
wchar_t char_t
Definition Config.h:247
#define __DCL_THROWS1(e)
Definition Config.h:152
IOException *size_t r
Definition MediaInfo.cpp:82
#define __DCL_ASSERT_PARAM(expr)
Definition Object.h:409
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
Definition Object.h:245
#define __T(str)
Definition Object.h:60
const char * __begin
virtual String toString() const
Definition Object.cpp:187
String className() const
Definition Object.cpp:163
size_t __MIN(size_t x, size_t y)
Definition size_t.h:27