void drawHiscores(int max) { int i; SDL_Rect a,b; /* erase the screen */ SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0)); /* DD2 characters */ a.x=60; a.y=5; b.x=450; b.y=43; b.w=211; b.h=190; SDL_BlitSurface(gfx, &b, screen, &a); /* header */ writeCString(gfx, screen, 80, 2, "the hall of fame", 1); for(i=0;i<max;i++) { writeNumber(gfx, screen, 10, 23+i*17, i+1, 2); writeCString(gfx, screen, 30, 20+i*17, hiscore[i].name, 0); writeCString(gfx, screen, 180, 20+i*17, "st",0); writeNumber(gfx, screen, 200, 23+i*17, hiscore[i].stage,2); writeCString(gfx, screen, 236, 20+i*17, "sc",0); writeNumber(gfx, screen, 260, 23+i*17, hiscore[i].score,6); } SDL_Flip(screen); }
/** Write a node at the specified coordinates. If a node is currently there then overwrite. */ void GridNode::writeNode(int x,int y, Color color, int numberOfNodes, File grid) { int pos = findPositionOfGridNode(x,y,grid); if(grid) { if(pos == -1) { if(numberOfNodes > 0) { grid.write(','); grid.write('\n'); } grid.write('\"'); writeNumber(grid,x); grid.write(','); writeNumber(grid,y); grid.write('\"'); grid.write('{'); grid.write('\n'); writeColor(grid,color, false); grid.write('\n'); grid.write('}'); } else { grid.seek(pos); grid.write('\n'); writeColor(grid,color, false); } } else { //Serial.println("Map file was not avaliable for writing"); } grid.flush(); grid.close(); }
void WKTWriter::appendCoordinate(const Coordinate* coordinate, Writer *writer) { string out=""; out+=writeNumber(coordinate->x); out+=" "; out+=writeNumber(coordinate->y); #if PRINT_Z out+=" "; out+=writeNumber(coordinate->z); #endif writer->write(out); }
uint32_t Node::encode(std::vector<uint8_t>& buffer) const { uint32_t size = 0; uint32_t ret = 0; buffer.push_back(static_cast<uint8_t>(marker)); size += 1; switch (marker) { case Marker::Number: ret = writeNumber(buffer, doubleValue); break; case Marker::Boolean: ret = writeBoolean(buffer, boolValue); break; case Marker::String: ret = writeString(buffer, stringValue); break; case Marker::Object: ret = writeObject(buffer, mapValue); break; case Marker::Null: /* Null */; break; case Marker::Undefined: /* Undefined */; break; case Marker::ECMAArray: ret = writeECMAArray(buffer, mapValue); break; case Marker::ObjectEnd: break; // should not happen case Marker::StrictArray: ret = writeStrictArray(buffer, vectorValue); break; case Marker::Date: ret = writeDate(buffer, dateValue); break; case Marker::LongString: ret = writeLongString(buffer, stringValue); break; case Marker::XMLDocument: ret = writeXMLDocument(buffer, stringValue); break; case Marker::TypedObject: ret = writeTypedObject(buffer); break; case Marker::SwitchToAMF3: ret = writeSwitchToAMF3(buffer); break; default: return 0; } size += ret; return size; }
void AMFWriter::writeResponseHeader(const string& key,double callbackHandle) { _writer.write8(0x14); _writer.write32(0); write(key); writeNumber(callbackHandle); writeNull(); }
void AMFWriter::writeObject(const AMFObject& amfObject) { beginObject(); AbstractConfiguration::Keys keys; amfObject.keys(keys); AbstractConfiguration::Keys::const_iterator it; for(it=keys.begin();it!=keys.end();++it) { string name = *it; _writer.writeString16(name); int type = amfObject.getInt(name+".type",-1); switch(type) { case AMF_BOOLEAN: writeBool(amfObject.getBool(name)); break; case AMF_STRING: write(amfObject.getString(name)); break; case AMF_NUMBER: writeNumber(amfObject.getDouble(name)); break; case AMF_UNDEFINED: write(""); break; case AMF_NULL: writeNull(); break; default: ERROR("Unknown AMF '%d' type",type); } } endObject(); }
/* protected */ void WKTWriter::appendCoordinate(const Coordinate* coordinate, Writer *writer) { writer->write(writeNumber(coordinate->x)); writer->write(" "); writer->write(writeNumber(coordinate->y)); if( outputDimension == 3 ) { writer->write(" "); if( ISNAN(coordinate->z) ) writer->write(writeNumber(0.0)); else writer->write(writeNumber(coordinate->z)); } }
/* protected */ void WKTWriter::appendCoordinate(const Coordinate* coordinate, Writer* writer) { writer->write(writeNumber(coordinate->x)); writer->write(" "); writer->write(writeNumber(coordinate->y)); if(outputDimension == 3) { writer->write(" "); if(std::isnan(coordinate->z)) { writer->write(writeNumber(0.0)); } else { writer->write(writeNumber(coordinate->z)); } } }
bool ResourceFileWriter::write() { ofstream outputFile(myFilePath.c_str(), ios::out | ios::binary); if(!outputFile.is_open()) // make sure the file is open { return false; } int headerSize = getHeaderSize(); // calculate how many bytes the header will be // write the header information writeNumber(outputFile, magicWord); writeNumber(outputFile, headerSize); writeNumber(outputFile, myEntries.size()); // write the file table int currentOffset = headerSize; for(map<string, ResourceFileEntry *>::iterator i = myEntries.begin(); i != myEntries.end(); i++) { ResourceFileEntry * entry = (*i).second; entry->setOffset(currentOffset); outputFile << entry->name() << '\0'; writeNumber(outputFile, entry->fileSize()); writeNumber(outputFile, currentOffset); currentOffset += entry->fileSize(); } // input all source files ifstream inputFile; for(map<string, ResourceFileEntry *>::iterator i = myEntries.begin(); i != myEntries.end(); i++) { ResourceFileEntry * entry = (*i).second; inputFile.open(entry->filePath().c_str(), ios::in | ios::binary); outputFile << inputFile.rdbuf(); inputFile.close(); } outputFile.close(); return true; }
/* pritected */ void WKTWriter::appendCoordinate(const Coordinate* coordinate, Writer *writer) { string out=""; out+=writeNumber(coordinate->x); out+=" "; out+=writeNumber(coordinate->y); if( outputDimension == 3 ) { out+=" "; if( ISNAN(coordinate->z) ) out+=writeNumber(0.0); else out+=writeNumber(coordinate->z); } writer->write(out); }
void surf3::buildSurface(const fluid3 *fluidSolver, const levelset3 *fluid, const levelset3 *solid, bool enclose ) { tick(); dump(">>> Building surfaces started...\n"); if( fluidSolver->getBCCMesh() ) { surf = &bccsurf; bccsurf.setBCC(*fluidSolver->getBCCMesh()); bccsurf.buildSurface(vertices,normals,faces,fluid,solid,enclose); } else if( fluidSolver->getMesh() ) { surf = &meshsurf; mesh = *fluidSolver->getMesh(); meshsurf.setReference(&mesh); meshsurf.buildSurface(vertices,normals,faces,fluid,solid,enclose); } else { surf = &cellsurf; cellsurf.buildSurface(vertices,normals,faces,fluid,solid,enclose); } // Build ANN tick(); dump("Building ANN structure for mesh vertices..."); ann.sort(vertices); dump("Done. Took %s.\n", stock("surf_ANN")); // Compute vertices to face info v2f.clear(); v2f.resize(vertices.size()); for( uint n=0; n<faces.size(); n++ ) { for( uint m=0; m<DIM; m++ ) { v2f[faces[n][m]].push_back(n); } } dump("<<< Done. Took %s.\n",stock("surf_build")); tick(); dump("Computing mesh-based curvature (%d vertices %d faces)...", vertices.size(), faces.size()); computeCurvature(solid); dump("Done. Took %s.\n", stock("surf_curvature")); // Write some info writeNumber("surf_vertex_num", vertices.size()); writeNumber("surf_face_num", faces.size()); }
void KdbxXmlWriter::writeMetadata() { m_xml.writeStartElement("Meta"); writeString("Generator", m_meta->generator()); if (m_kdbxVersion < KeePass2::FILE_VERSION_4 && !m_headerHash.isEmpty()) { writeBinary("HeaderHash", m_headerHash); } writeString("DatabaseName", m_meta->name()); writeDateTime("DatabaseNameChanged", m_meta->nameChanged()); writeString("DatabaseDescription", m_meta->description()); writeDateTime("DatabaseDescriptionChanged", m_meta->descriptionChanged()); writeString("DefaultUserName", m_meta->defaultUserName()); writeDateTime("DefaultUserNameChanged", m_meta->defaultUserNameChanged()); writeNumber("MaintenanceHistoryDays", m_meta->maintenanceHistoryDays()); writeColor("Color", m_meta->color()); writeDateTime("MasterKeyChanged", m_meta->masterKeyChanged()); writeNumber("MasterKeyChangeRec", m_meta->masterKeyChangeRec()); writeNumber("MasterKeyChangeForce", m_meta->masterKeyChangeForce()); writeMemoryProtection(); writeCustomIcons(); writeBool("RecycleBinEnabled", m_meta->recycleBinEnabled()); writeUuid("RecycleBinUUID", m_meta->recycleBin()); writeDateTime("RecycleBinChanged", m_meta->recycleBinChanged()); writeUuid("EntryTemplatesGroup", m_meta->entryTemplatesGroup()); writeDateTime("EntryTemplatesGroupChanged", m_meta->entryTemplatesGroupChanged()); writeUuid("LastSelectedGroup", m_meta->lastSelectedGroup()); writeUuid("LastTopVisibleGroup", m_meta->lastTopVisibleGroup()); writeNumber("HistoryMaxItems", m_meta->historyMaxItems()); writeNumber("HistoryMaxSize", m_meta->historyMaxSize()); if (m_kdbxVersion >= KeePass2::FILE_VERSION_4) { writeDateTime("SettingsChanged", m_meta->settingsChanged()); } if (m_kdbxVersion < KeePass2::FILE_VERSION_4) { writeBinaries(); } writeCustomData(m_meta->customData()); m_xml.writeEndElement(); }
void KdbxXmlWriter::writeTimes(const TimeInfo& ti) { m_xml.writeStartElement("Times"); writeDateTime("LastModificationTime", ti.lastModificationTime()); writeDateTime("CreationTime", ti.creationTime()); writeDateTime("LastAccessTime", ti.lastAccessTime()); writeDateTime("ExpiryTime", ti.expiryTime()); writeBool("Expires", ti.expires()); writeNumber("UsageCount", ti.usageCount()); writeDateTime("LocationChanged", ti.locationChanged()); m_xml.writeEndElement(); }
void meshsurf3::fillHoles( std::vector<FLOAT64> &values, const levelset3 *solid, const std::vector<vec3d> &nodes, const std::vector<std::vector<uint> > &elements, const std::vector<std::vector<uint> > &node2node, FLOAT64 dx ) { // Simple hack to fix check-mark artifacts tick(); dump("Filling holes on solid wall"); uint count_filled = 0; for( uint k=0; k<3; k++ ) { std::vector<bool> adjacentFlag(nodes.size()); std::vector<FLOAT64> old_levelset = values; PARALLEL_FOR for( uint n=0; n<values.size(); n++ ) { bool connected_wall = false; if( solid->evalLevelset(nodes[n]) > -dx ) { for( uint m=0; m<node2node[n].size(); m++ ) { if( solid->evalLevelset(nodes[node2node[n][m]]) < dx ) { connected_wall = true; break; } } } adjacentFlag[n] = connected_wall; } PARALLEL_FOR for( uint n=0; n<nodes.size(); n++ ) { if( adjacentFlag[n] && old_levelset[n] > 0.0 ) { uint fluid_count = 0; uint non_fluid_count = 0; FLOAT64 avg = 0.0; FLOAT64 sum = 0.0; for( uint m=0; m<node2node[n].size(); m++ ) { uint idx = node2node[n][m]; if( adjacentFlag[idx] ) { if( old_levelset[idx] < 0.0 ) { fluid_count ++; avg += old_levelset[idx]; sum ++; } else { non_fluid_count ++; } } } if( sum && fluid_count > 2*non_fluid_count ) { values[n] = avg / sum; count_filled ++; } } } dump("."); } dump("Done. Took %s. Filled %d holes.\n",stock("meshsurf_fill_hole"), count_filled ); writeNumber("meshsurf_fill_hole_number", count_filled); }
void KdbxXmlWriter::writeAutoType(const Entry* entry) { m_xml.writeStartElement("AutoType"); writeBool("Enabled", entry->autoTypeEnabled()); writeNumber("DataTransferObfuscation", entry->autoTypeObfuscation()); writeString("DefaultSequence", entry->defaultAutoTypeSequence()); const QList<AutoTypeAssociations::Association> autoTypeAssociations = entry->autoTypeAssociations()->getAll(); for (const AutoTypeAssociations::Association& assoc : autoTypeAssociations) { writeAutoTypeAssoc(assoc); } m_xml.writeEndElement(); }
void AMFWriter::writeInteger(Int32 value){ (UInt32&)lastReference=0; if(!_amf3) { if(amf0Preference) { writeNumber((double)value); return; } writer.write8(AMF_AVMPLUS_OBJECT); } writer.write8(AMF3_INTEGER); // marker if(value>268435455) { ERROR("AMF Integer maximum value reached"); value=268435455; } else if(value<0) value+=(1<<29); writer.write7BitValue(value); }
/** * @brief Writes the specified JSON element to `writer`. * @param writer The JSONWriter. * @param obj The JSON element to write. */ static void writeElement(JSONWriter *writer, const ident obj) { const Object *object = cast(Object, obj); if (object) { if ($(object, isKindOfClass, _Dictionary())) { writeObject(writer, (Dictionary *) object); } else if ($(object, isKindOfClass, _Array())) { writeArray(writer, (Array *) object); } else if ($(object, isKindOfClass, _String())) { writeString(writer, (String *) object); } else if ($(object, isKindOfClass, _Number())) { writeNumber(writer, (Number *) object); } else if ($(object, isKindOfClass, _Boole())) { writeBoole(writer, (Boole *) object); } else if ($(object, isKindOfClass, _Null())) { writeNull(writer, (Null *) object); } } }
void RC2UI::writeStyles( const QStringList styles, bool isFrame ) { if ( isFrame ) { bool defineFrame = FALSE; QString shadow = "NoFrame"; QString shape = "StyledPanel"; int width = 2; if ( styles.contains( "WS_EX_STATICEDGE" ) ) { shadow = "Plain"; width = 1; defineFrame = TRUE; } if ( styles.contains( "WS_EX_CLIENTEDGE" ) ) { shadow = "Sunken"; defineFrame = TRUE; } if ( styles.contains( "WS_EX_DLGMODALFRAME" ) ) { shadow = "Raised"; defineFrame = TRUE; } if ( !styles.contains( "WS_BORDER" ) ) { shape = "NoFrame"; defineFrame = TRUE; } if ( defineFrame ) { writeEnum( "frameShape", "StyledPanel" ); writeEnum( "frameShadow", shadow ); writeNumber( "lineWidth", width ); } } if ( styles.contains("WS_DISABLED") ) writeBool("enabled", FALSE ); if ( styles.contains("WS_EX_ACCEPTFILES") ) writeBool("acceptDrops", TRUE ); if ( styles.contains("WS_EX_TRANSPARENT") ) writeBool("autoMask", TRUE ); if ( !styles.contains("WS_TABSTOP") ) writeEnum("focusPolicy", "NoFocus"); }
void KdbxXmlWriter::writeGroup(const Group* group) { Q_ASSERT(!group->uuid().isNull()); m_xml.writeStartElement("Group"); writeUuid("UUID", group->uuid()); writeString("Name", group->name()); writeString("Notes", group->notes()); writeNumber("IconID", group->iconNumber()); if (!group->iconUuid().isNull()) { writeUuid("CustomIconUUID", group->iconUuid()); } writeTimes(group->timeInfo()); writeBool("IsExpanded", group->isExpanded()); writeString("DefaultAutoTypeSequence", group->defaultAutoTypeSequence()); writeTriState("EnableAutoType", group->autoTypeEnabled()); writeTriState("EnableSearching", group->searchingEnabled()); writeUuid("LastTopVisibleEntry", group->lastTopVisibleEntry()); if (m_kdbxVersion >= KeePass2::FILE_VERSION_4) { writeCustomData(group->customData()); } const QList<Entry*>& entryList = group->entries(); for (const Entry* entry : entryList) { writeEntry(entry); } const QList<Group*>& children = group->children(); for (const Group* child : children) { writeGroup(child); } m_xml.writeEndElement(); }
void Writer::write(Appender& appender, const Value& value, Size indent) { switch (value.getType()) { case Value::Type::Null: writeNull(appender); break; case Value::Type::Boolean: writeBoolean(appender, value.asBoolean()); break; case Value::Type::Number: writeNumber(appender, value.asDouble()); break; case Value::Type::String: writeString(appender, value.asString()); break; case Value::Type::Array: writeArray(appender, value, indent); break; case Value::Type::Object: writeObject(appender, value, indent); break; } }
void AMFWriter::writeObjectProperty(const string& name,double value) { writePropertyName(name); writeNumber(value); }
void _ByteArray::write4BChars(char * val) { std::size_t size = strlen(val); writeNumber(size); writeBytes((unsigned char *)val, size, 0); }
/** * 写入一个字符串 */ void ByteArray::writeString(const std::string &value) { writeNumber((int)value.size()); writeChars(value.c_str(), value.size(), 0); }
void KdbxXmlWriter::writeEntry(const Entry* entry) { Q_ASSERT(!entry->uuid().isNull()); m_xml.writeStartElement("Entry"); writeUuid("UUID", entry->uuid()); writeNumber("IconID", entry->iconNumber()); if (!entry->iconUuid().isNull()) { writeUuid("CustomIconUUID", entry->iconUuid()); } writeColor("ForegroundColor", entry->foregroundColor()); writeColor("BackgroundColor", entry->backgroundColor()); writeString("OverrideURL", entry->overrideUrl()); writeString("Tags", entry->tags()); writeTimes(entry->timeInfo()); const QList<QString> attributesKeyList = entry->attributes()->keys(); for (const QString& key : attributesKeyList) { m_xml.writeStartElement("String"); // clang-format off bool protect = (((key == "Title") && m_meta->protectTitle()) || ((key == "UserName") && m_meta->protectUsername()) || ((key == "Password") && m_meta->protectPassword()) || ((key == "URL") && m_meta->protectUrl()) || ((key == "Notes") && m_meta->protectNotes()) || entry->attributes()->isProtected(key)); // clang-format on writeString("Key", key); m_xml.writeStartElement("Value"); QString value; if (protect) { if (!m_innerStreamProtectionDisabled && m_randomStream) { m_xml.writeAttribute("Protected", "True"); bool ok; QByteArray rawData = m_randomStream->process(entry->attributes()->value(key).toUtf8(), &ok); if (!ok) { raiseError(m_randomStream->errorString()); } value = QString::fromLatin1(rawData.toBase64()); } else { m_xml.writeAttribute("ProtectInMemory", "True"); value = entry->attributes()->value(key); } } else { value = entry->attributes()->value(key); } if (!value.isEmpty()) { m_xml.writeCharacters(stripInvalidXml10Chars(value)); } m_xml.writeEndElement(); m_xml.writeEndElement(); } const QList<QString> attachmentsKeyList = entry->attachments()->keys(); for (const QString& key : attachmentsKeyList) { m_xml.writeStartElement("Binary"); writeString("Key", key); m_xml.writeStartElement("Value"); m_xml.writeAttribute("Ref", QString::number(m_idMap[entry->attachments()->value(key)])); m_xml.writeEndElement(); m_xml.writeEndElement(); } writeAutoType(entry); if (m_kdbxVersion >= KeePass2::FILE_VERSION_4) { writeCustomData(entry->customData()); } // write history only for entries that are not history items if (entry->parent()) { writeEntryHistory(entry); } m_xml.writeEndElement(); }
void DataWriter::writeNumberProperty(const string& name,double value) { writePropertyName(name); writeNumber(value); }
void AMFWriter::writeObjectProperty(const string& name,double value) { _writer.writeString16(name); writeNumber(value); }