mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
(-setStreamBufferCapacity:): Renamed from -setStreamBufferSize.
(-streamBufferCapacity): Renamed from -streamBufferSize. (-isWriteable): New method. (-streamBufferPrefix): Renamed from -streamPrefix. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@369 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
145826e50f
commit
6f0bc21bcb
1 changed files with 23 additions and 16 deletions
|
@ -47,6 +47,12 @@
|
||||||
/* This could be done with a set of classes instead. */
|
/* This could be done with a set of classes instead. */
|
||||||
enum {MALLOC_MEMORY_STREAM = 0, OBSTACK_MEMORY_STREAM, VM_MEMORY_STREAM};
|
enum {MALLOC_MEMORY_STREAM = 0, OBSTACK_MEMORY_STREAM, VM_MEMORY_STREAM};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
STREAM_READONLY = 0,
|
||||||
|
STREAM_READWRITE,
|
||||||
|
STREAM_WRITEONLY
|
||||||
|
};
|
||||||
|
|
||||||
#define DEFAULT_MEMORY_STREAM_SIZE 64
|
#define DEFAULT_MEMORY_STREAM_SIZE 64
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
|
@ -68,7 +74,7 @@ static BOOL debug_memory_stream = YES;
|
||||||
prefix: (unsigned)p /* never read/write before this position */
|
prefix: (unsigned)p /* never read/write before this position */
|
||||||
position: (unsigned)i /* current position for reading/writing */
|
position: (unsigned)i /* current position for reading/writing */
|
||||||
{
|
{
|
||||||
[super initWithMode:STREAM_READWRITE];
|
[super init];
|
||||||
buffer = b;
|
buffer = b;
|
||||||
size = s;
|
size = s;
|
||||||
prefix = p;
|
prefix = p;
|
||||||
|
@ -78,6 +84,7 @@ static BOOL debug_memory_stream = YES;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* xxx This method will disappear. */
|
||||||
- initWithSize: (unsigned)s
|
- initWithSize: (unsigned)s
|
||||||
prefix: (unsigned)p
|
prefix: (unsigned)p
|
||||||
position: (unsigned)i
|
position: (unsigned)i
|
||||||
|
@ -88,15 +95,19 @@ static BOOL debug_memory_stream = YES;
|
||||||
prefix:p position:i];
|
prefix:p position:i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* xxx Put mode in here */
|
- initWithCapacity: (unsigned)capacity
|
||||||
- initWithSize: (unsigned)s
|
|
||||||
{
|
{
|
||||||
return [self initWithSize:s prefix:0 position:0];
|
return [self initWithSize:capacity prefix:0 position:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithMode: (int)m
|
- initWithSize: (unsigned)s
|
||||||
{
|
{
|
||||||
return [self initWithSize: DEFAULT_MEMORY_STREAM_SIZE];
|
return [self initWithCapacity:s];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) isWritable
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) encodeWithCoder: anEncoder
|
- (void) encodeWithCoder: anEncoder
|
||||||
|
@ -193,7 +204,7 @@ void unchar_func(void *s, int c)
|
||||||
Using GNU stdio streams would do the trick.
|
Using GNU stdio streams would do the trick.
|
||||||
*/
|
*/
|
||||||
if (size - (prefix + position) < 128)
|
if (size - (prefix + position) < 128)
|
||||||
[self setStreamBufferSize:size*2];
|
[self setStreamBufferCapacity:size*2];
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
ret = vsprintf(buffer+prefix+position, format, ap);
|
ret = vsprintf(buffer+prefix+position, format, ap);
|
||||||
|
@ -255,22 +266,17 @@ void unchar_func(void *s, int c)
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned) streamBufferSize
|
- (unsigned) streamBufferCapacity
|
||||||
{
|
{
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *) streamBuffer
|
- (char*) streamBuffer
|
||||||
{
|
{
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned) prefix
|
- (void) setStreamBufferCapacity: (unsigned)s
|
||||||
{
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setStreamBufferSize: (unsigned)s
|
|
||||||
{
|
{
|
||||||
if (s > prefix + eofPosition)
|
if (s > prefix + eofPosition)
|
||||||
{
|
{
|
||||||
|
@ -290,7 +296,7 @@ void unchar_func(void *s, int c)
|
||||||
eofPosition = i;
|
eofPosition = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned) streamPrefix
|
- (unsigned) streamBufferPrefix
|
||||||
{
|
{
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
@ -299,4 +305,5 @@ void unchar_func(void *s, int c)
|
||||||
{
|
{
|
||||||
return prefix + eofPosition;
|
return prefix + eofPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue