39 bool ret(pMS->
Save(rep, into));
49 if ( data->
size() >= deflationLimit ) {
89 return rep->
visit( *
this );
98 }
else if ( val == 0 ) {
100 }
else if ( val == 1 ) {
102 }
else if ( val + 0x8000u > 0xFFFF ) {
105 }
else if ( val + 0x80u > 0xFF ) {
135 if ( rep->
value() == 0.0 ) {
139 Put<double>( rep->
value() );
165 size_t len(rep->
content().size());
169 }
else if ( len == 1 ) {
171 Put<uint8>( rep->
content()[0] );
191 size_t len(rep->
content().size());
211 const std::string& str = rep->
content();
214 Put( str.begin(), str.end() );
224 }
else if ( size == 1 ) {
226 }
else if ( size == 2 ) {
241 }
else if ( size == 1 ) {
259 for (; cur != end; ++cur) {
260 if ( !cur->second->visit( *
this ) )
262 if ( !cur->first->visit( *
this ) )
286 for (; lcur != lend; ++lcur ) {
287 if ( !(*lcur )->visit( *
this ) )
294 for (; dcur != dend; ++dcur ) {
295 if ( !dcur->first->visit( *
this ) )
297 if ( !dcur->second->visit( *
this ) )
311 header->
visit( *
this );
315 std::multimap< uint8, uint32, std::greater< uint8 > > sizeMap;
316 std::map<uint8,uint8> booleanColumns;
318 uint32 columnCount = header->ColumnCount();
319 size_t byteDataBitLength = 0;
320 size_t booleansBitLength = 0;
321 size_t nullsBitLength = 0;
324 for (uint32_t i = 0; i < columnCount; i ++)
326 DBTYPE columnType = header->GetColumnType (i);
333 booleanColumns.insert (std::make_pair (i, booleansBitLength));
334 booleansBitLength ++;
343 byteDataBitLength += size;
346 sizeMap.insert (std::make_pair (size, i));
351 rowData.
Reserve<
uint8> ((byteDataBitLength >> 3) + ((booleansBitLength + nullsBitLength) >> 3) + 1);
354 Buffer bitData(((booleansBitLength + nullsBitLength) >> 3) + 1, 0);
356 std::multimap< uint8, uint32, std::greater< uint8 > >::iterator cur, end;
357 cur = sizeMap.begin();
359 end = sizeMap.lower_bound( 1 );
360 PyRep* value(
nullptr);
361 for (; cur != end; ++cur)
363 value = pyPackedRow->
GetField(cur->second);
366 if (value->
IsNone() ==
true)
369 unsigned long nullBit = cur->second + booleansBitLength;
370 unsigned long nullByte = nullBit >> 3;
374 *bitIterator |= (1 << (nullBit & 0x7));
379 switch (header->GetColumnType (cur->second))
419 cur = sizeMap.lower_bound( 1 );
420 end = sizeMap.lower_bound( 0 );
422 for (; cur != end; ++cur)
427 if (b->
value() ==
false)
431 unsigned long boolBit = booleanColumns.find (cur->second)->second;
432 unsigned long boolByte = boolBit >> 3;
436 *bitIterator |= (1 << (boolBit & 0x7));
447 cur = sizeMap.lower_bound( 0 );
449 for (; cur != end; ++cur) {
450 value = pyPackedRow->
GetField(cur->second );
451 if (!value->
visit(*
this))
467 if (rep->
data() ==
nullptr) {
468 if (rep->
decoded() ==
nullptr) {
476 if (rep->
data() ==
nullptr) {
495 assert(
false &&
"MarshalStream on the server side should never send checksummed objects");
506 uint8 integerSize(0);
508 #define DoIntegerSizeCheck(x) if ( ( (uint8*)&value )[x] != 0 ) integerSize = x + 1;
512 #undef DoIntegerSizeCheck
514 if ( integerSize > 0 && integerSize < 7 ) {
517 Put( &( (
uint8*)&value )[0], &( (
uint8*)&value )[integerSize] );
544 int start, end, count;
546 int in_size = in.
size();
548 while(in_ix < in_size)
552 nibble_ix = out_ix++;
565 out[out_ix++] = in[in_ix++];
566 }
while(in_ix<end && in[in_ix]);
567 count = (start - in_ix) + 8;
572 while(in_ix<end && !in[in_ix])
574 count = (in_ix - start) + 7;
578 out[nibble_ix] |= (count << 4);
580 out[nibble_ix] = count;
584 if(nibble && zerochains)
595 if ( 0 < out.size() )
void Append(const T &value)
Appends a single value to buffer.
list_type::const_iterator const_list_iterator
bool MarshalDeflate(const PyRep *rep, Buffer &into, const uint32 deflationLimit)
bool VisitWString(const PyWString *rep)
add a wide string object to the data stream
bool VisitInteger(const PyInt *rep)
virtual bool VisitTuple(const PyTuple *rep)
the nested types Visitor
bool visit(PyVisitor &v) const
Visits object.
bool VisitDict(const PyDict *rep)
const Buffer & content() const
Get the const PyBuffer content.
bool Save(const PyRep *rep, Buffer &into)
void SaveVarInteger(const PyLong *v)
DBRowDescriptor * header() const
const std::string & content() const
Get the PyWString content.
bool VisitPackedRow(const PyPackedRow *pyPackedRow)
Adds a packed row to the stream.
bool VisitObject(const PyObject *rep)
Adds an object to the stream.
#define sMarshalStringTable
Python floating point number.
bool VisitBuffer(const PyBuffer *rep)
Adds a buffer to the stream.
const_iterator begin() const
Turns Python objects into marshal bytecode.
bool Marshal(const PyRep *rep, Buffer &into)
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
PyRep * GetField(size_t index) const
Generic class for buffers.
void AppendSeq(Iter first, Iter last)
Appends a sequence of elements to buffer.
bool VisitLong(const PyLong *rep)
Adds a long to the stream.
Python object "blue.DBRowDescriptor".
bool VisitSubStream(const PySubStream *rep)
Adds a sub stream to the stream.
dict_type::const_iterator const_dict_iterator
bool DeflateData(Buffer &data)
Deflates given data.
virtual bool VisitSubStruct(const PySubStruct *rep)
wrapper types Visitor
void Reserve(size_type requiredCount)
Reserves (pre-allocates) memory for buffer.
bool VisitChecksumedStream(const PyChecksumedStream *rep)
Adds a checksumed stream to the stream.
bool VisitBoolean(const PyBool *rep)
Adds a boolean to the stream.
#define STRING_TABLE_ERROR
uint8 DBTYPE_GetSizeBits(DBTYPE type)
bool VisitString(const PyString *rep)
add a string object to the data stream
#define DoIntegerSizeCheck(x)
const std::string & content() const
Obtain token.
const_iterator begin() const
Python token (eg. class name).
bool SaveStream(const PyRep *rep)
virtual bool VisitObject(const PyObject *rep)
Object type visitor.
const_iterator end() const
static const uint8 MarshalHeaderByte
storage_type::const_iterator const_iterator
bool SaveRLE(const Buffer &in)
bool VisitNone(const PyNone *rep)
Adds a None object to the stream.
const std::string & content() const
Get the PyString content.
bool VisitObjectEx(const PyObjectEx *rep)
Adds a New object to the stream.
const_iterator end() const
bool VisitToken(const PyToken *rep)
add a token object to the data stream
bool VisitSubStruct(const PySubStruct *rep)
Adds a sub structure to the stream.
bool VisitTuple(const PyTuple *rep)
bool VisitList(const PyList *rep)
virtual bool VisitList(const PyList *rep)
virtual bool visit(PyVisitor &v) const =0
Visits object.
void PutSizeEx(uint32 size)
bool VisitReal(const PyFloat *rep)
Adds a double to the stream.
virtual bool VisitChecksumedStream(const PyChecksumedStream *rep)