8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 22:03:03 +01:00
This commit is contained in:
robocop 2008-07-16 11:15:00 +00:00
parent ee1fdf040a
commit 7182bbaa8b
20 changed files with 176 additions and 164 deletions

View File

@ -103,7 +103,7 @@ void ClumpletWriter::reset(UCHAR tag)
rewind();
}
void ClumpletWriter::reset(const UCHAR* buffer, size_t buffLen)
void ClumpletWriter::reset(const UCHAR* buffer, const size_t buffLen)
{
dynamic_buffer.clear();
if (buffer && buffLen) {
@ -121,7 +121,7 @@ void ClumpletWriter::size_overflow()
fatal_exception::raise("Clumplet buffer size limit reached");
}
void ClumpletWriter::toVaxInteger(UCHAR* ptr, size_t length, SINT64 value)
void ClumpletWriter::toVaxInteger(UCHAR* ptr, size_t length, const SINT64 value)
{
int shift = 0;
while (length--) {
@ -130,7 +130,7 @@ void ClumpletWriter::toVaxInteger(UCHAR* ptr, size_t length, SINT64 value)
}
}
void ClumpletWriter::insertInt(UCHAR tag, SLONG value)
void ClumpletWriter::insertInt(UCHAR tag, const SLONG value)
{
UCHAR bytes[sizeof(SLONG)];
@ -138,7 +138,7 @@ void ClumpletWriter::insertInt(UCHAR tag, SLONG value)
insertBytesLengthCheck(tag, bytes, sizeof(bytes));
}
void ClumpletWriter::insertBigInt(UCHAR tag, SINT64 value)
void ClumpletWriter::insertBigInt(UCHAR tag, const SINT64 value)
{
UCHAR bytes[sizeof(SINT64)];
@ -146,7 +146,7 @@ void ClumpletWriter::insertBigInt(UCHAR tag, SINT64 value)
insertBytesLengthCheck(tag, bytes, sizeof(bytes));
}
void ClumpletWriter::insertDouble(UCHAR tag, double value)
void ClumpletWriter::insertDouble(UCHAR tag, const double value)
{
union {
double temp_double;
@ -162,7 +162,7 @@ void ClumpletWriter::insertDouble(UCHAR tag, double value)
insertBytesLengthCheck(tag, bytes, sizeof(bytes));
}
void ClumpletWriter::insertTimeStamp(UCHAR tag, ISC_TIMESTAMP value)
void ClumpletWriter::insertTimeStamp(UCHAR tag, const ISC_TIMESTAMP value)
{
UCHAR bytes[sizeof(ISC_TIMESTAMP)];
toVaxInteger(bytes, sizeof(SLONG), value.timestamp_date);
@ -195,7 +195,7 @@ void ClumpletWriter::insertByte(UCHAR tag, const UCHAR byte)
insertBytesLengthCheck(tag, &byte, 1);
}
void ClumpletWriter::insertBytesLengthCheck(UCHAR tag, const UCHAR* bytes, size_t length)
void ClumpletWriter::insertBytesLengthCheck(UCHAR tag, const UCHAR* bytes, const size_t length)
{
// Check that we're not beyond the end of buffer.
// We get there when we set end marker.
@ -298,7 +298,7 @@ void ClumpletWriter::insertBytesLengthCheck(UCHAR tag, const UCHAR* bytes, size_
}
dynamic_buffer.insert(cur_offset, bytes, length);
cur_offset += length;
size_t new_offset = cur_offset;
const size_t new_offset = cur_offset;
cur_offset = saved_offset;
adjustSpbState();
cur_offset = new_offset;

View File

@ -52,19 +52,19 @@ public:
ClumpletWriter(MemoryPool& pool, Kind k, size_t limit, const UCHAR* buffer, size_t buffLen, UCHAR tag);
void reset(UCHAR tag);
void reset(const UCHAR* buffer, size_t buffLen);
void reset(const UCHAR* buffer, const size_t buffLen);
// Methods to create new clumplet at current position
void insertInt(UCHAR tag, SLONG value);
void insertBigInt(UCHAR tag, SINT64 value);
void insertInt(UCHAR tag, const SLONG value);
void insertBigInt(UCHAR tag, const SINT64 value);
void insertBytes(UCHAR tag, const UCHAR* bytes, size_t length);
void insertString(UCHAR tag, const string& str);
void insertPath(UCHAR tag, const PathName& str);
void insertString(UCHAR tag, const char* str, size_t length);
void insertByte(UCHAR tag, const UCHAR byte);
void insertTag(UCHAR tag);
void insertDouble(UCHAR tag, double value);
void insertTimeStamp(UCHAR tag, ISC_TIMESTAMP value);
void insertDouble(UCHAR tag, const double value);
void insertTimeStamp(UCHAR tag, const ISC_TIMESTAMP value);
void insertTime(UCHAR tag, ISC_TIME value) { insertInt(tag, value); }
void insertDate(UCHAR tag, ISC_DATE value) { insertInt(tag, value); }
void insertEndMarker(UCHAR tag);
@ -80,7 +80,7 @@ public:
protected:
virtual const UCHAR* getBufferEnd() const { return dynamic_buffer.end(); }
virtual void size_overflow();
void insertBytesLengthCheck(UCHAR tag, const UCHAR* bytes, size_t length);
void insertBytesLengthCheck(UCHAR tag, const UCHAR* bytes, const size_t length);
private:
size_t sizeLimit;
@ -91,7 +91,7 @@ private:
HalfStaticArray<UCHAR, 128> dynamic_buffer;
void initNewBuffer(UCHAR tag);
static void toVaxInteger(UCHAR* ptr, size_t length, SINT64 value);
static void toVaxInteger(UCHAR* ptr, size_t length, const SINT64 value);
};
} // namespace Firebird

View File

@ -112,7 +112,7 @@ namespace Firebird {
va_end(params);
}
char* MetaName::getBuffer(size_t l)
char* MetaName::getBuffer(const size_t l)
{
fb_assert (l < MAX_SQL_IDENTIFIER_SIZE);
init();

View File

@ -68,7 +68,7 @@ public:
MetaName& operator=(const char* s) { return assign(s); }
MetaName& operator=(const string& s) { return assign(s.c_str(), s.length()); }
MetaName& operator=(const MetaName& m) { return set(m); }
char* getBuffer(size_t l);
char* getBuffer(const size_t l);
size_t length() const { return count; }
const char* c_str() const { return data; }

View File

@ -230,10 +230,11 @@ TempFile::~TempFile()
// Performs a positioning operation
//
void TempFile::seek(offset_t offset)
void TempFile::seek(const offset_t offset)
{
if (position == offset)
return;
#if defined(WIN_NT)
LARGE_INTEGER liOffset;
liOffset.QuadPart = offset;

View File

@ -70,7 +70,7 @@ public:
private:
void init(const Firebird::PathName&, const Firebird::PathName&);
void seek(offset_t);
void seek(const offset_t);
#if defined(WIN_NT)
HANDLE handle;

View File

@ -89,14 +89,14 @@ namespace Firebird {
memcpy(stringBuffer, v.c_str(), v.length());
}
AbstractString::AbstractString(size_type sizeL, const_pointer dataL)
AbstractString::AbstractString(const size_type sizeL, const_pointer dataL)
{
initialize(sizeL);
memcpy(stringBuffer, dataL, sizeL);
}
AbstractString::AbstractString(const_pointer p1, size_type n1,
const_pointer p2, size_type n2)
AbstractString::AbstractString(const_pointer p1, const size_type n1,
const_pointer p2, const size_type n2)
{
// CVC: npos must be maximum size_type value for all platforms.
// fb_assert(n2 < npos - n1 && n1 + n2 <= max_length());
@ -110,13 +110,13 @@ namespace Firebird {
memcpy(stringBuffer + n1, p2, n2);
}
AbstractString::AbstractString(size_type sizeL, char_type c)
AbstractString::AbstractString(const size_type sizeL, char_type c)
{
initialize(sizeL);
memset(stringBuffer, c, sizeL);
}
void AbstractString::AdjustRange(size_type length, size_type& pos, size_type& n)
void AbstractString::adjustRange(const size_type length, size_type& pos, size_type& n)
{
if (pos == npos) {
pos = length > n ? length - n : 0;
@ -130,7 +130,7 @@ namespace Firebird {
}
}
AbstractString::pointer AbstractString::baseAssign(size_type n)
AbstractString::pointer AbstractString::baseAssign(const size_type n)
{
reserveBuffer(n);
stringLength = n;
@ -139,7 +139,7 @@ namespace Firebird {
return stringBuffer;
}
AbstractString::pointer AbstractString::baseAppend(size_type n)
AbstractString::pointer AbstractString::baseAppend(const size_type n)
{
reserveBuffer(stringLength + n);
stringLength += n;
@ -147,7 +147,7 @@ namespace Firebird {
return stringBuffer + stringLength - n;
}
AbstractString::pointer AbstractString::baseInsert(size_type p0, size_type n)
AbstractString::pointer AbstractString::baseInsert(const size_type p0, const size_type n)
{
if (p0 >= length()) {
return baseAppend(n);
@ -161,7 +161,7 @@ namespace Firebird {
void AbstractString::baseErase(size_type p0, size_type n)
{
AdjustRange(length(), p0, n);
adjustRange(length(), p0, n);
memmove(stringBuffer + p0,
stringBuffer + p0 + n, stringLength - (p0 + n) + 1);
stringLength -= n;
@ -177,7 +177,7 @@ namespace Firebird {
reserveBuffer(n);
}
void AbstractString::resize(size_type n, char_type c)
void AbstractString::resize(const size_type n, char_type c)
{
if (n == length()) {
return;
@ -191,7 +191,7 @@ namespace Firebird {
shrinkBuffer();
}
AbstractString::size_type AbstractString::rfind(const_pointer s, size_type pos) const
AbstractString::size_type AbstractString::rfind(const_pointer s, const size_type pos) const
{
const size_type l = strlen(s);
int lastpos = length() - l;
@ -211,7 +211,7 @@ namespace Firebird {
return npos;
}
AbstractString::size_type AbstractString::rfind(char_type c, size_type pos) const
AbstractString::size_type AbstractString::rfind(char_type c, const size_type pos) const
{
int lastpos = length() - 1;
if (lastpos < 0) {
@ -243,7 +243,7 @@ namespace Firebird {
return npos;
}
AbstractString::size_type AbstractString::find_last_of(const_pointer s, size_type pos, size_type n) const
AbstractString::size_type AbstractString::find_last_of(const_pointer s, const size_type pos, size_type n) const
{
const strBitMask sm(s, n);
int lpos = length() - 1;
@ -273,7 +273,7 @@ namespace Firebird {
return npos;
}
AbstractString::size_type AbstractString::find_last_not_of(const_pointer s, size_type pos, size_type n) const
AbstractString::size_type AbstractString::find_last_not_of(const_pointer s, const size_type pos, size_type n) const
{
const strBitMask sm(s, n);
int lpos = length() - 1;
@ -290,11 +290,12 @@ namespace Firebird {
return npos;
}
bool AbstractString::LoadFromFile(FILE *file)
bool AbstractString::LoadFromFile(FILE* file)
{
baseErase(0, length());
if (! file)
return false;
bool rc = false;
int c;
while ((c = getc(file)) != EOF) {
@ -320,9 +321,9 @@ extern "C" {
void AbstractString::upper()
{
#ifdef WIN_NT
CharUpperBuffA(Modify(), length());
CharUpperBuffA(modify(), length());
#else // WIN_NT
for (pointer p = Modify(); *p; p++) {
for (pointer p = modify(); *p; p++) {
*p = toupper(*p);
}
#endif // WIN_NT
@ -331,9 +332,9 @@ extern "C" {
void AbstractString::lower()
{
#ifdef WIN_NT
CharLowerBuffA(Modify(), length());
CharLowerBuffA(modify(), length());
#else // WIN_NT
for (pointer p = Modify(); *p; p++) {
for (pointer p = modify(); *p; p++) {
*p = tolower(*p);
}
#endif // WIN_NT
@ -436,7 +437,7 @@ extern "C" {
}
}
unsigned int AbstractString::hash(const_pointer string, size_t tableSize)
unsigned int AbstractString::hash(const_pointer string, const size_t tableSize)
{
unsigned int value = 0;
unsigned char c;
@ -450,10 +451,12 @@ extern "C" {
return value % tableSize;
}
int PathNameComparator::compare(AbstractString::const_pointer s1, AbstractString::const_pointer s2, AbstractString::size_type n)
int PathNameComparator::compare(AbstractString::const_pointer s1, AbstractString::const_pointer s2,
const AbstractString::size_type n)
{
if (CASE_SENSITIVITY)
return memcmp(s1, s2, n);
return STRNCASECMP(s1, s2, n);
}

View File

@ -79,7 +79,7 @@ namespace Firebird
// Reserve buffer to allow storing at least newLen characters there
// (not including null terminator). Existing contents of our string are preserved.
void reserveBuffer(size_type newLen)
void reserveBuffer(const size_type newLen)
{
size_type newSize = newLen + 1;
if (newSize > bufferSize) {
@ -114,7 +114,7 @@ namespace Firebird
// Make sure our buffer is large enough to store at least <length> characters in it
// (not including null terminator). Resulting buffer is not initialized.
// Use it in constructors only when stringBuffer is not assigned yet.
void initialize(size_type len)
void initialize(const size_type len)
{
if (len < INLINE_BUFFER_SIZE) {
stringBuffer = inlineBuffer;
@ -145,10 +145,10 @@ namespace Firebird
}
protected:
AbstractString(size_type sizeL, const_pointer datap);
AbstractString(const size_type sizeL, const_pointer datap);
AbstractString(const_pointer p1, size_type n1,
const_pointer p2, size_type n2);
AbstractString(const_pointer p1, const size_type n1,
const_pointer p2, const size_type n2);
AbstractString(const AbstractString& v);
@ -158,7 +158,7 @@ namespace Firebird
stringBuffer[0] = 0;
}
AbstractString(size_type sizeL, char_type c);
AbstractString(const size_type sizeL, char_type c);
inline explicit AbstractString(MemoryPool& p) : AutoStorage(p),
stringBuffer(inlineBuffer), stringLength(0), bufferSize(INLINE_BUFFER_SIZE)
@ -173,26 +173,26 @@ namespace Firebird
memcpy(stringBuffer, v.c_str(), stringLength);
}
inline AbstractString(MemoryPool& p, const char_type* s, size_type l)
inline AbstractString(MemoryPool& p, const char_type* s, const size_type l)
: AutoStorage(p)
{
initialize(l);
memcpy(stringBuffer, s, l);
}
pointer Modify(void)
pointer modify()
{
return stringBuffer;
}
// Trim the range making sure that it fits inside specified length
static void AdjustRange(size_type length, size_type& pos, size_type& n);
static void adjustRange(const size_type length, size_type& pos, size_type& n);
pointer baseAssign(size_type n);
pointer baseAssign(const size_type n);
pointer baseAppend(size_type n);
pointer baseAppend(const size_type n);
pointer baseInsert(size_type p0, size_type n);
pointer baseInsert(const size_type p0, size_type n);
void baseErase(size_type p0, size_type n);
@ -225,7 +225,7 @@ namespace Firebird
}
void reserve(size_type n = 0);
void resize(size_type n, char_type c = ' ');
void resize(const size_type n, char_type c = ' ');
inline pointer getBuffer(size_t l)
{
@ -257,8 +257,8 @@ namespace Firebird
{
return rfind(str.c_str(), pos);
}
size_type rfind(const_pointer s, size_type pos = npos) const;
size_type rfind(char_type c, size_type pos = npos) const;
size_type rfind(const_pointer s, const size_type pos = npos) const;
size_type rfind(char_type c, const size_type pos = npos) const;
inline size_type find_first_of(const AbstractString& str, size_type pos = 0) const
{
return find_first_of(str.c_str(), pos, str.length());
@ -276,7 +276,7 @@ namespace Firebird
{
return find_last_of(str.c_str(), pos, str.length());
}
size_type find_last_of(const_pointer s, size_type pos, size_type n = npos) const;
size_type find_last_of(const_pointer s, const size_type pos, size_type n = npos) const;
inline size_type find_last_of(const_pointer s, size_type pos = npos) const
{
return find_last_of(s, pos, strlen(s));
@ -296,27 +296,27 @@ namespace Firebird
}
inline size_type find_first_not_of(char_type c, size_type pos = 0) const
{
const char s[2] = {c, 0};
const char_type s[2] = {c, 0};
return find_first_not_of(s, pos, 1);
}
inline size_type find_last_not_of(const AbstractString& str, size_type pos = npos) const
{
return find_last_not_of(str.c_str(), pos, str.length());
}
size_type find_last_not_of(const_pointer s, size_type pos, size_type n = npos) const;
size_type find_last_not_of(const_pointer s, const size_type pos, size_type n = npos) const;
inline size_type find_last_not_of(const_pointer s, size_type pos = npos) const
{
return find_last_not_of(s, pos, strlen(s));
}
inline size_type find_last_not_of(char_type c, size_type pos = npos) const
{
const char s[2] = {c, 0};
const char_type s[2] = {c, 0};
return find_last_not_of(s, pos, 1);
}
inline iterator begin()
{
return Modify();
return modify();
}
inline const_iterator begin() const
{
@ -324,21 +324,21 @@ namespace Firebird
}
inline iterator end()
{
return Modify() + length();
return modify() + length();
}
inline const_iterator end() const
{
return c_str() + length();
}
inline const_reference at(size_type pos) const
inline const_reference at(const size_type pos) const
{
checkPos(pos);
return c_str()[pos];
}
inline reference at(size_type pos)
inline reference at(const size_type pos)
{
checkPos(pos);
return Modify()[pos];
return modify()[pos];
}
inline const_reference operator[](size_type pos) const
{
@ -397,7 +397,7 @@ namespace Firebird
baseTrim(TrimBoth, ToTrim);
}
bool LoadFromFile(FILE *file);
bool LoadFromFile(FILE* file);
void vprintf(const char* Format, va_list params);
void printf(const char* Format, ...);
@ -414,7 +414,7 @@ namespace Firebird
return toSize;
}
static unsigned int hash(const_pointer string, size_type tableSize);
static unsigned int hash(const_pointer string, const size_type tableSize);
inline unsigned int hash(size_type tableSize) const
{
@ -478,10 +478,10 @@ namespace Firebird
inline StringType& append(const StringType& str, size_type pos, size_type n)
{
fb_assert(&str != this);
AdjustRange(str.length(), pos, n);
adjustRange(str.length(), pos, n);
return append(str.c_str() + pos, n);
}
inline StringType& append(const_pointer s, size_type n)
inline StringType& append(const_pointer s, const size_type n)
{
memcpy(baseAppend(n), s, n);
return *this;
@ -508,7 +508,7 @@ namespace Firebird
inline StringType& assign(const StringType& str, size_type pos, size_type n)
{
fb_assert(&str != this);
AdjustRange(str.length(), pos, n);
adjustRange(str.length(), pos, n);
return assign(&str.c_str()[pos], n);
}
inline StringType& assign(const_pointer s, size_type n)
@ -587,10 +587,10 @@ namespace Firebird
inline StringType& insert(size_type p0, const StringType& str, size_type pos, size_type n)
{
fb_assert(&str != this);
AdjustRange(str.length(), pos, n);
adjustRange(str.length(), pos, n);
return insert(p0, &str.c_str()[pos], n);
}
inline StringType& insert(size_type p0, const_pointer s, size_type n)
inline StringType& insert(size_type p0, const_pointer s, const size_type n)
{
if (p0 >= length()) {
return append(s, n);
@ -602,7 +602,7 @@ namespace Firebird
{
return insert(p0, s, strlen(s));
}
inline StringType& insert(size_type p0, size_type n, char_type c)
inline StringType& insert(size_type p0, const size_type n, const char_type c)
{
if (p0 >= length()) {
return append(n, c);
@ -641,13 +641,14 @@ namespace Firebird
fb_assert(&str != this);
return replace(p0, n0, str.c_str(), str.length());
}
inline StringType& replace(size_type p0, size_type n0, const StringType& str, size_type pos, size_type n)
inline StringType& replace(const size_type p0, const size_type n0, const StringType& str,
size_type pos, size_type n)
{
fb_assert(&str != this);
AdjustRange(str.length(), pos, n);
adjustRange(str.length(), pos, n);
return replace(p0, n0, &str.c_str()[pos], n);
}
inline StringType& replace(size_type p0, size_type n0, const_pointer s, size_type n)
inline StringType& replace(const size_type p0, const size_type n0, const_pointer s, size_type n)
{
erase(p0, n0);
return insert(p0, s, n);
@ -656,7 +657,7 @@ namespace Firebird
{
return replace(p0, n0, s, strlen(s));
}
inline StringType& replace(size_type p0, size_type n0, size_type n, char_type c)
inline StringType& replace(const size_type p0, const size_type n0, size_type n, char_type c)
{
erase(p0, n0);
return insert(p0, n, c);
@ -685,7 +686,7 @@ namespace Firebird
inline StringType substr(size_type pos = 0, size_type n = npos) const
{
AdjustRange(length(), pos, n);
adjustRange(length(), pos, n);
return StringType(&c_str()[pos], n);
}
inline int compare(const StringType& str) const
@ -698,21 +699,21 @@ namespace Firebird
}
inline int compare(size_type p0, size_type n0, const StringType& str, size_type pos, size_type n)
{
AdjustRange(str.length(), pos, n);
adjustRange(str.length(), pos, n);
return compare(p0, n0, &str.c_str()[pos], n);
}
inline int compare(const_pointer s) const
{
return compare(s, strlen(s));
}
int compare(size_type p0, size_type n0, const_pointer s, size_type n) const
int compare(size_type p0, size_type n0, const_pointer s, const size_type n) const
{
AdjustRange(length(), p0, n0);
adjustRange(length(), p0, n0);
const size_type ml = n0 < n ? n0 : n;
const int rc = Comparator::compare(&c_str()[p0], s, ml);
return rc ? rc : n0 - n;
}
int compare(const_pointer s, size_type n) const
int compare(const_pointer s, const size_type n) const
{
const size_type ml = length() < n ? length() : n;
const int rc = Comparator::compare(c_str(), s, ml);

View File

@ -63,7 +63,7 @@ public:
system_call_failed::raise("CloseHandle");
}
bool tryEnter(int seconds = 0, int milliseconds = 0)
bool tryEnter(const int seconds = 0, int milliseconds = 0)
{
milliseconds += seconds * 1000;
DWORD result = WaitForSingleObject(
@ -185,7 +185,7 @@ public:
#ifdef HAVE_SEM_TIMEDWAIT
// In case when sem_timedwait() is implemented by host OS,
// class SignalSafeSemaphore may have this function:
bool tryEnter(int seconds = 0, int milliseconds = 0)
bool tryEnter(const int seconds = 0, int milliseconds = 0)
{
milliseconds += seconds * 1000;
// Return true in case of success
@ -287,7 +287,7 @@ public:
system_call_failed::raise("semaphore.h: ~Semaphore: semctl()");
}
bool tryEnter(int seconds = 0, int milliseconds = 0) // Returns true in case of success
bool tryEnter(const int seconds = 0, int milliseconds = 0) // Returns true in case of success
{
milliseconds += seconds * 1000;
timespec timeout;
@ -400,7 +400,7 @@ public:
}
}
bool tryEnter(int seconds = 0, int milliseconds = 0)
bool tryEnter(const int seconds = 0, int milliseconds = 0)
{
bool rt = false;
// Return true in case of success

View File

@ -396,7 +396,8 @@ public:
return true;
}
if (!treeAccessor.getFirst()) return false;
if (!treeAccessor.getFirst())
return false;
BUNCH_T tree_bits = treeAccessor.current().bits;
bit_mask = BUNCH_ONE;

View File

@ -240,7 +240,7 @@ void TimeStamp::decode_timestamp(const ISC_TIMESTAMP ts, struct tm* times, int*
decode_time(ts.timestamp_time, &times->tm_hour, &times->tm_min, &times->tm_sec, fractions);
}
ISC_TIMESTAMP TimeStamp::encode_timestamp(const struct tm* times, int fractions)
ISC_TIMESTAMP TimeStamp::encode_timestamp(const struct tm* times, const int fractions)
{
fb_assert(fractions >= 0 && fractions < ISC_TIME_SECONDS_PRECISION);
@ -251,13 +251,14 @@ ISC_TIMESTAMP TimeStamp::encode_timestamp(const struct tm* times, int fractions)
return ts;
}
void TimeStamp::round_time(ISC_TIME &ntime, int precision)
void TimeStamp::round_time(ISC_TIME &ntime, const int precision)
{
const int scale = -ISC_TIME_SECONDS_PRECISION_SCALE - precision;
// for the moment, if greater precision was requested than we can
// provide return what we have.
if (scale <= 0) return;
if (scale <= 0)
return;
static const ISC_TIME pow10table[] =
{1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};

View File

@ -144,13 +144,13 @@ public:
// ISC date/time helper routines
static ISC_DATE encode_date(const struct tm* times);
static ISC_TIME encode_time(int hours, int minutes, int seconds, int fractions = 0);
static ISC_TIMESTAMP encode_timestamp(const struct tm* times, int fractions = 0);
static ISC_TIMESTAMP encode_timestamp(const struct tm* times, const int fractions = 0);
static void decode_date(ISC_DATE nday, struct tm* times);
static void decode_time(ISC_TIME ntime, int* hours, int* minutes, int* seconds, int* fractions = NULL);
static void decode_timestamp(const ISC_TIMESTAMP ntimestamp, struct tm* times, int* fractions = NULL);
static void round_time(ISC_TIME& ntime, int precision);
static void round_time(ISC_TIME& ntime, const int precision);
static inline bool isLeapYear(const int year)
{

View File

@ -353,7 +353,7 @@ public:
// add ItemList typedef for you compiler with whichever syntax it likes
return KeyOfValue::generate(item, *((ItemList *)item)->begin());
}
static void setNodeParentAndLevel(void* node, int level, NodeList* parent)
static void setNodeParentAndLevel(void* node, const int level, NodeList* parent)
{
if (level) {
((NodeList *)node)->parent = parent;
@ -362,7 +362,7 @@ public:
else
((ItemList *)node)->parent = parent;
}
static void setNodeParent(void* node, int level, NodeList* parent)
static void setNodeParent(void* node, const int level, NodeList* parent)
{
if (level)
((NodeList*) node)->parent = parent;
@ -460,7 +460,7 @@ public:
// Position accessor on item having LocType relationship with given key
// If method returns false position of accessor is not defined.
bool locate(LocType lt, const Key& key)
bool locate(const LocType lt, const Key& key)
{
// Inlining is efficient here because LocType will be known in most cases
// and compiler will be able to eliminate most of code
@ -481,7 +481,8 @@ public:
curr = (ItemList *)list;
const bool found = curr->find(key, curPos);
switch (lt) {
case locEqual: return found;
case locEqual:
return found;
case locGreatEqual:
if (curPos == curr->getCount()) {
curr = curr->next;
@ -836,7 +837,7 @@ bool BePlusTree<Value, Key, Allocator, KeyOfValue, Cmp, LeafCount, NodeCount>::a
}
template <typename Value, typename Key, typename Allocator, typename KeyOfValue, typename Cmp, int LeafCount, int NodeCount>
void BePlusTree<Value, Key, Allocator, KeyOfValue, Cmp, LeafCount, NodeCount>::_removePage(int nodeLevel, void *node)
void BePlusTree<Value, Key, Allocator, KeyOfValue, Cmp, LeafCount, NodeCount>::_removePage(const int nodeLevel, void *node)
{
NodeList *list;
// Get parent and adjust the links

View File

@ -6014,7 +6014,8 @@ static bool pass1_found_sub_select(const dsql_nod* node)
{
DEV_BLKCHK(node, dsql_type_nod);
if (node == NULL) return false;
if (node == NULL)
return false;
switch (node->nod_type)
{

View File

@ -542,8 +542,8 @@ static DUDLEY_CTX lookup_context( SYM symbol, dudley_lls* contexts)
for (; contexts; contexts = contexts->lls_next) {
context = (DUDLEY_CTX) contexts->lls_object;
if ((name = context->ctx_name) &&
!strcmp(name->sym_string, symbol->sym_string)) return context;
if ((name = context->ctx_name) && !strcmp(name->sym_string, symbol->sym_string))
return context;
}
return NULL;
@ -609,9 +609,8 @@ static DUDLEY_FLD lookup_global_field( DUDLEY_FLD field)
/* Find symbol */
name = (field->fld_source) ? field->fld_source : field->fld_name;
if (symbol =
HSH_typed_lookup(name->sym_string, name->sym_length,
SYM_global)) return (DUDLEY_FLD) symbol->sym_object;
if (symbol = HSH_typed_lookup(name->sym_string, name->sym_length, SYM_global))
return (DUDLEY_FLD) symbol->sym_object;
expand_error(103, SafeArg() << name->sym_string); /* msg 103: global field %s isn't defined */
@ -636,9 +635,11 @@ static DUDLEY_REL lookup_relation( DUDLEY_REL relation)
name = (relation->rel_name);
if (
(symbol =
HSH_typed_lookup(name->sym_string, name->sym_length, SYM_relation))
&& symbol->sym_object) return (DUDLEY_REL) symbol->sym_object;
(symbol = HSH_typed_lookup(name->sym_string, name->sym_length, SYM_relation))
&& symbol->sym_object)
{
return (DUDLEY_REL) symbol->sym_object;
}
expand_error(104, SafeArg() << name->sym_string); /* msg 104: relation %s isn't defined */
@ -662,9 +663,8 @@ static DUDLEY_TRG lookup_trigger( DUDLEY_TRG trigger)
/* Find symbol */
name = (trigger->trg_name);
if (symbol =
HSH_typed_lookup(name->sym_string, name->sym_length,
SYM_trigger)) return (DUDLEY_TRG) symbol->sym_object;
if (symbol = HSH_typed_lookup(name->sym_string, name->sym_length, SYM_trigger))
return (DUDLEY_TRG) symbol->sym_object;
expand_error(105, SafeArg() << name->sym_string); /* msg 105: trigger %s isn't defined */

View File

@ -300,12 +300,9 @@ void HSH_insert( SYM symbol)
* Insert a symbol into the hash table.
*
**************************************/
USHORT h;
SYM old;
const USHORT h = hash(symbol->sym_string, symbol->sym_length);
h = hash(symbol->sym_string, symbol->sym_length);
for (old = hash_table[h]; old; old = old->sym_collision)
for (SYM old = hash_table[h]; old; old = old->sym_collision)
if (scompare(symbol->sym_string, symbol->sym_length,
old->sym_string, old->sym_length))
{
@ -331,13 +328,11 @@ SYM HSH_lookup(const SCHAR* string, USHORT length)
* Perform a string lookup against hash table.
*
**************************************/
SYM symbol;
for (symbol = hash_table[hash(string, length)]; symbol;
symbol = symbol->sym_collision)
if (scompare
(string, length, symbol->sym_string,
symbol->sym_length)) return symbol;
for (SYM symbol = hash_table[hash(string, length)]; symbol; symbol = symbol->sym_collision)
{
if (scompare(string, length, symbol->sym_string, symbol->sym_length))
return symbol;
}
return NULL;
}

View File

@ -34,34 +34,41 @@
/* Data type information */
inline bool DTYPE_IS_TEXT(UCHAR d) {
inline bool DTYPE_IS_TEXT(UCHAR d)
{
return ((d >= dtype_text) && (d <= dtype_varying));
}
inline bool DTYPE_IS_DATE(UCHAR t) {
inline bool DTYPE_IS_DATE(UCHAR t)
{
return ((t >= dtype_sql_date) && (t <= dtype_timestamp));
}
/* DTYPE_IS_BLOB includes both BLOB and ARRAY since array's are implemented over blobs. */
inline bool DTYPE_IS_BLOB(UCHAR d) {
inline bool DTYPE_IS_BLOB(UCHAR d)
{
return ((d == dtype_blob) || (d == dtype_array));
}
/* DTYPE_IS_BLOB_OR_QUAD includes both BLOB, QUAD and ARRAY since array's are implemented over blobs. */
inline bool DTYPE_IS_BLOB_OR_QUAD(UCHAR d) {
inline bool DTYPE_IS_BLOB_OR_QUAD(UCHAR d)
{
return ((d == dtype_blob) || (d == dtype_quad) || (d == dtype_array));
}
/* Exact numeric? */
inline bool DTYPE_IS_EXACT(UCHAR d) {
inline bool DTYPE_IS_EXACT(UCHAR d)
{
return ((d == dtype_int64) || (d == dtype_long) || (d == dtype_short));
}
inline bool DTYPE_IS_APPROX(UCHAR d) {
inline bool DTYPE_IS_APPROX(UCHAR d)
{
return ((d == dtype_double) || (d == dtype_real));
}
inline bool DTYPE_IS_NUMERIC(UCHAR d) {
inline bool DTYPE_IS_NUMERIC(UCHAR d)
{
return (((d >= dtype_byte) && (d <= dtype_d_float)) || (d == dtype_int64));
}
@ -137,7 +144,7 @@ typedef struct dsc
{
if (isBlob())
return dsc_sub_type;
else
return isc_blob_text;
}
@ -151,14 +158,15 @@ typedef struct dsc
{
if (isText())
return dsc_sub_type & 0xFF;
else if (isBlob())
if (isBlob())
{
if (dsc_sub_type == isc_blob_text)
return dsc_scale;
else
return CS_BINARY;
}
else
return CS_ASCII;
}
@ -166,14 +174,15 @@ typedef struct dsc
{
if (isText())
return dsc_sub_type;
else if (isBlob())
if (isBlob())
{
if (dsc_sub_type == isc_blob_text)
return dsc_scale | (dsc_flags & 0xFF00);
else
return CS_BINARY;
}
else
return CS_ASCII;
}
@ -289,7 +298,8 @@ typedef struct dsc
dsc_flags(od.dsc_flags),
dsc_address((UCHAR*)(IPTR)(od.dsc_offset))
{}
operator Ods::Descriptor() const {
operator Ods::Descriptor() const
{
#ifdef DEV_BUILD
address32bit();
#endif
@ -308,15 +318,18 @@ typedef struct dsc
} DSC;
inline SSHORT DSC_GET_CHARSET(const dsc* desc) {
inline SSHORT DSC_GET_CHARSET(const dsc* desc)
{
return (desc->dsc_sub_type & 0x00FF);
}
inline SSHORT DSC_GET_COLLATE(const dsc* desc) {
inline SSHORT DSC_GET_COLLATE(const dsc* desc)
{
return (desc->dsc_sub_type >> 8);
}
typedef struct alt_dsc {
typedef struct alt_dsc
{
SLONG dsc_combined_type;
SSHORT dsc_sub_type;
USHORT dsc_flags; /* Not currently used */
@ -356,7 +369,8 @@ const UCHAR dtype_max_comp = dtype_d_float;
/* NOTE: For types <= dtype_any_text the dsc_sub_type field defines
the text type */
inline USHORT TEXT_LEN(const dsc* desc) {
inline USHORT TEXT_LEN(const dsc* desc)
{
return ((desc->dsc_dtype == dtype_text) ? desc->dsc_length
: (desc->dsc_dtype == dtype_cstring) ? desc->dsc_length - 1 : desc->dsc_length - sizeof(USHORT));
}
@ -379,7 +393,8 @@ const SSHORT dsc_num_type_decimal = 2; /* defined as DECIMAL(n,m) */
/* Date type information */
inline SCHAR NUMERIC_SCALE(const dsc desc) {
inline SCHAR NUMERIC_SCALE(const dsc desc)
{
return ((DTYPE_IS_TEXT(desc.dsc_dtype)) ? 0 : desc.dsc_scale);
}

View File

@ -96,8 +96,7 @@ public:
// Notify provider when some jrd attachment is about to be released
virtual void jrdAttachmentEnd(Jrd::thread_db *tdbb, Jrd::Attachment* att) = 0;
const Firebird::string& getName() const
{ return m_name; }
const Firebird::string& getName() const { return m_name; }
virtual void initialize() = 0;

View File

@ -70,16 +70,14 @@ public:
virtual bool isAvailable(Jrd::thread_db *tdbb, TraScope traScope) const;
virtual bool isConnected() const
{ return (m_attachment != 0); }
virtual bool isConnected() const { return (m_attachment != 0); }
virtual bool isSameDatabase(Jrd::thread_db *tdbb, const Firebird::string &dbName,
const Firebird::string &user, const Firebird::string &pwd) const;
bool isCurrent() const { return m_isCurrent; }
Jrd::Attachment* getJrdAtt()
{ return m_attachment; }
Jrd::Attachment* getJrdAtt() { return m_attachment; }
virtual Blob* createBlob();
@ -106,8 +104,7 @@ protected:
virtual ~InternalTransaction() {}
public:
Jrd::jrd_tra* getJrdTran()
{ return m_transaction; }
Jrd::jrd_tra* getJrdTran() { return m_transaction; }
protected:
virtual void doStart(ISC_STATUS* status, Jrd::thread_db *tdbb, Firebird::ClumpletWriter &tpb);
@ -139,7 +136,9 @@ protected:
virtual void getExtBlob(Jrd::thread_db *tdbb, const dsc &src, dsc &dst);
InternalTransaction* getIntTransaction()
{ return (InternalTransaction*) m_transaction; }
{
return (InternalTransaction*) m_transaction;
}
InternalConnection& m_intConnection;
InternalTransaction* m_intTransaction;

View File

@ -504,8 +504,7 @@ protected:
virtual ~IscConnection();
public:
FB_API_HANDLE& getAPIHandle()
{ return m_handle; }
FB_API_HANDLE& getAPIHandle() { return m_handle; }
virtual void attach(Jrd::thread_db *tdbb, const Firebird::string &dbName,
const Firebird::string &user, const Firebird::string &pwd);
@ -513,8 +512,7 @@ public:
virtual bool isAvailable(Jrd::thread_db *tdbb, TraScope traScope) const;
virtual bool isConnected() const
{ return (m_handle != 0); }
virtual bool isConnected() const { return (m_handle != 0); }
virtual Blob* createBlob();
@ -532,8 +530,7 @@ class IscTransaction : public Transaction
friend class IscConnection;
public:
FB_API_HANDLE& getAPIHandle()
{ return m_handle; }
FB_API_HANDLE& getAPIHandle() { return m_handle; }
protected:
explicit IscTransaction(IscConnection &conn) :
@ -561,8 +558,7 @@ class IscStatement : public Statement
friend class IscConnection;
public:
FB_API_HANDLE& getAPIHandle()
{ return m_handle; }
FB_API_HANDLE& getAPIHandle() { return m_handle; }
protected:
explicit IscStatement(IscConnection &conn);
@ -578,8 +574,7 @@ protected:
virtual void doSetInParams(Jrd::thread_db *tdbb, int count, const Firebird::string *const *names,
Jrd::jrd_nod **params);
IscTransaction *getIscTransaction()
{ return (IscTransaction*) m_transaction; }
IscTransaction *getIscTransaction() { return (IscTransaction*) m_transaction; }
IscProvider &m_iscProvider;
IscConnection &m_iscConnection;