#include <string.h>
#include "MemoryStream.h"
namespace
{
namespace
{
void
::
(
)
{
if
(
>
)
{
=(
/
+
1
)*
;
char
*
=
new
char
[
];
if
(
)
{
(
newBuffer
,
,
);
delete
[]
;
}
=
newBuffer
;
=
;
}
}
::
(
)
:block(
)
,buffer(
0
)
,size(
0
)
,position(
0
)
,capacity(
0
)
{
if
(
<=
0
)
{
=
65536
;
}
}
::
()
{
();
}
bool
::
()
const
{
return
!=
0
;
}
bool
::
()
const
{
return
!=
0
;
}
bool
::
()
const
{
return
!=
0
;
}
bool
::
()
const
{
return
!=
0
;
}
bool
::
()
const
{
return
false
;
}
bool
::
()
const
{
return
!=
0
;
}
void
::
()
{
if
(
)
{
delete
[]
;
}
=
0
;
=
0
;
=-
1
;
=-
1
;
=
0
;
}
::
()
const
{
return
;
}
::
()
const
{
return
;
}
void
::
(
)
{
(
+
);
}
void
::
(
)
{
CHECK_ERROR(block!=0, L"MemoryStream::SeekFromBegin(pos_t)#Stream is closed, cannot perform this operation.");
do
{
if
(!(
!=
0
))
throw
(
L"MemoryStream::SeekFromBegin(pos_t)#Stream is closed, cannot perform this operation."
);}
while
(
0
);
=(
)
;
if
(
expected
<
0
)
{
=
0
;
}
else
if
(
expected
>=
)
{
=
;
}
else
{
=
expected
;
}
}
void
::
(
)
{
(
-
);
}
::
(
void
*
,
)
{
CHECK_ERROR(block!=0, L"MemoryStream::Read(pos_t)#Stream is closed, cannot perform this operation.");
do
{
if
(!(
!=
0
))
throw
(
L"MemoryStream::Read(pos_t)#Stream is closed, cannot perform this operation."
);}
while
(
0
);
CHECK_ERROR(_size>=0, L"MemoryStream::Read(void*, vint)#Argument size cannot be negative.");
do
{
if
(!(
>=
0
))
throw
(
L"MemoryStream::Read(void*, vint)#Argument size cannot be negative."
);}
while
(
0
);
=
-
;
if
(
>
max
)
{
=
max
;
}
(
,
+
,
);
+=
;
return
;
}
::
(
void
*
,
)
{
CHECK_ERROR(block!=0, L"MemoryStream::Write(pos_t)#Stream is closed, cannot perform this operation.");
do
{
if
(!(
!=
0
))
throw
(
L"MemoryStream::Write(pos_t)#Stream is closed, cannot perform this operation."
);}
while
(
0
);
CHECK_ERROR(_size>=0, L"MemoryStream::Write(void*, vint)#Argument size cannot be negative.");
do
{
if
(!(
>=
0
))
throw
(
L"MemoryStream::Write(void*, vint)#Argument size cannot be negative."
);}
while
(
0
);
(
+
);
(
+
,
,
);
+=
;
if
(
<
)
{
=
;
}
return
;
}
::
(
void
*
,
)
{
CHECK_ERROR(block!=0, L"MemoryStream::Peek(pos_t)#Stream is closed, cannot perform this operation.");
do
{
if
(!(
!=
0
))
throw
(
L"MemoryStream::Peek(pos_t)#Stream is closed, cannot perform this operation."
);}
while
(
0
);
CHECK_ERROR(_size>=0, L"MemoryStream::Peek(void*, vint)#Argument size cannot be negative.");
do
{
if
(!(
>=
0
))
throw
(
L"MemoryStream::Peek(void*, vint)#Argument size cannot be negative."
);}
while
(
0
);
=
-
;
if
(
>
max
)
{
=
max
;
}
(
,
+
,
);
return
;
}
void
*
::
()
{
return
;
}
}
}