2005-05-28 00:45:31 +02:00
|
|
|
/*
|
|
|
|
*
|
2008-04-29 13:23:06 +02:00
|
|
|
* The contents of this file are subject to the Initial
|
|
|
|
* Developer's Public License Version 1.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
* http://www.ibphoenix.com/idpl.html.
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on
|
|
|
|
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
|
|
* express or implied. See the License for the specific
|
2005-05-28 00:45:31 +02:00
|
|
|
* language governing rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The contents of this file or any work derived from this file
|
2008-04-29 13:23:06 +02:00
|
|
|
* may not be distributed under any other license whatsoever
|
|
|
|
* without the express prior written permission of the original
|
2005-05-28 00:45:31 +02:00
|
|
|
* author.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* The Original Code was created by James A. Starkey for IBPhoenix.
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997 - 2000, 2001, 2003 James A. Starkey
|
|
|
|
* Copyright (c) 1997 - 2000, 2001, 2003 Netfrastructure, Inc.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Stream.h: interface for the Stream class.
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#if !defined(AFX_STREAM_H__02AD6A53_A433_11D2_AB5B_0000C01D2301__INCLUDED_)
|
|
|
|
#define AFX_STREAM_H__02AD6A53_A433_11D2_AB5B_0000C01D2301__INCLUDED_
|
|
|
|
|
2005-06-21 12:26:56 +02:00
|
|
|
#if defined _MSC_VER && _MSC_VER >= 1000
|
2005-05-28 00:45:31 +02:00
|
|
|
#pragma once
|
|
|
|
#endif // _MSC_VER >= 1000
|
|
|
|
|
2008-04-24 17:49:43 +02:00
|
|
|
#include "../common/classes/fb_string.h"
|
2005-05-28 00:45:31 +02:00
|
|
|
|
|
|
|
START_NAMESPACE
|
|
|
|
|
2008-04-24 17:49:43 +02:00
|
|
|
class Stream : public Firebird::GlobalStorage
|
2005-05-28 00:45:31 +02:00
|
|
|
{
|
|
|
|
public:
|
2008-04-29 13:23:06 +02:00
|
|
|
enum { FIXED_SEGMENT_SIZE = 1024 };
|
|
|
|
|
|
|
|
struct Segment
|
|
|
|
{
|
|
|
|
int length;
|
|
|
|
char *address;
|
|
|
|
Segment *next;
|
|
|
|
char tail [FIXED_SEGMENT_SIZE];
|
|
|
|
};
|
|
|
|
|
2008-04-20 12:40:58 +02:00
|
|
|
explicit Stream (int minSegmentSize = FIXED_SEGMENT_SIZE);
|
|
|
|
virtual ~Stream();
|
|
|
|
|
2008-04-19 11:40:19 +02:00
|
|
|
int compare (const Stream *stream) const;
|
2005-05-28 00:45:31 +02:00
|
|
|
void truncate (int length);
|
|
|
|
void format (const char *pattern, ...);
|
|
|
|
void putSegment (int length, const unsigned short *chars);
|
|
|
|
void putSegment (Stream *stream);
|
|
|
|
virtual void putSegment (const char *string);
|
|
|
|
virtual void putSegment (int length, const char *address, bool copy);
|
|
|
|
void putCharacter (char c);
|
|
|
|
|
2008-04-29 13:23:06 +02:00
|
|
|
virtual void setSegment (Segment *segment, int length, void* address);
|
|
|
|
virtual int getSegment (int offset, int len, void* ptr) const;
|
2008-04-19 11:40:19 +02:00
|
|
|
virtual int getSegment (int offset, int len, void *ptr, char delimiter) const;
|
2005-05-28 00:45:31 +02:00
|
|
|
void* getSegment (int offset);
|
2008-04-19 11:40:19 +02:00
|
|
|
const void* getSegment (int offset) const;
|
|
|
|
int getSegmentLength(int offset) const;
|
2005-05-28 00:45:31 +02:00
|
|
|
|
2008-04-29 13:23:06 +02:00
|
|
|
Firebird::string getFBString() const;
|
2005-05-28 00:45:31 +02:00
|
|
|
virtual char* getString();
|
|
|
|
void clear();
|
2008-04-19 11:40:19 +02:00
|
|
|
virtual int getLength() const;
|
2005-05-28 00:45:31 +02:00
|
|
|
virtual char* alloc (int length);
|
|
|
|
|
|
|
|
Segment* allocSegment (int tail);
|
|
|
|
void setMinSegment (int length);
|
|
|
|
|
|
|
|
int totalLength;
|
2008-04-20 12:40:58 +02:00
|
|
|
//int useCount;
|
|
|
|
Segment *segments; // used by StreamSegment::setStream
|
|
|
|
private:
|
2005-05-28 00:45:31 +02:00
|
|
|
int minSegment;
|
|
|
|
int currentLength;
|
|
|
|
int decompressedLength;
|
|
|
|
bool copyFlag;
|
|
|
|
Segment first;
|
|
|
|
Segment *current;
|
|
|
|
};
|
|
|
|
|
|
|
|
END_NAMESPACE
|
|
|
|
|
|
|
|
#endif // !defined(AFX_STREAM_H__02AD6A53_A433_11D2_AB5B_0000C01D2301__INCLUDED_)
|