mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 22:03:03 +01:00
I can revert the constness if it becomes too restrictive in the future.
This commit is contained in:
parent
e144558663
commit
b59cf9c750
@ -39,16 +39,17 @@ ClumpletReader::ClumpletReader(bool isTagged, const UCHAR* buffer, size_t buffLe
|
||||
{
|
||||
}
|
||||
|
||||
void ClumpletReader::usage_mistake(const char* what) {
|
||||
void ClumpletReader::usage_mistake(const char* what) const {
|
||||
fatal_exception::raiseFmt(
|
||||
"Internal error when using clumplet API: %s", what);
|
||||
}
|
||||
|
||||
void ClumpletReader::invalid_structure() {
|
||||
void ClumpletReader::invalid_structure() const {
|
||||
fatal_exception::raise("Invalid clumplet buffer structure");
|
||||
}
|
||||
|
||||
UCHAR ClumpletReader::getBufferTag() {
|
||||
UCHAR ClumpletReader::getBufferTag() const
|
||||
{
|
||||
if (!mIsTagged) {
|
||||
usage_mistake("buffer is not tagged");
|
||||
return 0;
|
||||
@ -63,7 +64,8 @@ UCHAR ClumpletReader::getBufferTag() {
|
||||
return buffer_start[0];
|
||||
}
|
||||
|
||||
void ClumpletReader::moveNext() {
|
||||
void ClumpletReader::moveNext()
|
||||
{
|
||||
const UCHAR* clumplet = getBuffer() + cur_offset;
|
||||
const UCHAR* buffer_end = getBufferEnd();
|
||||
|
||||
@ -103,7 +105,8 @@ bool ClumpletReader::find(UCHAR tag)
|
||||
}
|
||||
|
||||
// Methods which work with currently selected clumplet
|
||||
UCHAR ClumpletReader::getClumpTag() {
|
||||
UCHAR ClumpletReader::getClumpTag() const
|
||||
{
|
||||
const UCHAR* clumplet = getBuffer() + cur_offset;
|
||||
const UCHAR* buffer_end = getBufferEnd();
|
||||
|
||||
@ -116,7 +119,8 @@ UCHAR ClumpletReader::getClumpTag() {
|
||||
return clumplet[0];
|
||||
}
|
||||
|
||||
size_t ClumpletReader::getClumpLength() {
|
||||
size_t ClumpletReader::getClumpLength() const
|
||||
{
|
||||
const UCHAR* clumplet = getBuffer() + cur_offset;
|
||||
const UCHAR* buffer_end = getBufferEnd();
|
||||
|
||||
@ -142,7 +146,8 @@ size_t ClumpletReader::getClumpLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
SLONG ClumpletReader::getInt() {
|
||||
SLONG ClumpletReader::getInt() const
|
||||
{
|
||||
const UCHAR* clumplet = getBuffer() + cur_offset;
|
||||
size_t length = getClumpLength();
|
||||
|
||||
@ -163,7 +168,8 @@ SLONG ClumpletReader::getInt() {
|
||||
return value;
|
||||
}
|
||||
|
||||
SINT64 ClumpletReader::getBigInt() {
|
||||
SINT64 ClumpletReader::getBigInt() const
|
||||
{
|
||||
const UCHAR* clumplet = getBuffer() + cur_offset;
|
||||
size_t length = getClumpLength();
|
||||
|
||||
@ -184,14 +190,7 @@ SINT64 ClumpletReader::getBigInt() {
|
||||
return value;
|
||||
}
|
||||
|
||||
string& ClumpletReader::getString(string& str) {
|
||||
const UCHAR* clumplet = getBuffer() + cur_offset;
|
||||
size_t length = getClumpLength();
|
||||
str.assign(reinterpret_cast<const char*>(clumplet + 2), length);
|
||||
return str;
|
||||
}
|
||||
|
||||
PathName& ClumpletReader::getPath(PathName& str)
|
||||
string& ClumpletReader::getString(string& str) const
|
||||
{
|
||||
const UCHAR* clumplet = getBuffer() + cur_offset;
|
||||
size_t length = getClumpLength();
|
||||
@ -199,11 +198,21 @@ PathName& ClumpletReader::getPath(PathName& str)
|
||||
return str;
|
||||
}
|
||||
|
||||
bool ClumpletReader::getBoolean()
|
||||
PathName& ClumpletReader::getPath(PathName& str) const
|
||||
{
|
||||
const UCHAR* clumplet = getBuffer() + cur_offset;
|
||||
size_t length = getClumpLength();
|
||||
str.assign(reinterpret_cast<const char*>(clumplet + 2), length);
|
||||
return str;
|
||||
}
|
||||
|
||||
bool ClumpletReader::getBoolean() const
|
||||
{
|
||||
const UCHAR* clumplet = getBuffer() + cur_offset;
|
||||
// CVC: Maybe we should assert here that length == 1?
|
||||
size_t length = getClumpLength();
|
||||
return length && clumplet[2];
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -42,24 +42,24 @@ public:
|
||||
ClumpletReader(bool isTagged, const UCHAR* buffer, size_t buffLen);
|
||||
|
||||
// Navigation in clumplet buffer
|
||||
bool isEof() { return cur_offset >= getBufferLength(); }
|
||||
bool isEof() const { return cur_offset >= getBufferLength(); }
|
||||
void moveNext();
|
||||
void rewind();
|
||||
bool find(UCHAR tag);
|
||||
|
||||
// Methods which work with currently selected clumplet
|
||||
UCHAR getClumpTag();
|
||||
size_t getClumpLength();
|
||||
UCHAR getClumpTag() const;
|
||||
size_t getClumpLength() const;
|
||||
|
||||
SLONG getInt();
|
||||
bool getBoolean();
|
||||
SINT64 getBigInt();
|
||||
string& getString(string& str);
|
||||
PathName& getPath(PathName& str);
|
||||
const UCHAR* getBytes() { return getBuffer() + cur_offset + 2; }
|
||||
SLONG getInt() const;
|
||||
bool getBoolean() const;
|
||||
SINT64 getBigInt() const;
|
||||
string& getString(string& str) const;
|
||||
PathName& getPath(PathName& str) const;
|
||||
const UCHAR* getBytes() const { return getBuffer() + cur_offset + 2; }
|
||||
|
||||
// Return the tag for buffer (usually structure version)
|
||||
UCHAR getBufferTag();
|
||||
UCHAR getBufferTag() const;
|
||||
size_t getBufferLength() const
|
||||
{
|
||||
size_t rc = getBufferEnd() - getBuffer();
|
||||
@ -84,10 +84,10 @@ protected:
|
||||
// sensible, certainly not overwrite memory or read past the end of buffer
|
||||
|
||||
// This appears to be a programming error in buffer access pattern
|
||||
virtual void usage_mistake(const char* what);
|
||||
virtual void usage_mistake(const char* what) const;
|
||||
|
||||
// This is called when passed buffer appears invalid
|
||||
virtual void invalid_structure();
|
||||
virtual void invalid_structure() const;
|
||||
private:
|
||||
// Assignment and copy constructor not implemented.
|
||||
ClumpletReader(const ClumpletReader& from);
|
||||
@ -99,4 +99,5 @@ private:
|
||||
|
||||
} // namespace Firebird
|
||||
|
||||
#endif
|
||||
#endif // CLUMPLETREADER_H
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user