Exemple #1
0
const char *SkinElementsMgr::getElementAlias(const char *id)  {
  if(m_doc) {   
    DOMElement * node = m_doc->getElementById(id);
    if (node && !STRCMP(node->getNodeName(),"elementalias")) {
      DOMAttr * attr = node->getAttributeNode("target");
      if( attr && attr->getSpecified() )
        return attr->getValue();
    }
  }
  return NULL;
}
Exemple #2
0
	bool Manager::attribute(const DOMNode* n,const u_str attrname) {
		bool result=false;
		if (n != nullptr && !attrname.empty() && n->getNodeType() == DOMNode::ELEMENT_NODE ) {
			DOMElement* enod = (DOMElement*)n;
			DOMAttr* enoda = enod->getAttributeNode(pcx(attrname.c_str()));
			if (enoda != nullptr) {
				const XMLCh* x_attrval = enoda->getNodeValue();
				if (x_attrval != nullptr && x_attrval[0] != 0 ) {
					result = true; //only true if result is not empty.
				}
			}
		}
		return result;
	}
bool Triggerconf::existsConfigAttribute (string module, string submodule, string configname, string attributename)
{
	bool autoval	= autocreate;
	autocreate	= false;
	
	DOMNode* currentConfigElement = selectConfigElement (module, submodule, configname);
	autocreate = autoval;
	if (currentConfigElement == NULL) return false;

	assert (currentConfigElement->getNodeType () == DOMNode::ELEMENT_NODE);
	DOMElement* elem = (DOMElement*) currentConfigElement;

	XMLCh* xattrname	= XMLString::transcode (attributename.c_str ());
	bool hasattr		= elem->getAttributeNode (xattrname) != NULL;
	XMLString::release	(&xattrname);

	return hasattr;
}
Exemple #4
0
	bool Manager::attribute(const DOMNode* n,const u_str attrname, std::string& attrval) {
		bool result=false;
		if (n != nullptr && !attrname.empty() && n->getNodeType() == DOMNode::ELEMENT_NODE ) {
			DOMElement* enod = (DOMElement*)n;
			DOMAttr* enoda = enod->getAttributeNode(pcx(attrname.c_str()));
			if (enoda != nullptr) {
				const XMLCh* x_attrval = enoda->getNodeValue();
				if (x_attrval != nullptr && x_attrval[0] != 0 ) {
					char* value = (char*)TranscodeToStr(x_attrval,"UTF-8").adopt();
					size_t vl = strlen(value);
					attrval.reserve(vl);
					attrval.assign(value,vl);
					XMLString::release(&value); //delete attr;
					result = true; //only true if result is not empty.
				}
			}
		}
		return result;
	}
/**
 * 2DO extend to support non default references
 * If no tuning present, will default to 12ET
 */
Tuning *PMLDocument::getTuning(){

    DOMElement *perf = getSingleElement(m_doc->getDocumentElement(), "performance");

    if( !perf ){
//cerr << "No performance element! Defaulting to 12ET\n";
    }
    else{

        DOMElement *tuningEl = getSingleElement(perf, "tuning");


        if( !tuningEl ){
            cout << "No tuning element! Defaulting to 12ET\n";
        }
        else{
            string tuningName = XS( tuningEl->getAttribute(XS("name")) );

            IntervalList *intervals = new IntervalList;
            SpellingList *spellingList = new SpellingList;

            /* Get intervals */
            DOMElement* intList = getSingleElement(tuningEl,"intervallist");

            DOMNodeList *intervalEls = intList->getElementsByTagName(XS("interval"));
            for( int i=0; i<intervalEls->getLength(); i++ ){
                string is = getText((DOMElement*)intervalEls->item(i));
	//cout << "Interval " << is << endl;
                intervals->push_back( atof(is.c_str())  );
            }

            /* Get enharmonic equivalent spellings */
            DOMElement *spellingListEl = getSingleElement( tuningEl, "spellinglist" );
            DOMNodeList *equivs = spellingListEl->getElementsByTagName(XS("enharmequiv"));

            for( int e=0; e<equivs->getLength(); e++ ){

                DOMElement *equiv = (DOMElement*)equivs->item(e);
                DOMNodeList *spellings = equiv->getElementsByTagName(XS("spelling"));

                for( int i=0; i<spellings->getLength(); i++ ){

                    DOMElement* spEl = (DOMElement*)spellings->item(i);

                    Accidental acc;
                    if( spEl->getAttributeNode(XS("acc")) == NULL )  
                        acc = Accidentals::NoAccidental;
                    else
                        acc = XS( spEl->getAttribute(XS("acc")) );
	//cout << "Acc " << acc << endl;
	
                    string notest = XS(spEl->getAttribute(XS("note")));
                    char note = notest[0];
	
                    PitchSpelling ps(note,acc);
                    SpellingListItem spi( e, ps );
                    spellingList->insert( spi);
                }
            }

            Tuning *tuning = new Tuning( tuningName, intervals, spellingList);
            return tuning;
        }      
    }



    std::vector<Tuning*>* tunings = Tuning::getTunings( "/usr/local/lib/tunings" );
    Tuning *tuning = tunings->at(0);
    return tuning;
}