buf[size() * 2] = '\0';
s = buf;
delete buf;
return s;
}
void BBufferStore::setHexString(BString s){
int n;
char* p;
setSize(s.len() / 2);
p = odata;
for(n = 0; n < s.len(); n += 2){
*p = ((s[n] > '9' ? s[n] - '7' : s[n] - '0') & 0x0F) << 4;
*p |= (s[n+1] > '9' ? s[n+1] - '7' : s[n+1] - '0') & 0x0F;
p++;
}
opos = 0;
}
int BBufferStore::push(BInt8 v){
setSize(opos + sizeof(v));
bswap_copy(oswapBytes, &v, &odata[opos], sizeof(v), "1");
opos += sizeof(v);
return 0;
}
int BBufferStore::push(BUInt8 v){
setSize(opos + sizeof(v));
bswap_copy(oswapBytes, &v, &odata[opos], sizeof(v), "1");
opos += sizeof(v);
return 0;
}
int BBufferStore::push(BInt16 v){
setSize(opos + sizeof(v));
bswap_copy(oswapBytes, &v, &odata[opos], sizeof(v), "2");
opos += sizeof(v);
return 0;
}
int BBufferStore::push(BUInt16 v){
setSize(opos + sizeof(v));
bswap_copy(oswapBytes, &v, &odata[opos], sizeof(v), "2");
opos += sizeof(v);
return 0;
}
int BBufferStore::push(BInt32 v){
setSize(opos + sizeof(v));
bswap_copy(oswapBytes, &v, &odata[opos], sizeof(v), "4");
opos += sizeof(v);
return 0;
}
int BBufferStore::push(BUInt32 v){
setSize(opos + sizeof(v));
bswap_copy(oswapBytes, &v, &odata[opos], sizeof(v), "4");
opos += sizeof(v);
return 0;
}
int BBufferStore::push(BInt64 v){
setSize(opos + sizeof(v));
bswap_copy(oswapBytes, &v, &odata[opos], sizeof(v), "8");
opos += sizeof(v);
return 0;
}
int BBufferStore::push(BUInt64 v){
setSize(opos + sizeof(v));
bswap_copy(oswapBytes, &v, &odata[opos], sizeof(v), "8");
opos += sizeof(v);
return 0;
}
int BBufferStore::push(BFloat32 v){
setSize(opos + sizeof(v));
bswap_copy(oswapBytes, &v, &odata[opos], sizeof(v), "4");
opos += sizeof(v);
return 0;
}
int BBufferStore::push(BFloat64 v){
setSize(opos + sizeof(v));
bswap_copy(oswapBytes, &v, &odata[opos], sizeof(v), "8");
opos += sizeof(v);
return 0;
}
int BBufferStore::push(const BString& v){
BInt32 l = v.len() + 1;
setSize(opos + sizeof(l) + l);
bswap_copy(oswapBytes, &l, &odata[opos], sizeof(l), "4");
opos += sizeof(l);
bswap_copy(oswapBytes, v.retStr(), &odata[opos], l, "1");
opos += l;
return 0;
}
int BBufferStore::push(const BError& v){
BInt32 n = v.getErrorNo();
BString s = v.getString();
push(n);
push(s);
return 0;
}
int BBufferStore::push(const BTimeStamp& v){
push(v.oyear);
push(v.oyday);
push(v.ohour);
push(v.ominute);
push(v.osecond);
push(v.omicroSecond);
return 0;
}
int BBufferStore::push(const BComplex& v){
push(v.real());
push(v.imag());
return 0;
}
int BBufferStore::push(BUInt32 nBytes, const void* data, const char* swapType){
setSize(opos + nBytes);
bswap_copy(oswapBytes, data, &odata[opos], nBytes, swapType);
opos += nBytes;
return 0;
}
int BBufferStore::pop(BInt8& v){
if((osize - opos) < sizeof(v))
return 1;
bswap_copy(oswapBytes, &odata[opos], &v, sizeof(v), "1");
opos += sizeof(v);
return 0;
}
int BBufferStore::pop(BUInt8& v){
if((osize - opos) < sizeof(v))
return 1;
bswap_copy(oswapBytes, &odata[opos], &v, sizeof(v), "1");
opos += sizeof(v);
return 0;
}
int BBufferStore::pop(BInt16& v){
if((osize - opos) < sizeof(v))
return 1;
bswap_copy(oswapBytes, &odata[opos], &v, sizeof(v), "2");
opos += sizeof(v);
return 0;
}
int BBufferStore::pop(BUInt16& v){
if((osize - opos) < sizeof(v))
return 1;
bswap_copy(oswapBytes, &odata[opos], &v, sizeof(v), "2");
opos += sizeof(v);
return 0;
}
int BBufferStore::pop(BInt32& v){
if((osize - opos) < sizeof(v))
return 1;
bswap_copy(oswapBytes, &odata[opos], &v, sizeof(v), "4");
opos += sizeof(v);
return 0;
}
int BBufferStore::pop(BUInt32& v){
if((osize - opos) < sizeof(v))
return 1;
bswap_copy(oswapBytes, &odata[opos], &v, sizeof(v), "4");
opos += sizeof(v);
return 0;
}
int BBufferStore::pop(BInt64& v){
if((osize - opos) < sizeof(v))
return 1;
bswap_copy(oswapBytes, &odata[opos], &v, sizeof(v), "8");
opos += sizeof(v);
return 0;
}
int BBufferStore::pop(BUInt64& v){
if((osize - opos) < sizeof(v))
return 1;
bswap_copy(oswapBytes, &odata[opos], &v, sizeof(v), "8");
opos += sizeof(v);
return 0;