void regG::execWP() { if(SEQ::isAsserted(CLG)) write(0); if(SEQ::isAsserted(RP2)) writeField(15, 15, PAR::register_P2.read()); if(SEQ::isAsserted(GP)) writeField(15, 15, PAR::gen1_15Parity(PAR::register_P.read())); if(SEQ::isAsserted(WGn)) writeShift(BUS::glbl_RWBUS, MBF::conv_WGn); // This is only used in PINC, MINC, and SHINC. Does not clear G // register; writes (ORs) into G from RWBus and writes into parity // from 1-15 generator. All done in one operation, although I show // it in two steps here. The sequence calls CLG in a previous TP. if(SEQ::isAsserted(WGx)) { write(read() | shiftData(read(), BUS::glbl_RWBUS, MBF::conv_WGn)); writeField(15, 15, PAR::gen1_15Parity(PAR::register_P.read())); } if(SEQ::isAsserted(W20)) writeShift(BUS::glbl_RWBUS, MBF::conv_W20); if(SEQ::isAsserted(W21)) writeShift(BUS::glbl_RWBUS, MBF::conv_W21); if(SEQ::isAsserted(W22)) writeShift(BUS::glbl_RWBUS, MBF::conv_W22); if(SEQ::isAsserted(W23)) writeShift(BUS::glbl_RWBUS, MBF::conv_W23); if(SEQ::isAsserted(SBEWG)) writeShift(MBF::readMemory(), MBF::conv_SBEWG); if(SEQ::isAsserted(SBFWG)) writeShift(MBF::readMemory(), MBF::conv_SBFWG); if(SEQ::isAsserted(WE)) MBF::writeMemory(shiftData(0, MBF::register_G.read(), MBF::conv_WE)); }
void JavaCodeGenerator::serializeField(ofstream& ofs, TypeDeclaration& theField) { if (theField.declarationType == DLT_ARRAY) { ofs << "SerializationUtil.writeVariableLength(dos, " + theField.name + ".length);" << endl; if (theField.userTypeDefinition == NULL) { ofs << "for(int i=0; i < " + theField.name + ".length;i++){" << endl; writeField(ofs, theField.dataType, theField.name + "[i]"); ofs << "}" << endl; } else { ofs << "for(int i=0; i < " + theField.name + ".length;i++){" << endl; ofs << theField.name + "[i].serialize(dos);" << endl; ofs << "}" << endl; } } else if (theField.declarationType == DLT_USER) { ofs << theField.name + ".serialize(dos);" << endl; } else if (theField.declarationType == DLT_PRIMITIVE) { writeField(ofs, theField.dataType, theField.name); } else if (theField.declarationType == DLT_BYTE_ARRAY) { ofs << "SerializationUtil.writeVariableLength(dos, " + theField.name + ".length);" << endl; ofs << "dos.write(" + theField.name + ");" << endl; } }
void regSTB::execWP() { if(SEQ::isAsserted(WSTB)) write(SEQ::register_STA.read()); if(SEQ::isAsserted(CLSTB)) writeField(2,1,0); if(SEQ::isAsserted(SETSTB)) writeField(2,1,1); }
void toJson( JsonWriter &json, const _T & v ) const { switch( v.d() ) { case ADL::picture::Picture::CIRCLE: json.startObject(); writeField( json, circle_s(), "circle", v.circle() ); json.endObject(); break; case ADL::picture::Picture::RECTANGLE: json.startObject(); writeField( json, rectangle_s(), "rectangle", v.rectangle() ); json.endObject(); break; case ADL::picture::Picture::COMPOSED: json.startObject(); writeField( json, composed_s(), "composed", v.composed() ); json.endObject(); break; case ADL::picture::Picture::TRANSLATED: json.startObject(); writeField( json, translated_s(), "translated", v.translated() ); json.endObject(); break; } }
void regSTA::execWP() { if(SEQ::isAsserted(ST1)) writeField(1,1,1); if(SEQ::isAsserted(ST2)) writeField(2,2,1); if(SEQ::isAsserted(TRSM)) if(ADR::register_S.read()==025) writeField(2,2,1); if(SEQ::isAsserted(CLSTA)) writeField(2,1,0); }
void MetadataReader::doDESubheader(const std::string& key, ::nitf::DESubheader& subheader) { writeField(key, "DESID", subheader.getTypeID()); writeField(key, "DESVER", subheader.getVersion()); writeField(key, "DECLAS", subheader.getSecurityClass()); ::nitf::FileSecurity security = subheader.getSecurityGroup(); doSecurity(key, "DE", security); // this is not an internal field, not interesting to users //writeField(key, "DESSHL", subheader.getDataLength()); }
void regIn0::execRP() { if(SEQ::isAsserted(RA4)) { // Sample the state of the inputs at the moment the // read pulse is asserted. In the H/W implementation, // register 0 is a buffer, not a latch. writeField(5,1,KBD::kbd); writeField(6,6,0); // actually should be keypressed strobe writeField(14,14,MON::SA); clk(); BUS::glbl_RWBUS|=read(); } }
void TabSeparatedRowOutputStream::writeExtremes() { if (extremes) { size_t rows = extremes.rows(); size_t columns = extremes.columns(); writeChar('\n', ostr); for (size_t i = 0; i < rows; ++i) { if (i != 0) writeRowBetweenDelimiter(); writeRowStartDelimiter(); for (size_t j = 0; j < columns; ++j) { if (j != 0) writeFieldDelimiter(); writeField(*extremes.getByPosition(j).column.get(), *extremes.getByPosition(j).type.get(), i); } writeRowEndDelimiter(); } } }
void VerticalRowOutputStream::writeSpecialRow(const Block & block, size_t row_num, const char * title) { writeCString("\n", ostr); row_number = 0; field_number = 0; size_t columns = block.columns(); writeCString(title, ostr); writeCString(":\n", ostr); size_t width = strlen(title) + 1; for (size_t i = 0; i < width; ++i) writeCString("─", ostr); writeChar('\n', ostr); for (size_t i = 0; i < columns; ++i) { if (i != 0) writeFieldDelimiter(); auto & col = block.getByPosition(i); writeField(*col.column, *col.type, row_num); } }
bool Nuria::Serializer::populateImpl (void *object, Nuria::MetaObject *meta, const QVariantMap &data) { this->d->curDepth--; if (!this->d->curDepth) { this->d->curDepth++; return false; } // int fields = meta->fieldCount (); for (int i = 0; i < fields; i++) { MetaField field = meta->field (i); bool ignore = std::binary_search (this->d->excluded.constBegin (), this->d->excluded.constEnd (), field.name ()); if (!ignore && !writeField (object, field, data)) { this->d->failed.append (field.name ()); } } this->d->curDepth++; return this->d->failed.isEmpty (); }
void RTBinaryMessage::setMessage(QByteArray &buffer) { QDataStream stream(&buffer, QIODevice::WriteOnly); stream.setByteOrder((_littleEndian) ? QDataStream::LittleEndian : QDataStream::BigEndian); uint written = 0; for (const Field &field : _fields) { written += writeField(stream, field, written); } }
bool QSqlForm::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: readField((QWidget*)static_QUType_ptr.get(_o+1)); break; case 1: writeField((QWidget*)static_QUType_ptr.get(_o+1)); break; case 2: readFields(); break; case 3: writeFields(); break; case 4: clear(); break; case 5: clearValues(); break; case 6: clearValues((bool)static_QUType_bool.get(_o+1)); break; default: return QObject::qt_invoke( _id, _o ); } return TRUE; }
/// @brief /// @todo Doc me! void run() { // Initial saturation. std::vector<double> saturation(this->init_saturation_); std::vector<double> saturation_old(saturation); // Gravity. // Dune::FieldVector<double, 3> gravity(0.0); // gravity[2] = -Dune::unit::gravity; // Compute flow field. if (this->gravity_.two_norm() > 0.0) { MESSAGE("Warning: Gravity not handled by flow solver."); } // Solve some steps. for (int i = 0; i < this->simulation_steps_; ++i) { std::cout << "\n\n================ Simulation step number " << i << " ===============" << std::endl; // Flow. this->flow_solver_.solve(this->res_prop_, saturation, this->bcond_, this->injection_rates_psolver_, this->residual_tolerance_, this->linsolver_verbosity_, this->linsolver_type_); // if (i == 0) { // flow_solver_.printSystem("linsys_dump_mimetic"); // } // Transport. this->transport_solver_.transportSolve(saturation, this->stepsize_, this->gravity_, this->flow_solver_.getSolution(), this->injection_rates_); // Output. writeVtkOutput(this->ginterf_, this->res_prop_, this->flow_solver_.getSolution(), saturation, "testsolution-" + boost::lexical_cast<std::string>(i)); writeField(saturation, "saturation-" + boost::lexical_cast<std::string>(i)); // Comparing old to new. int num_cells = saturation.size(); double maxdiff = 0.0; for (int i = 0; i < num_cells; ++i) { maxdiff = std::max(maxdiff, std::fabs(saturation[i] - saturation_old[i])); } std::cout << "Maximum saturation change: " << maxdiff << std::endl; // Copy to old. saturation_old = saturation; } }
void IRowOutputStream::write(const Block & block, size_t row_num) { size_t columns = block.columns(); writeRowStartDelimiter(); for (size_t i = 0; i < columns; ++i) { if (i != 0) writeFieldDelimiter(); auto & col = block.getByPosition(i); writeField(*col.column, *col.type, row_num); } writeRowEndDelimiter(); }
int writeBufToFile(std::string outfilename, byte* buf, int fieldSizeX, int fieldSizeY) #endif { std::ofstream outf; #ifdef MEASUREMENTS outf.open((outfilename+postfix).c_str()); //< write to file #else outf.open(outfilename.c_str()); //< write to file #endif if (outf) { // print to file without a 1-wide margin writeField(buf,fieldSizeX+2,fieldSizeY+2,1,outf); outf.close(); } return 0; }
void MetadataReader::doTRE(const std::string& key, ::nitf::TRE& tre) { const std::string& tag = key + "." + tre.getTag(); // The C interface to nitro has a TREDescription object which // (I think) allows you to enumerate the keys in the // TRE. However, there is no C++ interface for it, so instead // we will use the raw iterator to access each (Key,Value) // pair. we won't use the Value from pair.second() directly, // however: instead, we'll call getField(key) and get the // value as represented by a Field object (which will tell us // the formatting, etc). ::nitf::TREFieldIterator iter = tre.begin(); while (iter != tre.end()) { try { // nitro will explicitly throw when dereferencing iter // if there's no pair object set (would be nice if // there was a is_valid() function or something...) ::nitf::Pair pair = *iter; const char* key = pair.first(); // only put into metadata things that look like legit // stringy things if (strcmp(key, "raw_data") != 0) { ::nitf::Field field = tre.getField(key); writeField(tag, key, field); } } catch (::except::NullPointerReference&) { // oh, well - skip this one, go to the next iteration } ++iter; } return; }
void TabSeparatedRowOutputStream::writeTotals() { if (totals) { size_t columns = totals.columns(); writeChar('\n', ostr); writeRowStartDelimiter(); for (size_t j = 0; j < columns; ++j) { if (j != 0) writeFieldDelimiter(); writeField(*totals.getByPosition(j).column.get(), *totals.getByPosition(j).type.get(), 0); } writeRowEndDelimiter(); } }
void MetadataReader::doComments(const std::string& key, ::nitf::List& list) { int i = 0; ::nitf::ListIterator iter = list.begin(); while (iter != list.end()) { ::nitf::Field field = *iter; const std::string subkey = "ICOM:" + std::to_string(i); writeField(key, subkey, field); ++i; ++iter; } return; }
void MetadataReader::doBand(const std::string& key, ::nitf::BandInfo& band) { writeField(key, "IREPBAND", band.getRepresentation()); writeField(key, "ISUBCAT", band.getSubcategory()); writeField(key, "IFC", band.getImageFilterCondition()); writeField(key, "IMFLT", band.getImageFilterCode()); writeField(key, "NLUTS", band.getNumLUTs()); writeField(key, "NELUT", band.getBandEntriesPerLUT()); ::nitf::LookupTable lut = band.getLookupTable(); writeInt(key, "num_lookup_tables", lut.getTables()); writeInt(key, "num_lookup_entries", lut.getEntries()); }
IOManager3D<B,F>::IOManager3D(const SimulationEvaluator3D<B,F> &_evaluator, string _path): evaluator(_evaluator), simulator(_evaluator.getSimulator()) { unsigned u = 0; if (boost::filesystem::is_directory(_path)) { while (boost::filesystem::is_directory(_path + util::num2str(u))) u++; cerr << "Directory " << _path << " already exists, creating " << _path + util::num2str(u) << endl; _path = _path + util::num2str(u); } boost::filesystem::create_directory(_path); this->path = _path + "/"; printInfo(cout); writeConfigurationFile (path + "config.cfg"); writeCapillaryConfiguration (path + "capillary_configuration.csv"); writeSequenceConfiguration (path + "sequence_configuration.csv"); writeField (path + "field_configuration.csv"); writeSampleTrajectory (path + "sample_trajectories.csv"); writeCollisionTree (path + "collision_tree.csv"); }
// pat added: write an Optional Field controlled by an initial 0/1 field. void MsgCommonWrite::writeOptField01(uint64_t value, unsigned len, int present, const char*) { if (present) { write1(); writeField(value,len); } else { write0(); } }
void BinWriter::writeClass(json_t *jclass) { writeMemberInfo(jclass); // handle class modifiers json_t *attr_array = json_object_get(jclass, "classattributes"); bytes.writeInt((int)json_array_size(attr_array)); for (size_t i = 0; i < json_array_size(attr_array); i++) { bytes.writeInt((int)poolJString(json_array_get(attr_array, i))); } // base class int ibaseType = -1; utString sbaseType = json_string_value( json_object_get(jclass, "baseType")); if (sbaseType.size() > 0) { ibaseType = poolString(sbaseType.c_str()); } bytes.writeInt(ibaseType); // interfaces json_t *jinterfaces = json_object_get(jclass, "interfaces"); bytes.writeInt((int)json_array_size(jinterfaces)); for (size_t i = 0; i < json_array_size(jinterfaces); i++) { json_t *o = json_array_get(jinterfaces, i); bytes.writeInt(poolString(json_string_value(o))); } // delegate types json_t *jdelegate_types = json_object_get(jclass, "delegateTypes"); bytes.writeInt((int)json_array_size(jdelegate_types)); for (size_t i = 0; i < json_array_size(jdelegate_types); i++) { json_t *o = json_array_get(jdelegate_types, i); bytes.writeInt(poolString(json_string_value(o))); } // delegate return type int idelegatereturntype = -1; utString sdelegateReturnType = json_string_value( json_object_get(jclass, "delegateReturnType")); if (sdelegateReturnType.size() > 0) { idelegatereturntype = poolString(sdelegateReturnType.c_str()); } bytes.writeInt(idelegatereturntype); // write imports json_t *import_array = json_object_get(jclass, "imports"); bytes.writeInt((int)json_array_size(import_array)); for (size_t i = 0; i < json_array_size(import_array); i++) { json_t *jimport = json_array_get(import_array, i); bytes.writeInt(poolString(json_string_value(jimport))); } // write constructor json_t *jconstructor = json_object_get(jclass, "constructor"); if (jconstructor) { bytes.writeBoolean(true); writeConstructor(jconstructor); } else { bytes.writeBoolean(false); } // write fields json_t *field_array = json_object_get(jclass, "fields"); bytes.writeInt((int)json_array_size(field_array)); for (size_t i = 0; i < json_array_size(field_array); i++) { json_t *fo = json_array_get(field_array, i); writeField(fo); } // write properties json_t *prop_array = json_object_get(jclass, "properties"); bytes.writeInt((int)json_array_size(prop_array)); for (size_t i = 0; i < json_array_size(prop_array); i++) { json_t *po = json_array_get(prop_array, i); writeProperty(po); } // write methods json_t *method_array = json_object_get(jclass, "methods"); bytes.writeInt((int)json_array_size(method_array)); for (size_t i = 0; i < json_array_size(method_array); i++) { json_t *jmethod = json_array_get(method_array, i); writeMethodInfo(jmethod); } // static initializer byte code utString bc = json_string_value(json_object_get(jclass, "bytecode_staticinitializer")); bytes.writeString(bc.c_str()); // instance initializer byte code bc = json_string_value(json_object_get(jclass, "bytecode_instanceinitializer")); bytes.writeString(bc.c_str()); }
inline void save(std::ostream &out, const int &data, char delim) { writeField(out, data, delim); }
void MetadataReader::doImageSubheader(const std::string& key, ::nitf::ImageSubheader& subheader) { writeField(key, "IID1", subheader.getImageId()); writeField(key, "IDATIM", subheader.getImageDateAndTime()); writeField(key, "TGTID", subheader.getTargetId()); writeField(key, "IID2", subheader.getImageTitle()); writeField(key, "ISCLAS", subheader.getImageSecurityClass()); ::nitf::FileSecurity security = subheader.getSecurityGroup(); doSecurity(key, "I", security); writeField(key, "ENCRYP", subheader.getEncrypted()); writeField(key, "ISORCE", subheader.getImageSource()); writeField(key, "NROWS", subheader.getNumRows()); writeField(key, "NCOLS", subheader.getNumCols()); writeField(key, "PVTYPE", subheader.getPixelValueType()); writeField(key, "IREP", subheader.getImageRepresentation()); writeField(key, "ICAT", subheader.getImageCategory()); writeField(key, "ABPP", subheader.getActualBitsPerPixel()); writeField(key, "PJUST", subheader.getPixelJustification()); writeField(key, "ICORDS", subheader.getImageCoordinateSystem()); writeField(key, "IGEOLO", subheader.getCornerCoordinates()); writeField(key, "NICOM", subheader.getNumImageComments()); ::nitf::List list = subheader.getImageComments(); doComments(key, list); writeField(key, "IC", subheader.getImageCompression()); writeField(key, "COMRAT", subheader.getCompressionRate()); writeField(key, "NBANDS", subheader.getNumImageBands()); writeField(key, "XBANDS", subheader.getNumMultispectralImageBands()); doBands(key, subheader); writeField(key, "ISYNC", subheader.getImageSyncCode()); writeField(key, "IMODE", subheader.getImageMode()); writeField(key, "NBPR", subheader.getNumBlocksPerRow()); writeField(key, "NBPC", subheader.getNumBlocksPerCol()); writeField(key, "NPPBH", subheader.getNumPixelsPerHorizBlock()); writeField(key, "NPPVB", subheader.getNumPixelsPerVertBlock()); writeField(key, "NBPP", subheader.getNumBitsPerPixel()); writeField(key, "IDLVL", subheader.getImageDisplayLevel()); writeField(key, "IALVL", subheader.getImageAttachmentLevel()); writeField(key, "ILOC", subheader.getImageLocation()); writeField(key, "IMAG", subheader.getImageMagnification()); }
void MetadataReader::doSecurity(const std::string& parentkey, const std::string& prefix, ::nitf::FileSecurity& security) { writeField(parentkey, prefix + "SCLSY", security.getClassificationSystem()); writeField(parentkey, prefix + "SCODE", security.getCodewords()); writeField(parentkey, prefix + "SCTLH", security.getControlAndHandling()); writeField(parentkey, prefix + "SREL", security.getReleasingInstructions()); writeField(parentkey, prefix + "SDCTP", security.getDeclassificationType()); writeField(parentkey, prefix + "SDCDT", security.getDeclassificationDate()); writeField(parentkey, prefix + "SDCXM", security.getDeclassificationExemption()); writeField(parentkey, prefix + "SDG", security.getDowngrade()); writeField(parentkey, prefix + "SDGDT", security.getDowngradeDateTime()); writeField(parentkey, prefix + "SCLTX", security.getClassificationText()); writeField(parentkey, prefix + "SCATP", security.getClassificationAuthorityType()); writeField(parentkey, prefix + "SCAUT", security.getClassificationAuthority()); writeField(parentkey, prefix + "SCRSN", security.getClassificationReason()); writeField(parentkey, prefix + "SSRDT", security.getSecuritySourceDate()); writeField(parentkey, prefix + "SCTLN", security.getSecurityControlNumber()); }
void MetadataReader::doFileHeader(const std::string& parentkey, ::nitf::FileHeader& header) { writeField("FH", "FHDR", header.getFileHeader()); writeField("FH", "FVER", header.getFileVersion()); writeField("FH", "CLEVEL", header.getComplianceLevel()); writeField("FH", "STYPE", header.getSystemType()); writeField("FH", "OSTAID", header.getOriginStationID()); writeField("FH", "FDT", header.getFileDateTime()); writeField("FH", "FTITLE", header.getFileTitle()); writeField("FH", "FSCLAS", header.getClassification()); writeField("FH", "FSCOP", header.getMessageCopyNum()); writeField("FH", "FSCPYS", header.getMessageNumCopies()); writeField("FH", "ENCRYP", header.getEncrypted()); writeField("FH", "FBKGC", header.getBackgroundColor()); writeField("FH", "ONAME", header.getOriginatorName()); writeField("FH", "OPHONE", header.getOriginatorPhone()); writeField("FH", "FL", header.getFileLength()); writeField("FH", "HL", header.getHeaderLength()); writeField("FH", "NUMI", header.getNumImages()); writeField("FH", "NUMS", header.getNumGraphics()); //writeField("FH", "???", header.getNumLabels()); //unsupported in 2500c spec writeField("FH", "NUMT", header.getNumTexts()); writeField("FH", "NUMDES", header.getNumDataExtensions()); writeField("FH", "NUMRES", header.getNumReservedExtensions()); }
void FreezerBase::setState(const State state_) const { do { writeField("state", state_); } while (state() != state_); }
void MsgCommonWrite::writeBitMap(bool*bitmap,unsigned bitmaplen, const char*name) { for (unsigned i=0; i<bitmaplen; i++) { writeField(bitmap[i],1,name); } }
int32_t Serializer::writeTable(const std::string parentKey) { // Handle cycles for (const auto &table : _tblMap) { lua_rawgeti(_L, LUA_REGISTRYINDEX, table.first); if (lua_equal(_L, -1, -2)) { // Maybe a cycle... lua_pop(_L, 1); if (!writeField(parentKey, table.second)) return -1; return 1; } else lua_pop(_L, 1); } { // Store this table lua_pushvalue(_L, -1); int ref = luaL_ref(_L, LUA_REGISTRYINDEX); _tblMap[ref] = parentKey; } lua_pushnil(_L); int32_t numFields = 0; while (lua_next(_L, -2) != 0) { if (!lua_isstring(_L, -2)) { lua_pop(_L, 1); continue; } std::string val; std::string fullKey = parentKey + '['; if (lua_type(_L, -2) == LUA_TSTRING) fullKey += '"'; lua_pushvalue(_L, -2); fullKey += lua_tostring(_L, -1); lua_pop(_L, 1); if (lua_type(_L, -2) == LUA_TSTRING) fullKey += '"'; fullKey += ']'; switch (lua_type(_L, -1)) { case LUA_TTABLE: { int32_t numNewFields = writeTable(fullKey); if (numNewFields < 0) return -1; numFields += numNewFields; lua_pop(_L, 1); continue; } case LUA_TBOOLEAN: { val = lua_toboolean(_L, -1) ? "true" : "false"; break; } case LUA_TSTRING: val += '"'; // Fallthrough case LUA_TNUMBER: { val += lua_tostring(_L, -1); if (val[0] == '"') val += '"'; break; } default: { lua_pop(_L, 1); continue; } } if (!writeField(fullKey, val)) return -1; numFields++; lua_pop(_L, 1); } return numFields; }
void MsgCommonWrite::writeL() { unsigned fillBit = fillPattern[wp%8]; // wp is in MsgCommon writeField(fillBit,1); }