2004-10-22 08:24:40 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: Client/Server Common Code
|
|
|
|
* MODULE: ClumpletWriter.h
|
|
|
|
* DESCRIPTION: Secure handling of clumplet buffers
|
|
|
|
*
|
|
|
|
* 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/main.nfs?a=ibphoenix&page=ibp_idpl.
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed AS IS,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing rights
|
|
|
|
* and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Nickolay Samofatov
|
|
|
|
* for the Firebird Open Source RDBMS project.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Nickolay Samofatov <nickolay@broadviewsoftware.com>
|
|
|
|
* and all contributors signed below.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-10-23 03:21:11 +02:00
|
|
|
#ifndef CLUMPLETWRITER_H
|
|
|
|
#define CLUMPLETWRITER_H
|
2004-10-22 08:24:40 +02:00
|
|
|
|
|
|
|
#include "../common/classes/ClumpletReader.h"
|
2004-11-15 17:34:47 +01:00
|
|
|
#include "../common/classes/array.h"
|
2004-10-22 08:24:40 +02:00
|
|
|
|
2004-12-09 20:19:47 +01:00
|
|
|
// This setting of maximum dpb size doesn't mean, that we
|
|
|
|
// can't process larger DBPs! This is just recommended limit
|
|
|
|
// cause it's hard to imagine sensefull DPB of even this size.
|
|
|
|
const size_t MAX_DPB_SIZE = 1024;
|
|
|
|
|
2004-10-22 08:24:40 +02:00
|
|
|
namespace Firebird {
|
|
|
|
|
|
|
|
// At the moment you can only declare it on stack, permanent objects are not allowed
|
2004-12-17 06:40:10 +01:00
|
|
|
class ClumpletWriter : public ClumpletReader
|
|
|
|
{
|
2004-10-22 08:24:40 +02:00
|
|
|
public:
|
2004-11-03 09:38:09 +01:00
|
|
|
// Create empty clumplet writer.
|
|
|
|
ClumpletWriter(bool isTagged, size_t limit, UCHAR tag = 0);
|
2004-10-23 03:21:11 +02:00
|
|
|
|
|
|
|
// Create writer from a given buffer
|
2004-12-09 20:19:47 +01:00
|
|
|
ClumpletWriter(bool isTagged, size_t limit, const UCHAR* buffer, size_t buffLen, UCHAR tag);
|
2004-10-23 03:21:11 +02:00
|
|
|
|
|
|
|
void reset(UCHAR tag);
|
|
|
|
void reset(const UCHAR* buffer, size_t buffLen);
|
2004-10-22 08:24:40 +02:00
|
|
|
|
|
|
|
// Methods to create new clumplet at current position
|
|
|
|
void insertInt(UCHAR tag, SLONG value);
|
|
|
|
void insertBigInt(UCHAR tag, SINT64 value);
|
2004-11-03 09:38:09 +01:00
|
|
|
void insertBytes(UCHAR tag, const UCHAR* bytes, size_t length);
|
2004-10-22 08:24:40 +02:00
|
|
|
void insertString(UCHAR tag, const string& str);
|
2004-11-15 17:34:47 +01:00
|
|
|
void insertPath(UCHAR tag, const PathName& str);
|
2004-11-03 09:38:09 +01:00
|
|
|
void insertString(UCHAR tag, const char* str, size_t length);
|
2004-12-09 20:19:47 +01:00
|
|
|
void insertByte(UCHAR tag, const UCHAR byte)
|
|
|
|
{
|
|
|
|
insertBytesNoLengthCheck(tag, &byte, 1);
|
|
|
|
}
|
|
|
|
void insertTag(UCHAR tag);
|
2004-10-22 08:24:40 +02:00
|
|
|
void insertEndMarker(UCHAR tag);
|
|
|
|
|
|
|
|
// Delete currently selected clumplet from buffer
|
|
|
|
void deleteClumplet();
|
|
|
|
|
2004-12-09 20:19:47 +01:00
|
|
|
virtual const UCHAR* getBuffer() const { return dynamic_buffer.begin(); }
|
2004-10-22 08:24:40 +02:00
|
|
|
protected:
|
2004-12-09 20:19:47 +01:00
|
|
|
virtual const UCHAR* getBufferEnd() const { return dynamic_buffer.end(); }
|
2004-10-22 08:24:40 +02:00
|
|
|
virtual void size_overflow();
|
2004-11-03 09:38:09 +01:00
|
|
|
void insertBytesNoLengthCheck(UCHAR tag, const UCHAR* bytes, UCHAR length);
|
2004-10-22 08:24:40 +02:00
|
|
|
private:
|
|
|
|
size_t sizeLimit;
|
|
|
|
|
|
|
|
// Assignment and copy constructor not implemented.
|
|
|
|
ClumpletWriter(const ClumpletWriter& from);
|
|
|
|
ClumpletWriter& operator=(const ClumpletWriter& from);
|
|
|
|
|
2004-11-15 17:34:47 +01:00
|
|
|
HalfStaticArray<UCHAR, 128> dynamic_buffer;
|
2004-10-22 08:24:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Firebird
|
|
|
|
|
2004-12-12 02:55:21 +01:00
|
|
|
#endif // CLUMPLETWRITER_H
|
|
|
|
|