void FixedPositioning::dumpLayer(FILE* file, int indentLevel) const { writeLength(file, indentLevel + 1, "fixedLeft", m_fixedLeft); writeLength(file, indentLevel + 1, "fixedTop", m_fixedTop); writeLength(file, indentLevel + 1, "fixedRight", m_fixedRight); writeLength(file, indentLevel + 1, "fixedBottom", m_fixedBottom); writeLength(file, indentLevel + 1, "fixedMarginLeft", m_fixedMarginLeft); writeLength(file, indentLevel + 1, "fixedMarginTop", m_fixedMarginTop); writeLength(file, indentLevel + 1, "fixedMarginRight", m_fixedMarginRight); writeLength(file, indentLevel + 1, "fixedMarginBottom", m_fixedMarginBottom); writeRect(file, indentLevel + 1, "fixedRect", m_fixedRect); }
void TSaslTransport::write(const uint8_t* buf, uint32_t len) { const uint8_t* newBuf; if (shouldWrap_) { newBuf = sasl_->wrap((uint8_t*)buf, 0, len, &len); } else { newBuf = buf; } writeLength(len); transport_->write(newBuf, len); }
int signal(int cond, int lock){ int length=0; readLength(&length); if(length>0){ v(cond); //readLength(&length); length--; writeLength(&length); } return(0); }
int broadCast(int cond, int lock){ int length=0; readLength(&length); while(length>0){ v(cond); //readLength(&length); length--; writeLength(&length); readLength(&length); } return(0); }
void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const { writeln(file, indentLevel, "{"); writeHexVal(file, indentLevel + 1, "layer", (int)this); writeIntVal(file, indentLevel + 1, "layerId", m_uniqueId); writeIntVal(file, indentLevel + 1, "haveClip", m_haveClip); writeIntVal(file, indentLevel + 1, "isRootLayer", m_isRootLayer); writeIntVal(file, indentLevel + 1, "isFixed", m_isFixed); writeFloatVal(file, indentLevel + 1, "opacity", getOpacity()); writeSize(file, indentLevel + 1, "size", getSize()); writePoint(file, indentLevel + 1, "position", getPosition()); writePoint(file, indentLevel + 1, "translation", m_translation); writePoint(file, indentLevel + 1, "anchor", getAnchorPoint()); writePoint(file, indentLevel + 1, "scale", m_scale); if (m_doRotation) writeFloatVal(file, indentLevel + 1, "angle", m_angleTransform); if (m_isFixed) { writeLength(file, indentLevel + 1, "fixedLeft", m_fixedLeft); writeLength(file, indentLevel + 1, "fixedTop", m_fixedTop); writeLength(file, indentLevel + 1, "fixedRight", m_fixedRight); writeLength(file, indentLevel + 1, "fixedBottom", m_fixedBottom); writeLength(file, indentLevel + 1, "fixedMarginLeft", m_fixedMarginLeft); writeLength(file, indentLevel + 1, "fixedMarginTop", m_fixedMarginTop); writeLength(file, indentLevel + 1, "fixedMarginRight", m_fixedMarginRight); writeLength(file, indentLevel + 1, "fixedMarginBottom", m_fixedMarginBottom); writePoint(file, indentLevel + 1, "fixedOffset", m_fixedOffset); writeIntVal(file, indentLevel + 1, "fixedWidth", m_fixedWidth); writeIntVal(file, indentLevel + 1, "fixedHeight", m_fixedHeight); } if (m_recordingPicture) { writeIntVal(file, indentLevel + 1, "picture width", m_recordingPicture->width()); writeIntVal(file, indentLevel + 1, "picture height", m_recordingPicture->height()); } if (countChildren()) { writeln(file, indentLevel + 1, "children = ["); for (int i = 0; i < countChildren(); i++) { if (i > 0) writeln(file, indentLevel + 1, ", "); getChild(i)->dumpLayers(file, indentLevel + 1); } writeln(file, indentLevel + 1, "];"); } writeln(file, indentLevel, "}"); }
int wait(int cond, int lock){ int length=0; readLength(&length); length++; writeLength(&length); v(lock); //lock->Release(); p(cond); //s.P(); p(lock); //lock -> Acquire(); return(0); }
/* * PROTOCOL - Payload Packet * ------------------------------------------------------------------------------- * | Header | Length | Sub-Payloads | CHECKSUM | * ------------------------------------------------------------------------------- * | 4 BYTES | 2 BYTES | n BYTES (74 Bytes Max for each Sub-Payload | 2 BYTES | * ------------------------------------------------------------------------------- * * * Sub-Payload Packet (Max 74 Bytes) * ------------------------------------------------------------------------------------------------- * | Length | ID | TYPE | ACCESS | LOCATION | VALUE | DESCRIPTION | * ------------------------------------------------------------------------------------------------- * | 1 BYTE | 2 BYTES | 1 BYTE | 1 BYTE | 1 BYTE | 4 BYTES | n BYTES (Max 30) | * ------------------------------------------------------------------------------------------------- * * * Joins the full message buffer to be sent to the controller * */ int writePayload(Datapoint datapoints[], byte protocolBuffer[]) { writeHeader(protocolBuffer); // First sub-payload starts at index 6 (starting from 0) // 4 bytes HEADER + 2 bytes PAYLOAD LENGTH int length = 6; for(int i=0;i < NUMBER_DATAPOINTS; i++) { length += datapoints[i].writeSubPayload(protocolBuffer, length); } // The length comes before the sub-payloads but is only known after they are processed writeLength(length - 6, protocolBuffer); length += writeChecksum(length, protocolBuffer); return length; }
void CompactionConstraintGraphBase::writeGML(ostream &os, NodeArray<bool> one) const { const Graph &G = *this; NodeArray<int> id(*this); int nextId = 0; os.setf(ios::showpoint); os.precision(10); os << "Creator \"ogdf::CompactionConstraintGraphBase::writeGML\"\n"; os << "graph [\n"; os << " directed 1\n"; for(node v : G.nodes) { os << " node [\n"; os << " id " << (id[v] = nextId++) << "\n"; os << " graphics [\n"; os << " x 0.0\n"; os << " y 0.0\n"; os << " w 30.0\n"; os << " h 30.0\n"; if ((one[v])) { os << " fill \"#FF0F0F\"\n"; } else { os << " fill \"#FFFF00\"\n"; } os << " ]\n"; // graphics os << " ]\n"; // node } for(edge e : G.edges) { os << " edge [\n"; os << " source " << id[e->source()] << "\n"; os << " target " << id[e->target()] << "\n"; #if 0 // show edge lengths as edge lables (not yet supported) os << " label \""; writeLength(os,e); os << "\"\n"; #endif os << " graphics [\n"; os << " type \"line\"\n"; os << " arrow \"last\"\n"; switch(m_type[e]) { case cetBasicArc: // red os << " fill \"#FF0000\"\n"; break; case cetVertexSizeArc: // blue os << " fill \"#0000FF\"\n"; break; case cetVisibilityArc: // green os << "fill \"#00FF00\"\n"; break; case cetReducibleArc: // rose os << " fill \"#FF00FF\"\n"; break; case cetFixToZeroArc: //violett os << " fill \"#3F00FF\"\n"; break; OGDF_NODEFAULT } os << " ]\n"; // graphics #if 0 os << " LabelGraphics [\n"; os << " type \"text\"\n"; os << " fill \"#000000\"\n"; os << " anchor \"w\"\n"; os << " ]\n"; #endif os << " ]\n"; // edge } os << "]\n"; // graph }
QByteArray U2BitCompression::compress(const char* text, int len, int alphabetSize, const int* alphabetCharNums, U2OpStatus& os) { // algorithm: // 1. compute chars freq -> derive number of bits per char // 2. assign bit masks per char. Do not assign any bit masks for non used alphabet chars // 3. compress chars // 4. create header with used char mask // Result bits [len type][len][used alpha bits][compressed text] // where [len type] is a type of length field: 00 -> empty, 01 -> 8 byte, 10 -> 16 bytes, 11 -> 32 bytes // [len] - length of the result sequence // [used alpha bits] bit is set if alpha char is used in the text. // [compressed text] the data in compressed form assert(alphabetSize <= 32); //avoid this check in runtime -> use this method correctly // find all used chars in text QVector<bool> visitVector(alphabetSize, false); bool* visited = visitVector.data(); for (int i = 0; i < len; i++) { uchar c = text[i]; int n = alphabetCharNums[c]; if (n == -1) { os.setError(tr("Bit compression: illegal character in text '%1'").arg(char(c))); return QByteArray(); } if (!visited[n]) { visited[n] = true; } } // assign sequential bit-mask for all used chars QVector<uchar> maskVector(alphabetSize, 0); uchar* mask = maskVector.data(); uchar m = 0; for (int i = 0; i < alphabetSize; i++) { if (visited[i]) { mask[i] = m; m++; } } // store header and data to bit set int bitsPerChar = U2Bits::getNumberOfBitsPerChar(m); int compressedBitSize = len * bitsPerChar; int lenBits = getLenBitsSize(len); int headerSizeBits = 2 + lenBits + alphabetSize; int resultSizeBits = headerSizeBits + compressedBitSize; static QByteArray res; QByteArray bitSet = U2Bits::allocateBits(resultSizeBits); uchar* bits = (uchar*)bitSet.data(); writeLength(bits, len, lenBits); int pos = 2 + lenBits; for (; pos < alphabetSize; pos++) { if (visited[pos]) { U2Bits::setBit(bits, pos); } } for (int i = 0; i < len; i++, pos+=bitsPerChar) { uchar c = text[i]; int n = alphabetCharNums[c]; uchar m = mask[n]; U2Bits::setBits(bits, pos, &m, bitsPerChar); } return bitSet; }