void RenderingRulesStorage::printDebug(int state) { HMAP::hash_map<int, RenderingRule*>::iterator it = tagValueGlobalRules[state].begin(); for (; it != tagValueGlobalRules[state].end(); it++) { printf("\n\n%s : %s", getTagString(it->first).c_str(), getValueString(it->first).c_str()); it->second->printDebugRenderingRule(string(""), this); } }
trackDetails * getMP3Details(char *path) { trackDetails *details; details = calloc(1,sizeof(trackDetails)); struct id3_file *mp3file = NULL; struct id3_tag *tag = NULL; mp3file = id3_file_open(path,ID3_FILE_MODE_READONLY); if(mp3file!=NULL) { tag = id3_file_tag(mp3file); details->title = getTagString(tag,"TIT2"); details->artist = getTagString(tag,"TPE1"); details->album = getTagString(tag,"TALB"); } else { fprintf(stdout,"could not get details for %s\n",path); } id3_file_close(mp3file); return details; }
RenderingRule* RenderingRulesStorage::createTagValueRootWrapperRule(int tagValueKey, RenderingRule* previous) { if (previous->properties.size() > 2) { map<string, string> m; m["tag"] = getTagString(tagValueKey); m["value"] = getValueString(tagValueKey); RenderingRule* toInsert = new RenderingRule(m, this); toInsert->ifElseChildren.push_back(previous); return toInsert; } else { return previous; } }
std::shared_ptr<OsmAnd::MapStyleRule> OsmAnd::MapStyle_P::createTagValueRootWrapperRule( uint64_t id, const std::shared_ptr<MapStyleRule>& rule ) { if(rule->_d->_values.size() <= 2) return rule; QHash< QString, QString > attributes; attributes.insert(QLatin1String("tag"), getTagString(id)); attributes.insert(QLatin1String("value"), getValueString(id)); std::shared_ptr<MapStyleRule> newRule(new MapStyleRule(owner, attributes)); newRule->_d->_ifElseChildren.push_back(rule); return newRule; }
/** * FUNCTION: xmlGenerateTag * * Generates a XML tag * * PRE-Condition: valid parameters * * POST-Condition: the XML tag is written to the XML buffer * * IN: tagId, the ID for the tag to generate (TN_ADD, ...) * tagType, the tag type (e.g. Begin Tag -> TT_BEG, ...) * attFlag, indicates if the encoded tag contain Attributes in namespace extensions * * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements * * RETURN: shows error codes of function, * 0, if OK */ Ret_t xmlGenerateTag(XltTagID_t tagId, XltTagType_t tagType, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag) { Ret_t _err; MemByte_t _begpar = XML_BEGPAR; MemByte_t _tagdel = XML_TAGDEL; MemByte_t _endpar = XML_ENDPAR; MemByte_t _nstagstart[] = XML_NSSTART; MemByte_t _nstagend[] = XML_NSEND; String_t _tagstr; String_t _tagnsattr = NULL; if ((_tagstr = (String_t)smlLibMalloc(XML_MAX_TAGLEN)) == NULL) return SML_ERR_NOT_ENOUGH_SPACE; if ((_err = getTagString(tagId, _tagstr, attFlag)) != SML_ERR_OK) { smlLibFree(_tagstr); return _err; } if (!_tagstr) { // check again as _tagstr might be alterd in getTagString smlLibFree(_tagstr); return SML_ERR_XLT_INVAL_TAG_TYPE; } /* the <SyncML> tag _must_ have an xmlns attribute */ if (attFlag != pBufMgr->smlActiveExt || tagId == TN_SYNCML) { // %%% luz:2003-07-31: now uses namespace from table according to version if (getExtName(attFlag, &_tagnsattr, pBufMgr->vers) != SML_ERR_OK) { smlLibFree(_tagstr); return SML_ERR_XLT_INVAL_TAG_TYPE; } } pBufMgr->smlActiveExt = attFlag; //check if content byte has to be added to the tag switch (tagType) { // set the end tag case TT_END: { if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, pBufMgr)) != SML_ERR_OK) break; if ((_err = xltAddToBuffer((MemPtr_t)(&_tagdel), 1, pBufMgr)) != SML_ERR_OK) break; if ((_err = xltAddToBuffer((MemPtr_t)_tagstr, smlLibStrlen(_tagstr), pBufMgr)) != SML_ERR_OK) break; if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, pBufMgr)) != SML_ERR_OK) break; if (tagId == pBufMgr->switchExtTag) { pBufMgr->smlActiveExt = pBufMgr->smlLastExt; pBufMgr->smlCurExt = pBufMgr->smlLastExt; pBufMgr->smlLastExt = attFlag; } // just forget the stored number ob bytes for this end-tag since written now pBufMgr->endTagSize -= (3 + smlLibStrlen(_tagstr)); break; } //Empty tag case TT_ALL: { if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, pBufMgr)) != SML_ERR_OK) break; if ((_err = xltAddToBuffer((MemPtr_t)_tagstr, smlLibStrlen(_tagstr), pBufMgr)) != SML_ERR_OK) break; if (_tagnsattr) { if ((_err = xltAddToBuffer((MemPtr_t)(&_nstagstart), 8, pBufMgr)) != SML_ERR_OK) break; if ((_err = xltAddToBuffer((MemPtr_t)_tagnsattr, smlLibStrlen(_tagnsattr), pBufMgr)) != SML_ERR_OK) break; if ((_err = xltAddToBuffer((MemPtr_t)&_nstagend, 1, pBufMgr)) != SML_ERR_OK) break; } if ((_err = xltAddToBuffer((MemPtr_t)(&_tagdel), 1, pBufMgr)) != SML_ERR_OK) break; if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, pBufMgr)) != SML_ERR_OK) break; break; } //Only Begin Tag -> content follows -> content byte has to be added case TT_BEG: { if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, pBufMgr)) != SML_ERR_OK) break; if ((_err = xltAddToBuffer((MemPtr_t)_tagstr, smlLibStrlen(_tagstr), pBufMgr)) != SML_ERR_OK) break; if (_tagnsattr) { if ((_err = xltAddToBuffer((MemPtr_t)&_nstagstart, 8, pBufMgr)) != SML_ERR_OK) break; if ((_err = xltAddToBuffer((MemPtr_t)_tagnsattr, smlLibStrlen(_tagnsattr), pBufMgr)) != SML_ERR_OK) break; if ((_err = xltAddToBuffer((MemPtr_t)&_nstagend, 1, pBufMgr)) != SML_ERR_OK) break; } if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, pBufMgr)) != SML_ERR_OK) break; // remember the number of byte that must follow for the according end-tag pBufMgr->endTagSize += (3 + smlLibStrlen(_tagstr)); break; } default: { smlLibFree(_tagstr); smlLibFree(_tagnsattr); return SML_ERR_XLT_INVAL_TAG_TYPE; } } smlLibFree(_tagstr); smlLibFree(_tagnsattr); return _err; }