bool LyricAttributes::fromXElement( std::ostream& message, xml::XElement& xelement ) { const char* const className = "LyricAttributes"; bool isSuccess = true; auto it = xelement.attributesBegin(); auto endIter = xelement.attributesEnd(); for( ; it != endIter; ++it ) { if( parseAttribute( message, it, className, isSuccess, number, hasNumber, "number" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, name, hasName, "name" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, justify, hasJustify, "justify", &parseLeftCenterRight ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, defaultX, hasDefaultX, "default-x" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, defaultY, hasDefaultY, "default-y" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, relativeX, hasRelativeX, "relative-x" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, relativeY, hasRelativeY, "relative-y" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, placement, hasPlacement, "placement", &parseAboveBelow ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, color, hasColor, "color" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, printObject, hasPrintObject, "print-object", &parseYesNo ) ) { continue; } } return isSuccess; }
bool BookmarkAttributes::fromXElement( std::ostream& message, xml::XElement& xelement ) { const char* const className = "BookmarkAttributes"; bool isSuccess = true; bool isIdFound = false; auto it = xelement.attributesBegin(); auto endIter = xelement.attributesEnd(); for( ; it != endIter; ++it ) { if( parseAttribute( message, it, className, isSuccess, id, isIdFound, "id" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, name, hasName, "name" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, element, hasElement, "element" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, position, hasPosition, "position" ) ) { continue; } } if( !isIdFound ) { isSuccess = false; message << className << ": 'number' is a required attribute but was not found" << std::endl; } return isSuccess; }
bool XmlReader::parseXmlHeader () { eatChar ('?'); char * name = getNextToken (); if (name == NULL || strcmp (name, "xml") != 0) { free (name); MESSAGE ("Error: XML must start with a valid xml declaration <?xml ?> !'\n"); m_failure = true; return false; } free (name); XmlAttribute * attr = parseAttribute (); while (attr != NULL) { if (m_iconv == NULL && strcmp (attr->m_name, "encoding") == 0 && strcmp (attr->m_value, "UTF-8") != 0) { // Setup caracter conversion as encoding is not UTF-8 m_iconv = iconv_open ("UTF-8", attr->m_value); if (m_iconv == (iconv_t)-1) { // unsupported target encoding MESSAGE ("Error: unsupported encoding in xml declaration: %s\n", attr->m_value); return false; } } delete attr; attr = parseAttribute (); } if (eatChar ('?') && eatChar ('>')) { return true; } MESSAGE ("Error: <?xml declaration must end with a valid '?>' value !'\n"); return false; }
Slot* Parser::parseSlot(Node *_parent,const xmlDocPtr &_doc, xmlNodePtr _cur, std::map<std::string, std::string> *_map) { Slot *s = 0; xmlChar *name,*type, *var; name = parseAttribute(_cur, "name"); type = parseAttribute(_cur, "type"); var = parseAttribute(_cur, "var"); EnumParser<SVariable> p; EnumParser<Stype> p2; s = new Slot( _parent, (const char*)name, p2.parseEnum((const char*)_cur->name), p.parseEnum((const char*)var) ); _cur=_cur->children; while(_cur !=NULL) { if(!xmlStrcmp(_cur->name, (const xmlChar *)SLOTSOURCE)) { std::cout<<"in source slot"<<'\n'; std::string output, input; input = _parent->getName()+"."+ _parent->getID()+"."+ (char *)name; output = parseSource(_cur, _map); _map->insert(std::pair<std::string, std::string>(input, output)); } _cur=_cur->next; } xmlFree(name); xmlFree(type); xmlFree(var); return s; }
const Token* AttributesParser::parseAttributes(const Token* pNext) { pNext = parseAttribute(pNext); while (isOperator(pNext, OperatorToken::OP_COMMA) || isIdentifier(pNext)) { if (!isIdentifier(pNext)) pNext = next(); pNext = parseAttribute(pNext); } return pNext; }
std::string Parser::parseSource(xmlNodePtr _cur, std::map<std::string, std::string> *_connections) { std::string output; xmlChar *sourcenode, *sourceid, *sourceslot; sourcenode = parseAttribute(_cur, "node"); sourceid = parseAttribute(_cur, "id"); sourceslot = parseAttribute(_cur, "slot"); std::cout<<(char*)sourcenode<<(char*)sourceid<<(char*)sourceslot<<'\n'; output = (char*)sourcenode; output += "."; output += (char*)sourceid; output += "."; output += (char*)sourceslot; return output; }
void TooltipManager::parse(XmlReader& reader) { XmlReader::AttributeIterator iter(reader); while(iter.next()) { const char* attribute = (const char*) iter.getName(); const char* value = (const char*) iter.getValue(); if(parseAttribute(attribute, value)) { continue; } else { std::cerr << "Skipping unknown attribute '" << attribute << "' in TooltipManager.\n"; } } int depth = reader.getDepth(); while(reader.read() && reader.getDepth() > depth) { if(reader.getNodeType() == XML_READER_TYPE_ELEMENT) { const char* element = (const char*) reader.getName(); std::cerr << "Skipping unknown child '" << element << "in TooltipManager.\n"; } } }
void AttributeParser::parseCompoundAttribute(MFnDependencyNode & node, MObject & attr, std::set<String>& parsedAttributes) { MStatus status; MFnCompoundAttribute fnCompoundAttribute(attr, &status); if (!status) return; unsigned int numChildren = fnCompoundAttribute.numChildren(&status); if (!status) return; MPlug plug = node.findPlug(attr, &status); if (!status) return; MFnAttribute fnAttr(attr, &status); if (!status) return; MString name = fnAttr.name(&status); if (!status) return; onCompoundAttribute(plug, name); // Recurse children for (unsigned int i = 0; i < fnCompoundAttribute.numChildren(); ++i) { MObject child = fnCompoundAttribute.child(i, &status); if (!status) return; MFnAttribute childFnAttr(child); parsedAttributes.insert(childFnAttr.name().asChar()); parseAttribute(node, child, parsedAttributes); } }
void LCPBar::parse(XmlReader& reader) { XmlReader::AttributeIterator iter(reader); while(iter.next()) { const char* name = (const char*) iter.getName(); const char* value = (const char*) iter.getValue(); if(parseAttribute(name, value)) { continue; } else { std::cerr << "Unknown attribute '" << name << "' skipped in PBar.\n"; } } if(getName() == "PBar") { //LCPBarInstance = this; //FIXME old code compability hack LCPBarPage1 = this; } else if(getName() == "PBar2nd") { LCPBarPage2 = this;} else { std::cerr << "Unknown LCBar component '" << getName() << "' found.\n";} Component* component = parseEmbeddedComponent(reader); addChild(component); width = component->getWidth(); height = component->getHeight(); }
void Parser::parseXMLDeclaration( Node *node ) { if( !doesStreamMatchString( "<?xml" ) ) return; Node *thisNode = new Node; thisNode->setNodeType( XMLDeclaration ); try { do parseWhitespace(); while( parseAttribute( thisNode ) ); parseWhitespace(); if( !doesStreamMatchString( "?>" ) ) reportError( "XML declaration does not end with ?>" ); } catch( ... ) { delete thisNode; throw; } node->addNode( thisNode ); }
void Gradient::parse(XmlReader& reader) { XmlReader::AttributeIterator iter(reader); while(iter.next()) { const char* attribute = (const char*) iter.getName(); const char* value = (const char*) iter.getValue(); if(parseAttribute(attribute, value)) { continue; } else if(strcmp(attribute, "from") == 0) { from.parse(value); } else if(strcmp(attribute, "to") == 0) { to.parse(value); } else if (strcmp(attribute, "direction") == 0) { if(strcmp(value, "left-right") == 0) { direction = LEFT_RIGHT; } else if (strcmp(value, "top-bottom") == 0) { direction = TOP_BOTTOM; } else { std::stringstream msg; msg << "Invalid gradient direction '" << value << "'."; throw std::runtime_error(msg.str()); } } else { std::cerr << "Skipping unknown attribute '" << attribute << "'.\n"; } } flags |= FLAG_RESIZABLE; }
//! [font_translate] void FontTranslator::translate(ScriptCompiler* compiler, const AbstractNodePtr& node) { ObjectAbstractNode* obj = static_cast<ObjectAbstractNode*>(node.get()); // Must have a name - unless we are in legacy mode. Then the class is the name. if (obj->name.empty() && obj->cls == "font") { compiler->addError(ScriptCompiler::CE_OBJECTNAMEEXPECTED, obj->file, obj->line, "font must be given a name"); return; } String& name = obj->cls == "font" ? obj->name : obj->cls; FontPtr font = FontManager::getSingleton().create(name, compiler->getResourceGroup()); font->_notifyOrigin(obj->file); for (auto& c : obj->children) { if (c->type == ANT_PROPERTY) { parseAttribute(compiler, font, static_cast<PropertyAbstractNode*>(c.get())); } } }
Boolean FSIParser::setCatalogAttributes(ParsedSystemId &parsedSysid) { Boolean hadPublic = 0; parsedSysid.maps.resize(parsedSysid.maps.size() + 1); parsedSysid.maps.back().type = ParsedSystemIdMap::catalogDocument; for (;;) { StringC token, value; Boolean gotValue; if (!parseAttribute(token, gotValue, value)) { mgr_.message(EntityManagerMessages::fsiSyntax, StringMessageArg(str_)); return 0; } if (token.size() == 0) break; if (matchKey(token, "PUBLIC")) { if (hadPublic) mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, StringMessageArg(idCharset_.execToDesc("PUBLIC"))); else if (gotValue) { convertMinimumLiteral(value, parsedSysid.maps.back().publicId); parsedSysid.maps.back().type = ParsedSystemIdMap::catalogPublic; } else mgr_.message(EntityManagerMessages::fsiMissingValue, StringMessageArg(token)); hadPublic = 1; } else mgr_.message(gotValue ? EntityManagerMessages::fsiUnsupportedAttribute : EntityManagerMessages::fsiUnsupportedAttributeToken, StringMessageArg(token)); } return 1; }
bool QQuickStyledTextPrivate::parseOrderedListAttributes(const QChar *&ch, const QString &textIn) { bool valid = false; List listItem; listItem.level = 0; listItem.type = Ordered; listItem.format = Decimal; QPair<QStringRef,QStringRef> attr; do { attr = parseAttribute(ch, textIn); if (attr.first == QLatin1String("type")) { valid = true; if (attr.second == QLatin1String("a")) listItem.format = LowerAlpha; else if (attr.second == QLatin1String("A")) listItem.format = UpperAlpha; else if (attr.second == QLatin1String("i")) listItem.format = LowerRoman; else if (attr.second == QLatin1String("I")) listItem.format = UpperRoman; } } while (!ch->isNull() && !attr.first.isEmpty()); listStack.push(listItem); return valid; }
XmlNode * XmlReader::parseTag (char c) { c = skipSpaces (); // '<' has been eaten to check for a comment bool closing = false; if (c == '/') { // ending tag closing = true; c = getNextChar (); } char * name = getNextToken (); if (name == NULL) { MESSAGE ("Error: XML tags must start with an alpha caracter !'"); m_failure = true; return NULL; } XmlNode * e = new XmlNode (name, closing ? CLOSE_TAG : OPEN_TAG); if (!closing) { // may have some attributes XmlAttribute * attr = parseAttribute (); while (attr != NULL) { e->addAttribute (attr); attr = parseAttribute (); } } // final '>' c = getChar (); if (c == '/') { // self tag if (closing) { delete e; MESSAGE ("Error: closing is also self closing: %s", e->m_name); m_failure = true; return NULL; } e->m_type = SELF_TAG; c = getNextChar (); } // check for nodes that shoudl be self closing: BR, HR, IMG // if (m_htmlMode && e->m_type == OPEN_TAG) { // e.m_type = checkHtmlSelfClosing(e.m_name); // } if (c != '>') { // ending tag delete e; MESSAGE ("Error: got '%c' instead of '>'", c); m_failure = true; return NULL; } getNextChar (); // eat '>' return e; }
bool MidiDeviceAttributes::fromXElement( std::ostream& message, xml::XElement& xelement ) { const char* const className = "MidiDeviceAttributes"; bool isSuccess = true; auto it = xelement.attributesBegin(); auto endIter = xelement.attributesEnd(); for( ; it != endIter; ++it ) { if( parseAttribute( message, it, className, isSuccess, port, hasPort, "port" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, id, hasId, "id" ) ) { continue; } } return isSuccess; }
bool DirectionAttributes::fromXElement( std::ostream& message, xml::XElement& xelement ) { const char* const className = "DirectionAttributes"; bool isSuccess = true; auto it = xelement.attributesBegin(); auto endIter = xelement.attributesEnd(); for( ; it != endIter; ++it ) { if( parseAttribute( message, it, className, isSuccess, placement, hasPlacement, "placement", &parseAboveBelow ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, directive, hasDirective, "directive", &parseYesNo ) ) { continue; } } return isSuccess; }
static int parseDwarfInfo(char *line, Dwarf_Die *lastCreatedDie, Dwarf_Die *currentDie, size_t *lastIndent, unordered_map<Dwarf_Die *, Dwarf_Off> *refToPopulate, Dwarf_Error *error) { int ret = DW_DLV_OK; /* There are two possible formats for a line. Every second line * is blank. Non-blank lines either begin with * "0x[address]: [whitespace...] TAG_*" to represent a new Die org/legal/epl-v10 * "[whitespae...] AT_*( {[optional address]} ( [value] ) ) for a die attribute. * The amount of whitespace varies to indicate parent-child relationships * between Die's. */ if (0 == strncmp("0x", line, 2)) { /* Find the end of the address and number of spaces. Amount of indentation * represents parent-child relationship between Dwarf_Die's. */ char *endOfAddress = NULL; Dwarf_Off address = strtoul(line, &endOfAddress, 16); size_t spaces = 0; if (NULL != endOfAddress) { endOfAddress += 1; spaces = strspn(endOfAddress, " "); } /* The string "TAG_[tag]" or "Compile Unit:" or "NULL" should be next. */ if (0 == strncmp(endOfAddress + spaces, "Compile Unit: ", 14)) { cleanUnknownDiesInCU(Dwarf_CU_Context::_currentCU); ret = parseCompileUnit(endOfAddress + spaces + 14, lastIndent, error); lastCreatedDie = NULL; } else if (0 == strncmp(endOfAddress + spaces, "TAG_", 4)) { ret = parseDwarfDie(endOfAddress + spaces + 4, lastCreatedDie, currentDie, lastIndent, spaces, error); if (DW_DLV_OK == ret && DW_TAG_unknown != (*lastCreatedDie)->_tag) { Dwarf_Die_s::refMap[address] = *lastCreatedDie; } } else if (0 == strncmp(endOfAddress + spaces, "NULL", 4)) { /* A "NULL" line indicates going up one level in the Die tree. * Process it only if the current level contained a Die that was * processed. */ if (spaces <= *lastIndent) { *lastCreatedDie = (*lastCreatedDie)->_parent; } } else { ret = DW_DLV_ERROR; setError(error, DW_DLE_VMM); } } else if ((0 == strncmp(" ", line, 2)) && (NULL != *currentDie)) { /* Die attribute lines begin with "[whitespace...] AT_". To belong * to the last Die to be created, it must contain 12 spaces more * than the last indentation (For the size of the Die offset text). */ size_t spaces = strspn(line, " "); if ((spaces == *lastIndent + 12) && (0 == strncmp(line + spaces, "AT_", 3))) { ret = parseAttribute(line + spaces + 3, lastCreatedDie, refToPopulate, error); } } return ret; }
bool BeamAttributes::fromXElement( std::ostream& message, xml::XElement& xelement ) { const char* const className = "BeamAttributes"; bool isSuccess = true; auto it = xelement.attributesBegin(); auto endIter = xelement.attributesEnd(); for( ; it != endIter; ++it ) { if( parseAttribute( message, it, className, isSuccess, number, hasNumber, "number" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, repeater, hasRepeater, "repeater", &parseYesNo ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, fan, hasFan, "fan", &parseFan ) ) { continue; } } return isSuccess; }
void EconomyGraph::parse( XmlReader& reader ){ XmlReader::AttributeIterator iter( reader ); while(iter.next()) { const char* name = (const char*) iter.getName(); const char* value = (const char*) iter.getValue(); if(parseAttribute(name, value)){ continue; } else if(strcmp(name, "width") == 0) { if(sscanf(value, "%f", &width) != 1) { std::stringstream msg; msg << "Couldn't parse width attribute (" << value << ")."; throw std::runtime_error(msg.str()); } } else if(strcmp(name, "height") == 0) { if(sscanf(value, "%f", &height) != 1) { std::stringstream msg; msg << "Couldn't parse height attribute (" << value << ")."; throw std::runtime_error(msg.str()); } } else { std::cerr << "Unknown attribute '" << name << "' skipped in EconomyGraph.\n"; } } //Generate Labels for Sustainability Graph Style labelStyle; labelStyle.font_family = "sans"; labelStyle.font_size = 10; TTF_Font* font = fontManager->getFont( labelStyle ); SDL_Surface* labelXXX; /* MIN=Mining, PRT=Import/export from port, MNY=Money, POP=Population, TEC=Technology, FIR=Fire coverage */ labelXXX = TTF_RenderUTF8_Blended( font, _("Mining"), labelStyle.text_color.getSDLColor() ); labelTextureMIN = texture_manager->create( labelXXX ); labelXXX = TTF_RenderUTF8_Blended( font, _("Trade"), labelStyle.text_color.getSDLColor() ); labelTexturePRT = texture_manager->create( labelXXX ); labelXXX = TTF_RenderUTF8_Blended( font, _("Money"), labelStyle.text_color.getSDLColor() ); labelTextureMNY = texture_manager->create( labelXXX ); labelXXX = TTF_RenderUTF8_Blended( font, _("Popul."), labelStyle.text_color.getSDLColor() ); labelTexturePOP = texture_manager->create( labelXXX ); labelXXX = TTF_RenderUTF8_Blended( font, _("Techn."), labelStyle.text_color.getSDLColor() ); labelTextureTEC = texture_manager->create( labelXXX ); labelXXX = TTF_RenderUTF8_Blended( font, _("Fire"), labelStyle.text_color.getSDLColor() ); labelTextureFIR = texture_manager->create( labelXXX ); labelXXX = TTF_RenderUTF8_Blended( font, _("Economy Overview:"), labelStyle.text_color.getSDLColor() ); labelTextureEconomy = texture_manager->create( labelXXX ); labelXXX = TTF_RenderUTF8_Blended( font, _("Sustainability:"), labelStyle.text_color.getSDLColor() ); labelTextureSustainability = texture_manager->create( labelXXX ); labelXXX = TTF_RenderUTF8_Blended( font, _("Frames per Second:"), labelStyle.text_color.getSDLColor() ); labelTextureFPS = texture_manager->create( labelXXX ); }
bool BarlineAttributes::fromXElement( std::ostream& message, xml::XElement& xelement ) { const char* const className = "BarlineAttributes"; bool isSuccess = true; auto it = xelement.attributesBegin(); auto endIter = xelement.attributesEnd(); for( ; it != endIter; ++it ) { if( parseAttribute( message, it, className, isSuccess, location, hasLocation, "location", &parseRightLeftMiddle ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, segno, hasSegno, "segno" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, coda, hasCoda, "coda" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, divisions, hasDivisions, "divisions" ) ) { continue; } } return isSuccess; }
bool GroupSymbolAttributes::fromXElementImpl( std::ostream& message, xml::XElement& xelement ) { const char* const className = "GroupSymbolAttributes"; bool isSuccess = true; auto it = xelement.attributesBegin(); auto endIter = xelement.attributesEnd(); for( ; it != endIter; ++it ) { if( parseAttribute( message, it, className, isSuccess, defaultX, hasDefaultX, "default-x" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, defaultY, hasDefaultY, "default-y" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, relativeX, hasRelativeX, "relative-x" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, relativeY, hasRelativeY, "relative-y" ) ) { continue; } } MX_RETURN_IS_SUCCESS; }
bool FretAttributes::fromXElementImpl( std::ostream& message, xml::XElement& xelement ) { const char* const className = "FretAttributes"; bool isSuccess = true; auto it = xelement.attributesBegin(); auto endIter = xelement.attributesEnd(); for( ; it != endIter; ++it ) { if( parseAttribute( message, it, className, isSuccess, fontFamily, hasFontFamily, "font-family" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, fontStyle, hasFontStyle, "font-style", &parseFontStyle ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, fontSize, hasFontSize, "font-size" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, fontWeight, hasFontWeight, "font-weight", &parseFontWeight ) ) { continue; } } MX_RETURN_IS_SUCCESS; }
XMLNode* XMLDecoderUTF8::parseElement() { String name; advance(1); /* spec says no whitespaces allowd - whatever */ skipWhitespace(); if(!parseName( name)) throw CVTException("Malformed element name"); /* START Tag */ XMLElement* element = new XMLElement( name ); while( _rlen ) { skipWhitespace(); if( match( "/>" ) ) { advance( 2 ); return element; } else if( match( '>' ) ) { advance( 1 ); break; } else { element->addChild( parseAttribute() ); } } /* Content */ skipWhitespace(); while( !match("</") ) { if( match("<?") ) element->addChild( parsePI() ); else if( match("<!--") ) element->addChild( parseComment() ); else if( match("<") ) element->addChild( parseElement() ); else if( match("<![CDATA[") ) element->addChild( parseCData() ); else element->addChild( parseText() ); skipWhitespace(); } /* END Tag */ advance( 2 ); /* spec says no whitespaces allowd - whatever */ skipWhitespace(); String ename; if( ! parseName( ename ) ) throw CVTException("Malformed element name"); if( name != ename ) throw CVTException("Names in start- and end-tag differ"); skipWhitespace(); if( !match('>') ) throw CVTException("Missing '>'"); advance( 1 ); return element; }
int CMuseDataHeader::parseMusicalAttributes(char*line,int lineNr) { attributesRead=1; if(line[1]!=' '){ MUSEERROR(err_EditorialLevelNotSupported,lineNr,2); } if(line[2]!=' '){ MUSEERROR(err_FootnoteNotSupported,lineNr,3); } if(line[1]==0){return 0;} if(line[2]==0){return 0;} int col=3; while(line[col]!=0){ int rv=0; switch(line[col]){ //single-integer-attributes: case 'K':rv=parseAttribute(&line[col+1],&rdKey);break; case 'Q':rv=parseAttribute(&line[col+1],&rdDivisionsPerQuarter);break; case 'X':rv=parseAttribute(&line[col+1],&rdTransposingPart);break; case 'S':rv=parseAttribute(&line[col+1],&rdNumberOfStaves);break; case 'I':rv=parseAttribute(&line[col+1],&rdNumberOfInstruments);break; //clefs: case 'C': if(line[col+1]==':'){rv=parseAttribute(&line[col+1],&rdClef[0]);break;} if(line[col+1]=='1'){rv=parseAttribute(&line[col+2],&rdClef[0]);break;} if(line[col+1]=='2'){rv=parseAttribute(&line[col+2],&rdClef[1]);break;} rv=-1;break; //directives: case 'D': if(line[col+1]==':'){strncpy(rdDirective[0],&line[col+2],80);break;} if(line[col+1]=='1'){ if(line[col+2]==':') {strncpy(rdDirective[0],&line[col+3],80);break;} else {rv=-1;break;} } if(line[col+1]=='2'){ if(line[col+2]==':') {strncpy(rdDirective[1],&line[col+3],80);break;} else {rv=-1;break;} } } if(rv){ MUSEERROR(err_ParseAttribute,lineNr,col); } //find next blank while( (line[col]!=0) && (line[col]!=' ') ){col++;} if(line[col]==' '){col++;} } return 0; }
void parseAttributes(xsMachine* the) { xsIntegerValue c, i; if (xsTest(xsVar(CHILDREN))) { c = xsToInteger(xsGet(xsVar(CHILDREN), xsID_length)); for (i = 0; i < c; i++) { xsVar(CHILD) = xsGet(xsVar(CHILDREN), i); parseAttribute(the); } } }
bool PrintAttributes::fromXElementImpl( std::ostream& message, xml::XElement& xelement ) { const char* const className = "PrintAttributes"; bool isSuccess = true; auto it = xelement.attributesBegin(); auto endIter = xelement.attributesEnd(); for( ; it != endIter; ++it ) { if( parseAttribute( message, it, className, isSuccess, staffSpacing, hasStaffSpacing, "staff-spacing" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, newSystem, hasNewSystem, "new-system", &parseYesNo ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, newPage, hasNewPage, "new-page", &parseYesNo ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, blankPage, hasBlankPage, "blank-page" ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, pageNumber, hasPageNumber, "page-number" ) ) { continue; } } MX_RETURN_IS_SUCCESS; }
// Loads the attribute data saved in a .tx3 file void AttributeData::load(string filename) { ifstream inFile; inFile.open(filename.c_str()); while (!inFile.eof()) { inFile.ignore(1024, '#'); inFile.unget(); if (inFile.peek() == '#') { string line; inFile >> line; if (line == "#att") { string attname; short flipNum; inFile >> attname; xAttr = parseAttribute(attname); inFile >> xMod; inFile >> xZmin; inFile >> flipNum; xFlip = (bool) flipNum; inFile >> attname; yAttr = parseAttribute(attname); inFile >> yMod; inFile >> yZmin; inFile >> flipNum; yFlip = (bool) flipNum; inFile >> attname; zAttr = parseAttribute(attname); inFile >> zMod; inFile >> zZmin; inFile >> flipNum; zFlip = (bool) flipNum; break; } }
bool TieAttributes::fromXElementImpl( std::ostream& message, xml::XElement& xelement ) { const char* const className = "TieAttributes"; bool isSuccess = true; bool isTypeFound = false; auto it = xelement.attributesBegin(); auto endIter = xelement.attributesEnd(); for( ; it != endIter; ++it ) { if( parseAttribute( message, it, className, isSuccess, type, isTypeFound, "type", &parseStartStop ) ) { continue; } if( parseAttribute( message, it, className, isSuccess, timeOnly, hasTimeOnly, "time-only" ) ) { continue; } } if( !isTypeFound ) { isSuccess = false; message << className << ": 'number' is a required attribute but was not found" << std::endl; } return isSuccess; }
void Document::parse(XmlReader& reader) { XmlReader::AttributeIterator iter(reader); while(iter.next()) { const char* attribute = (const char*) iter.getName(); const char* value = (const char*) iter.getValue(); if(parseAttribute(attribute, value)) { continue; } else if(style.parseAttribute(attribute, value)) { continue; } else if(strcmp(attribute, "src") == 0) { XmlReader fileReader(value); parse(fileReader); return; } else { std::cerr << "Skipping unknown attribute '" << attribute << "'.\n"; } } int depth = reader.getDepth(); while(reader.read() && reader.getDepth() > depth) { if(reader.getNodeType() == XML_READER_TYPE_ELEMENT) { std::string node = (const char*) reader.getName(); if(node == "p" || node=="Paragraph" || node == "li") { std::auto_ptr<Paragraph> paragraph (new Paragraph()); if(node != "li") { paragraph->parse(reader, style); } else { paragraph->parseList(reader, style); } paragraph->linkClicked.connect( makeCallback(*this, &Document::paragraphLinkClicked)); addChild(paragraph.release()); } else if(node == "img") { std::auto_ptr<DocumentImage> image (new DocumentImage()); image->parse(reader, style); addChild(image.release()); } else { std::cerr << "Skipping unknown node type '" << node << "'.\n"; reader.nextNode(); } } else if(reader.getNodeType() == XML_READER_TYPE_TEXT) { // TODO create anonymous paragraph... std::cerr << "Warning: text outside paragraph not allowed (yet).\n"; } } }