IptcCoreLocationInfo ItemExtendedProperties::location() { IptcCoreLocationInfo location; location.country = readProperty(ItemScanner::iptcCorePropertyName(MetadataInfo::IptcCoreCountry)); location.countryCode = readProperty(ItemScanner::iptcCorePropertyName(MetadataInfo::IptcCoreCountryCode)); location.city = readProperty(ItemScanner::iptcCorePropertyName(MetadataInfo::IptcCoreCity)); location.location = readProperty(ItemScanner::iptcCorePropertyName(MetadataInfo::IptcCoreLocation)); location.provinceState = readProperty(ItemScanner::iptcCorePropertyName(MetadataInfo::IptcCoreProvinceState)); return location; }
bool Ambitus::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "head") readProperty(e, Pid::HEAD_GROUP); else if (tag == "headType") readProperty(e, Pid::HEAD_TYPE); else if (tag == "mirror") readProperty(e, Pid::MIRROR_HEAD); else if (tag == "hasLine") setHasLine(e.readInt()); else if (tag == "lineWidth") readProperty(e, Pid::LINE_WIDTH); else if (tag == "topPitch") _topPitch = e.readInt(); else if (tag == "bottomPitch") _bottomPitch = e.readInt(); else if (tag == "topTpc") _topTpc = e.readInt(); else if (tag == "bottomTpc") _bottomTpc = e.readInt(); else if (tag == "topAccidental") { while (e.readNextStartElement()) { if (e.name() == "Accidental") { if (score()->mscVersion() < 301) readAccidental206(&_topAccid, e); else _topAccid.read(e); } else e.skipCurrentElement(); } } else if (tag == "bottomAccidental") { while (e.readNextStartElement()) { if (e.name() == "Accidental") { if (score()->mscVersion() < 301) readAccidental206(&_bottomAccid, e); else _bottomAccid.read(e); } else e.skipCurrentElement(); } } else if (Element::readProperties(e)) ; else return false; return true; }
std::string project() const { if (!empty()) return readProperty("project"); else return std::string(); }
std::string rVersionHome() { if (!empty()) return readProperty("r-version-home"); else return std::string(); }
std::string workingDir() const { if (!empty()) return readProperty("working-dir"); else return std::string(); }
/** Funkcja na podstawie podanego jako parametr jezyka wczytuje komunikaty * w danym jezyku. Domyslnie jest to ANG. Komunikaty sa przechowywane w * tablicy asocjacyjnej w bierzacej klasie. Komunikatow pobranych z propertys nalezy uzywac * w calej aplikacji. ZAKAZUJE SIE UZYWANIE STRINGOW NA SZTYWNO W KODZIE! * @param string : Jezyk jaki bedzie ustawiony w grze, jest to zarazem koncowka w nazwie pliku ( data/property_xxx ) */ void Property::init( const string& Languages ) { pLanguages = Languages; readSettings(); readProperty(); }
void MaterialEditDialog::readMaterial() { if (QFile::exists(m_fileName)) { std::auto_ptr<XMLMaterial::material> material_xsd; material_xsd = XMLMaterial::material_(compatibleFilename(m_fileName).toStdString(), xml_schema::flags::dont_validate); XMLMaterial::material *material = material_xsd.get(); txtName->setText(QString::fromStdString(material->general().name())); if (material->general().description().present()) txtDescription->setText(QString::fromStdString(material->general().description().get())); m_properties.clear(); lstProperties->clear(); // properties for (unsigned int i = 0; i < material->properties().property().size(); i++) { XMLMaterial::property prop = material->properties().property().at(i); m_properties.append(prop); // item QListWidgetItem *item = new QListWidgetItem(lstProperties); item->setText(QString::fromStdString(prop.name())); item->setData(Qt::UserRole, lstProperties->count() - 1); lstProperties->addItem(item); } propertyGUI->setEnabled(lstProperties->count() > 0); btnDeleteProperty->setEnabled(lstProperties->count() > 0); if (lstProperties->count() > 0) { lstProperties->setCurrentRow(0); readProperty(m_properties.at(0)); } else { readProperty(); } } }
bool TextLineBase::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); for (P_ID i :pids) { if (readProperty(tag, e, i)) { setPropertyFlags(i, PropertyFlags::UNSTYLED); return true; } } return SLine::readProperties(e); }
void SimpleAbstractStreamReader::readProperties(AST::UiObjectDefinition *uiObjectDefinition) { Q_ASSERT(uiObjectDefinition); for (AST::UiObjectMemberList *it = uiObjectDefinition->initializer->members; it; it = it->next) { AST::UiObjectMember *member = it->member; AST::UiScriptBinding *scriptBinding = AST::cast<AST::UiScriptBinding *>(member); if (scriptBinding) readProperty(scriptBinding); } }
bool savePromptRequired() const { if (!empty()) { std::string value = readProperty("save_prompt_required"); if (!value.empty()) return safe_convert::stringTo<bool>(value, false); else return false; } else return false; }
bool executing() const { if (!empty()) { std::string value = readProperty("executing"); if (!value.empty()) return safe_convert::stringTo<bool>(value, false); else return false; } else return false; }
bool initial() const { if (!empty()) { std::string value = readProperty("initial"); if (!value.empty()) return safe_convert::stringTo<bool>(value, false); else return false; } else return false; }
double lastUsed() const { if (!empty()) { std::string value = readProperty("last-used"); if (!value.empty()) return safe_convert::stringTo<double>(value, 0); else return 0; } else { return 0; } }
inline bool Json::next(const JsonValue& _current, JsonValue& _next) { m_readPos = m_fileContent.data() + _current.offset; // Iterate through the stream to the next ','. Meanwhile the number of // brackets ({} and []) must match. int parenthesis = 0; do { if(!readToken()) return false; if(m_tokenPos[0] == '{' || m_tokenPos[0] == '[') ++parenthesis; else if(m_tokenPos[0] == '}' || m_tokenPos[0] == ']') --parenthesis; } while(parenthesis > 0 || m_tokenPos[0] != ','); if(parenthesis < 0) return false; readProperty(_next); return true; }
bool Reader::accessProperty(PropertyInfo& p) { Request r = property(stringFromId(p.name), stringFromId(p.interpretation), p); p.requested = r.m_want; p.propertyData = r.m_data; if (p.requested) { seekTo(p); readProperty(p); } return true; }
bool Reader::readBinaryGTO() { readIndexTable(); // OK to continue if this fails readHeader(); if (m_error) return false; readStringTable(); if (m_error) return false; readObjects(); if (m_error) return false; readComponents(); if (m_error) return false; readProperties(); if (m_error) return false; descriptionComplete(); if (m_mode & HeaderOnly) { return true; } Properties::iterator p = m_properties.begin(); for (Components::iterator i = m_components.begin(); i != m_components.end(); ++i) { ComponentInfo &comp = *i; if (comp.flags & Gto::Transposed) { cerr << "ERROR: Transposed data for '" << stringFromId( comp.object->name ) << "." << stringFromId( comp.name ) << "' is currently unsupported." << endl; abort(); } else { for (Properties::iterator e = p + comp.numProperties; p != e; ++p) { if (!readProperty(*p)) { return false; } } } } return true; }
void LayoutBreak::read(XmlReader& e) { while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "subtype") readProperty(e, Pid::LAYOUT_BREAK); else if (tag == "pause") _pause = e.readDouble(); else if (tag == "startWithLongNames") _startWithLongNames = e.readInt(); else if (tag == "startWithMeasureOne") _startWithMeasureOne = e.readInt(); else if (!Element::readProperties(e)) e.unknown(); } layout0(); }
inline bool Json::child(const JsonValue& _current, JsonValue& _next) { m_readPos = m_fileContent.data() + _current.offset; if(!readToken()) return false; if(_current.type == JsonValue::Type::ARRAY) { // Next token is '[' otherwise the type would have been wrong if(m_tokenPos[0] != '[') return false; // Read array value directly if(!readToken()) return false; return readValue(_next); } else if( _current.type == JsonValue::Type::OBJECT) { // Next token is '{' otherwise the type would have been wrong if(m_tokenPos[0] != '{') return false; // Subobject has a property list return readProperty(_next); } return false; }
void Trill::read(XmlReader& e) { eraseSpannerSegments(); while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "subtype") setTrillType(e.readElementText()); else if (tag == "Accidental") { _accidental = new Accidental(score()); _accidental->read(e); _accidental->setParent(this); } else if ( tag == "ornamentStyle") readProperty(e, Pid::ORNAMENT_STYLE); else if ( tag == "play") setPlayArticulation(e.readBool()); else if (!SLine::readProperties(e)) e.unknown(); } }
bool Articulation::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "subtype") { QString s = e.readElementText(); SymId id = Sym::name2id(s); if (id == SymId::noSym) id = oldArticulationNames2SymId(s); // compatibility hack for "old" 3.0 scores setSymId(id); } else if (tag == "channel") { _channelName = e.attribute("name"); e.readNext(); } else if (tag == "anchor") _anchor = ArticulationAnchor(e.readInt()); else if (tag == "direction") readProperty(e, P_ID::DIRECTION); else if ( tag == "ornamentStyle") setProperty(P_ID::ORNAMENT_STYLE, Ms::getProperty(P_ID::ORNAMENT_STYLE, e)); else if ( tag == "play") setPlayArticulation(e.readBool()); else if (tag == "timeStretch") _timeStretch = e.readDouble(); else if (tag == "offset") { if (score()->mscVersion() > 114) Element::readProperties(e); else e.skipCurrentElement(); // ignore manual layout in older scores } else if (Element::readProperties(e)) ; else return false; return true; }
bool UltMtgReader::readEntity(MtgEntity& entity) { string entityType; string entityValue; unsigned int entityWeight; string entityAdditionalSearchTerm; unsigned int propertyCount; unsigned int generatorCount; unsigned char majorv; unsigned char minorv; if(!_unserializer->readByte(majorv)) return false; if(!_unserializer->readByte(minorv)) return false; if(majorv != 1 || minorv != 0) return false; if(!_unserializer->readString(entityType)) return false; if(!_unserializer->readString(entityValue)) return false; if(!_unserializer->readInt(entityWeight)) return false; if(!_unserializer->readString(entityAdditionalSearchTerm)) return false; entity._version = "1.0"; entity._type = QString::fromStdString(entityType); entity._value = QString::fromStdString(entityValue); entity._weight = entityWeight; entity._additionalSearchTerm = QString::fromStdString(entityAdditionalSearchTerm); //Properties if(!_unserializer->readInt(propertyCount)) return false; for(unsigned int i(0); i<propertyCount; ++i) { MtgProperty property; if(!readProperty(property)) { qCritical("[x] readProperty failed"); return false; } entity._propertyHash.insert(property.name,property); } //Generators if(!_unserializer->readInt(generatorCount)) return false; for(unsigned int i(0); i<generatorCount; ++i) { MtgGenerator generator; if(!readGenerator(generator)) { qCritical("[x] readGenerator failed"); return false; } entity._generatorList.append(generator); } unsigned char byte; _unserializer->readByte(byte); if(byte != 2) // bourrage { qCritical("pronostic failed %x",byte); return false; } unsigned char majorversion; _unserializer->readByte(majorversion); unsigned char minorversion; _unserializer->readByte(minorversion); if(majorversion != 1 && minorversion != 0) //major & minor version ? return false; double x,y; _unserializer->readDouble(x); _unserializer->readDouble(y); entity._posx = x; entity._posy = y; if(_obfuscationByte) { if(!_unserializer->readByte(byte)) return false; } return true; }
QString ItemExtendedProperties::jobId() { return readProperty(ItemScanner::iptcCorePropertyName(MetadataInfo::IptcCoreJobID)); }
QString ItemExtendedProperties::intellectualGenre() { return readProperty(ItemScanner::iptcCorePropertyName(MetadataInfo::IptcCoreIntellectualGenre)); }
IsoMediaFile::Content WriterConfig::readContent(const Json::Value& contentValues) const { IsoMediaFile::Content newContent; /// @todo Throw an exception if a content does not have the master. // The Content.Master parameters const Json::Value& masterValues = contentValues["master"]; newContent.master.uniq_bsid = readOptionalUint(masterValues["uniq_bsid"]); newContent.master.make_vide = readBool(masterValues["make_vide"], false); newContent.master.file_path = masterValues["file_path"].asString(); newContent.master.hdlr_type = masterValues["hdlr_type"].asString(); newContent.master.code_type = masterValues["code_type"].asString(); newContent.master.encp_type = masterValues["encp_type"].asString(); newContent.master.disp_xdim = readUint32(masterValues, "disp_xdim"); newContent.master.disp_ydim = readUint32(masterValues, "disp_ydim"); newContent.master.disp_rate = readOptionalUint(masterValues["disp_rate"], 0); newContent.master.tick_rate = readOptionalUint(masterValues["tick_rate"], 90000); // If content master has an edit list file if (masterValues["edit_file"].asString() != "") { readEditList(masterValues["edit_file"].asString(), newContent.master); } // The Content.Thumb parameters for (const auto& thumb : contentValues["thumbs"]) { IsoMediaFile::Thumbs newThumb; newThumb.uniq_bsid = readOptionalUint(thumb["uniq_bsid"]); newThumb.file_path = thumb["file_path"].asString(); newThumb.hdlr_type = thumb["hdlr_type"].asString(); newThumb.code_type = thumb["code_type"].asString(); newThumb.disp_xdim = readUint32(thumb, "disp_xdim"); newThumb.disp_ydim = readUint32(thumb, "disp_ydim"); newThumb.tick_rate = readOptionalUint(thumb["tick_rate"], 90000); newThumb.sync_rate = readOptionalUint(thumb["sync_rate"], 0); const Json::Value syncidxs_array = thumb["sync_idxs"]; for (const auto& synxIndex : syncidxs_array) { newThumb.sync_idxs.push_back(std::stoi(synxIndex.asString())); } // If this thumbs has an edit list file if (thumb["edit_file"].asString() != "") { readEditList(thumb["edit_file"].asString(), newThumb); } newContent.thumbs.push_back(newThumb); } for (const auto& metadata : contentValues["metadata"]) { IsoMediaFile::Metadata newMetadata; newMetadata.file_path = metadata["file_path"].asString(); newMetadata.hdlr_type = metadata["hdlr_type"].asString(); newContent.metadata.push_back(newMetadata); } const Json::Value& derivedValues = contentValues["derived"]; if (not derivedValues.isNull()) { IsoMediaFile::Derived newDerived; IsoMediaFile::Property newProperty; for (const auto& irot : derivedValues["irot"]) { IsoMediaFile::Irot newIrot; newIrot.angle = readUint32(irot, "angle"); newIrot.uniq_bsid = readOptionalUint(irot["uniq_bsid"]); newIrot.refs_list = parseRefsList(irot["refs_list"]); newIrot.idxs_list = parseIndexList(irot["idxs_list"]); newDerived.irots.push_back(newIrot); } for (const auto& rloc : derivedValues["rloc"]) { IsoMediaFile::Rloc newRloc; newRloc.horizontal_offset = readUint32(rloc, "horizontal_offset"); newRloc.vertical_offset = readUint32(rloc, "vertical_offset"); newRloc.uniq_bsid = readOptionalUint(rloc["uniq_bsid"]); newRloc.refs_list = parseRefsList(rloc["refs_list"]); newRloc.idxs_list = parseIndexList(rloc["idxs_list"]); newDerived.rlocs.push_back(newRloc); } for (const auto& clap : derivedValues["clap"]) { IsoMediaFile::Clap newClap; newClap.clapWidthN = readUint32(clap, "clapWidthN"); newClap.clapWidthD = readUint32(clap, "clapWidthD"); newClap.clapHeightN = readUint32(clap, "clapHeightN"); newClap.clapHeightD = readUint32(clap, "clapHeightD"); newClap.horizOffN = readUint32(clap, "horizOffN"); newClap.horizOffD = readUint32(clap, "horizOffD"); newClap.vertOffN = readUint32(clap, "vertOffN"); newClap.vertOffD = readUint32(clap, "vertOffD"); newClap.uniq_bsid = readUint32(clap, "uniq_bsid"); newClap.refs_list = parseRefsList(clap["refs_list"]); newClap.idxs_list = parseIndexList(clap["idxs_list"]); newDerived.claps.push_back(newClap); } for (const auto& prederived : derivedValues["pre-derived"]) { IsoMediaFile::PreDerived newPreDerived; newPreDerived.uniq_bsid = readUint32(prederived, "uniq_bsid"); newPreDerived.pre_refs_list = parseRefsList(prederived["pre_refs_list"]); newPreDerived.pre_idxs_list = parseIndexList(prederived["pre_idxs_list"]); newPreDerived.base_refs_list = parseRefsList(prederived["base_refs_list"]); newPreDerived.base_idxs_list = parseIndexList(prederived["base_idxs_list"]); newDerived.prederiveds.push_back(newPreDerived); } for (const auto& grid : derivedValues["grid"]) { IsoMediaFile::Grid newGrid; newGrid.columns = readUint32(grid, "columns"); newGrid.outputHeight = readUint32(grid, "output_height"); newGrid.outputWidth = readUint32(grid, "output_width"); newGrid.rows = readUint32(grid, "rows"); newGrid.uniq_bsid = readUint32(grid, "uniq_bsid"); for (const auto& reference : grid["refs_list"]) { newGrid.refs_list.push_back(std::stoi(reference.asString())); } for (const auto& idxsList : grid["idxs_list"]) { std::vector<std::uint32_t> idxListEntries; for (const auto& index : idxsList) { idxListEntries.push_back(std::stoi(index.asString())); } newGrid.idxs_list.push_back(idxListEntries); } newDerived.grids.push_back(newGrid); } for (const auto& iovl : derivedValues["iovl"]) { IsoMediaFile::Iovl newIovl; newIovl.outputHeight = readUint32(iovl, "output_height"); newIovl.outputWidth = readUint32(iovl, "output_width"); newIovl.uniq_bsid = readUint32(iovl, "uniq_bsid"); for (const auto& canvasFill : iovl["canvas_fill"]) { newIovl.canvasFillValue.push_back(std::stoi(canvasFill.asString())); } if (newIovl.canvasFillValue.size() != 4) { throw std::runtime_error("Invalid iovl canvas_fill"); } for (const auto& reference : iovl["refs_list"]) { newIovl.refs_list.push_back(std::stoi(reference.asString())); } for (const auto& idxsList : iovl["idxs_list"]) { std::vector<std::uint32_t> idxListEntries; for (const auto& index : idxsList) { idxListEntries.push_back(std::stoi(index.asString())); } newIovl.idxs_list.push_back(idxListEntries); } for (const auto& offset : iovl["offsets"]) { IsoMediaFile::Iovl::Offset newOffset; newOffset.horizontal = std::stoi(offset[0].asString()); ///< @todo Check that this is the intended order newOffset.vertical = std::stoi(offset[1].asString()); ///< @todo Check that this is the intended order newIovl.offsets.push_back(newOffset); } newDerived.iovls.push_back(newIovl); } /// @todo Add other derived image types as well. newContent.derived = newDerived; } newContent.property = readProperty(contentValues["property"]); for (const auto& auxiliary : contentValues["auxiliary"]) { newContent.auxiliary.push_back(readAuxiliary(auxiliary)); } return newContent; }
void Image::read(XmlReader& e) { if (score()->mscVersion() <= 114) _sizeIsSpatium = false; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "autoScale") readProperty(e, Pid::AUTOSCALE); else if (tag == "size") readProperty(e, Pid::SIZE); else if (tag == "lockAspectRatio") readProperty(e, Pid::LOCK_ASPECT_RATIO); else if (tag == "sizeIsSpatium") // setting this using the property Pid::SIZE_IS_SPATIUM breaks, because the // property setter attempts to maintain a constant size. If we're reading, we // don't want to do that, because the stored size will be in: // mm if size isn't spatium // sp if size is spatium _sizeIsSpatium = e.readBool(); else if (tag == "path") _storePath = e.readElementText(); else if (tag == "linkPath") _linkPath = e.readElementText(); else if (tag == "subtype") // obsolete e.skipCurrentElement(); else if (!BSymbol::readProperties(e)) e.unknown(); } // once all paths are read, load img or retrieve it from store // loading from file is tried first to update the stored image, if necessary qDebug("linkPath <%s>", qPrintable(_linkPath)); qDebug("storePath <%s>", qPrintable(_storePath)); QString path; bool loaded = false; // if a store path is given, attempt to get the image from the store if (!_storePath.isEmpty()) { _storeItem = imageStore.getImage(_storePath); if (_storeItem) { _storeItem->reference(this); loaded = true; } // if no image in store, attempt to load from path (for backward compatibility) else loaded = load(_storePath); path = _storePath; } // if no success from store path, attempt loading from link path (for .mscx files) if (!loaded) { _linkIsValid = load(_linkPath); path = _linkPath; } if (path.endsWith(".svg")) setImageType(ImageType::SVG); else setImageType(ImageType::RASTER); }
/* \overload */ QVariant DomTool::readProperty(const QDomElement& e, const QString& name, const QVariant& defValue) { QString comment; return readProperty(e, name, defValue, comment); }
void Property::resetLang(string Languages){ pLanguages = Languages; property.clear(); readProperty(); }
void BinReader::readClass(Type *type) { readMemberInfo(type); MetaInfo *meta = type->getMetaInfo("Native"); if (meta) { type->attr.isNative = true; if (meta->keys.find("managed") != UT_NPOS) { type->attr.isNativeManaged = true; } } int numClassAttr = bytes->readInt(); for (int i = 0; i < numClassAttr; i++) { const char *cattr = readPoolString(); if (!strcmp(cattr, "public")) { type->attr.isPublic = true; } if (!strcmp(cattr, "static")) { type->attr.isStatic = true; } if (!strcmp(cattr, "final")) { type->attr.isFinal = true; } } // base type Type *baseType = getType(readPoolString()); if (baseType) { type->setBaseType(baseType); } // interfaces int numInterfaces = bytes->readInt(); for (int i = 0; i < numInterfaces; i++) { Type *interface = getType(readPoolString()); type->addInterface(interface); } // delegate types int numDelegateTypes = bytes->readInt(); for (int i = 0; i < numDelegateTypes; i++) { Type *delegateType = getType(readPoolString()); type->addDelegateType(delegateType); } // delegateReturnType Type *delegateReturnType = getType(readPoolString()); if (delegateReturnType) { type->setDelegateReturnType(delegateReturnType); } // imports int numImports = bytes->readInt(); for (int i = 0; i < numImports; i++) { Type *import = getType(readPoolString()); type->addImport(import); } // read constructor if (bytes->readBoolean()) { ConstructorInfo *cinfo = readConstructor(type); type->addMember(cinfo); } // read fields int numFields = bytes->readInt(); for (int i = 0; i < numFields; i++) { FieldInfo *fieldInfo = readField(type); type->addMember(fieldInfo); } // read properties int numProps = bytes->readInt(); for (int i = 0; i < numProps; i++) { PropertyInfo *propertyInfo = readProperty(type); type->addMember(propertyInfo); } // read methods int numMethods = bytes->readInt(); for (int i = 0; i < numMethods; i++) { MethodInfo *methodInfo = readMethodInfo(type); type->addMember(methodInfo); } type->setBCStaticInitializer(ByteCode::decode64(bytes->readString())); type->setBCInstanceInitializer(ByteCode::decode64(bytes->readString())); }
pair<typename properties::tagType, const properties*> baseStructureParser<streamT>::next() { bool success = true; string readTxt; // String where text read by readUntil() will be placed char termChar; // Character where readUntil() places the character that caused parsing to terminate string tagName; // The name of the current tag string propName, propVal; long int numProps; bool derived; std::map<std::string, std::string> pMap; // Reset tagProperties in preparation of a new tag being read tagProperties.clear(); #ifdef VERBOSE cout << "============"<<(loc==start?"start":(loc==textRead?"textRead":(loc==enterTagRead?"enterTagRead":(loc==exitTagRead?"exitTagRead":(loc==done?"done":"???")))))<<"============"<<endl; if(loc!=start) cout << "buf["<<bufIdx<<"]="<<buf[bufIdx]<<endl; #endif // When we enter this function we resume text processing from where we left off // in the last call to getNext(). loc records this location and we now jump to it. switch(loc) { case start: goto START_LOC; case textRead: goto TEXT_READ_LOC; case enterTagRead: goto ENTER_TAG_READ_LOC; case exitTagRead: goto EXIT_TAG_READ_LOC; case done: goto DONE_LOC; } START_LOC: // Start reading the file, filling as much of buf as possible. Store the number of // bytes read in dataInBuf and initialize bufIdx to refer to the start of buf. //cout << "f="<<f<<", feof(f)="<<feof(f)<<", ferror(f)="<<ferror(f)<<", sizeof(buf)="<<sizeof(buf)<<endl; dataInBuf = readData(); bufIdx=0; while(success) { //cout << "main loop, bufIdx="<<bufIdx<<", bufSize="<<bufSize<<endl; // We must currently be outside of a tag, although we may be between the multiple individual // tags that encode entry into an object with a multi-level inheritance hierarchy (multiple tags) // Look for the start of the next tag success = readUntil(true, "[", 1, termChar, readTxt); // Emit the text before the start of the tag #ifdef VERBOSE cout << "text=\""<<readTxt<<"\""<<endl; #endif //dbg << readTxt; if(readTxt != "") { std::map<std::string, std::string> pMap; pMap["text"] = readTxt; tagProperties.add("text", pMap); loc = textRead; return make_pair(properties::enterTag, &tagProperties); } if(!success) goto DONE_LOC; TEXT_READ_LOC: nextChar(); // Now look for the end of name of the tag (a whitespace char) or the / char // that indicates that this is the end rather than beginning of a tag if(!(success = readUntil(true, " \t\r\n/|", 6, termChar, tagName))) goto DONE_LOC; // If this is the end of a tag, read until its end to determine its name if(termChar == '/') { if(!nextChar()) goto DONE_LOC; if(!(success = readUntil(true, "]", 1, termChar, tagName))) goto DONE_LOC; //if(!(success = readUntil(true, " \t\r\n", 4, termChar, tagName))) goto DONE_LOC; #ifdef VERBOSE cout << "END \""<<tagName<<"\""<<endl; #endif tagProperties.add(tagName, pMap); loc = exitTagRead; return make_pair(properties::exitTag, &tagProperties); EXIT_TAG_READ_LOC: if(!nextChar()) goto DONE_LOC; } else { // Records whether this entry tag corresponds to a base class that has been derived by another derived=false; //cout << "START "<<tagName<<" termChar="<<termChar<<endl; if(termChar == '|') { if(!nextChar()) goto DONE_LOC; if(!(success = readUntil(true, " \t\r\n", 4, termChar, tagName))) goto DONE_LOC; derived=true; } // Read the "numProperties" property if(!(success = readProperty(propName, propVal, termChar))) { goto DONE_LOC; } if(propName != "numProperties") { cerr<< "ERROR: expecting numProperties property in tag "<<tagName<<" but got \""<<propName<<"\"!"<<endl; exit(-1); } numProps = strtol(propVal.c_str(), NULL, 10); //cout << "propName=\""<<propName<<"\", propVal=\""<<propVal<<"\", numProps="<<numProps<<", termChar=\""<<termChar<<"\""<<endl; // Skip until the start of the next property or the end of the tag if(!(success = readUntil(true, " \t\r\n]", 5, termChar, readTxt))) goto DONE_LOC; // Read the properties of this tag pMap.clear(); for(long int p=0; p<numProps; p++) { // If we reached the end of the tag before processing all the properties if(termChar==']') { cerr << "ERROR: reached the end of tag "<<tagName<<" after processing "<<p<<" properties but expected "<<numProps<<" properties!"<<endl; exit(-1); } //cout << " prop "<<p<<": termChar=\""<<termChar<<"\""<<" buf["<<bufIdx<<"]=\""<<buf[bufIdx]<<"\""<<endl; // Read the name/val pair that encodes the name of the current property string propNameName, propNameVal; if(!(success = readProperty(propNameName, propNameVal, termChar))) { goto DONE_LOC; } //cout << " prop "<<p<<": "<<propNameName<<" = "<<propNameVal<<endl; // Skip until the start of the next name/val pair if(!(success = readUntil(true, " \t\r\n]", 5, termChar, readTxt))) goto DONE_LOC; if(termChar==']') { cerr << "ERROR: reached the end of tag "<<tagName<<" reading the name of property "<<p<<" but expected "<<numProps<<" properties!"<<endl; exit(-1); } // Read the name/val pair that encodes the name of the current property string propValName, propValVal; if(!(success = readProperty(propValName, propValVal, termChar))) { goto DONE_LOC; } //cout << " prop "<<p<<": "<<propValName<<" = "<<propValVal<<endl; pMap[unescape(propNameVal)] = unescape(propValVal); // cout << " prop "<<p<<": termChar=\""<<termChar<<"\""<<" buf["<<bufIdx<<"]=\""<<buf[bufIdx]<<"\""<<endl; // Skip until the start of the next property or the end of the tag if(!(success = readUntil(true, " \t\r\n]", 5, termChar, readTxt))) goto DONE_LOC; // cout << " prop "<<p<<": termChar=\""<<termChar<<"\""<<" buf["<<bufIdx<<"]=\""<<buf[bufIdx]<<"\""<<endl; } //cout << "end tag: termChar=\""<<termChar<<"\""<<" buf["<<bufIdx<<"]=\""<<buf[bufIdx]<<"\""<<endl; // If we failed to reach the end of the tag after processing all the properties if(termChar!=']') { // Keep reading the remaining whitespace if(!(success = readUntil(true, " \t\r\n", 4, termChar, readTxt))) goto DONE_LOC; // This must be the end of the tag if(termChar != ']') { cerr << "ERROR: failed to reached the end of tag "<<tagName<<" after processing "<<numProps<<" properties! termChar=\""<<termChar<<"\""<<endl; exit(-1); } } if(!nextChar()) goto DONE_LOC; // If this tag corresponds to an object at the outer-most level of a derivation hierarchy // (it was not derived by another) if(!derived) { // Print out the properties #ifdef VERBOSE cout << "START "<<tagName<<endl; #endif tagProperties.add(tagName, pMap); #ifdef VERBOSE cout << tagProperties.str()<<endl; #endif loc = enterTagRead; return make_pair(properties::enterTag, &tagProperties); ENTER_TAG_READ_LOC: ; // If this tag's class was derived by another, add its properties to pStack so that it can be // picked up when we reach the derived class' tag } else tagProperties.add(tagName, pMap); } } DONE_LOC: loc = done; return make_pair(properties::exitTag, &tagProperties); }