Beispiel #1
0
bool Config::parseNode(const pugi::xml_node& node) {
    UnicodeString currentPath = StringConverter::fromUtf8(node.path('/'));
    currentPath.append("@");

    pugi::xml_node::attribute_iterator attrIter = node.attributes_begin();
    pugi::xml_node::attribute_iterator attrEnd = node.attributes_end();

    for (; attrIter != attrEnd; ++attrIter) {
        UnicodeString configKey = currentPath;
        configKey.append(attrIter->name());
        std::map<UnicodeString, Variable>::iterator itm = variablesMap_.find(configKey);
        if (itm != variablesMap_.end()) {
            if (!itm->second.parse(attrIter->value())) {
                return false;
            }
        } else {
            LOG_WARN << "Ignoring unknown config value " << configKey << std::endl;
        }
    }

    pugi::xml_node::iterator nodeIter = node.begin();
    pugi::xml_node::iterator nodeEnd = node.end();

    for (; nodeIter != nodeEnd; ++nodeIter) {
        if (nodeIter->type() == pugi::node_element) {
            if (!parseNode(*nodeIter)) {
                return false;
            }
        }
    }

    return true;
}
Beispiel #2
0
Group * AssimpLoader::parseNode(const aiScene & scene,
    const QList<PolygonalDrawable *> &drawables, const aiNode & node) const
{
    Group * group = new Group(node.mName.C_Str());

    const aiMatrix4x4 & mat = node.mTransformation;
    glm::mat4 transform(
        mat.a1, mat.b1, mat.c1, mat.d1,
        mat.a2, mat.b2, mat.c2, mat.d2,
        mat.a3, mat.b3, mat.c3, mat.d3,
        mat.a4, mat.b4, mat.c4, mat.d4
    );
    /*
    translation vector is marked with []
    assimp's aiMatrix4x4 : row major (as usually written down in maths)
     a1  a2  a3 [a4]  <1. row>
     b1  b2  b3 [b4]  <2. row>
     c1  c2  c3 [c4]  <3. row>
     d1  d2  d3  d4   <4. row>
    glm/openGL mat4 : column major (not as stated in http://assimp.sourceforge.net/lib_html/data.html , search for "All matrices")
     a1  b1  c1  d1   <1. column>
     a2  b2  c2  d2   <2. column>
     a3  b3  c3  d3   <3. column>
    [a4][b4][c4] d4   <4. column>
    */
    group->setTransform(transform);

    for (unsigned int i = 0; i < node.mNumChildren; i++)
        group->append(parseNode(scene, drawables, *(node.mChildren[i])));

    for (unsigned int i = 0; i < node.mNumMeshes; i++)
        group->append(drawables[node.mMeshes[i]]);

    return group;
}
Beispiel #3
0
inline void PBFParser::ParseData() {
    while (true) {
        _ThreadData *threadData;
        threadDataQueue->wait_and_pop(threadData);
        if( NULL==threadData ) {
            INFO("Parse Data Thread Finished");
            threadDataQueue->push(NULL); // Signal end of data for other threads
            break;
        }

        loadBlock(threadData);

        for(int i = 0, groupSize = threadData->PBFprimitiveBlock.primitivegroup_size(); i < groupSize; ++i) {
            threadData->currentGroupID = i;
            loadGroup(threadData);

            if( parsingStep == eRelations ) {
                if(threadData->entityTypeIndicator == TypeRelation)
                    parseRelation(threadData);
            } else if( parsingStep == eOther ) {
                if(threadData->entityTypeIndicator == TypeNode)
                    parseNode(threadData);
                if(threadData->entityTypeIndicator == TypeWay)
                    parseWay(threadData);
                if(threadData->entityTypeIndicator == TypeDenseNode)
                    parseDenseNode(threadData);
            }
        }

        delete threadData;
        threadData = NULL;
    }
}
Beispiel #4
0
void parseNode(QDomNode &node,QMap<QString, QString> *retmap)
{
    if (node.isNull() || !node.isElement())
    {
      return;
    }
    QDomElement elem = node.toElement();
    if(node.firstChild().isElement())
    {
        QDomNodeList children=node.childNodes();
        int c=children.count();
        for(int i=0;i<c;i++)
        {
            QDomNode cn=children.item(i);
            parseNode(cn,retmap);

        }
        return;
    }
    QString tagname=node.toElement().tagName();
    int pos=tagname.indexOf(":");
    if(pos >=0)
    {
        tagname=tagname.right(tagname.length() - pos - 1);
    }
    retmap->insert(tagname,node.toElement().text());

}
Beispiel #5
0
Children mainParse(I& be, I& en,  Pos& pos) {
	Children ret;

	while(be != en) {
		eatWhitespaceComment(be, en, pos);

		if(test(be, en, "<{{")) {
			ret.push_back(std::move(parseC(be, en, pos)));	
		} else if(test(be, en, '<')) {
			ret.push_back(std::move(parseNode(be, en, pos)));
		} else if(test(be, en, '>')) {
			eat(be, '>', pos);
			break;
		} else {
			I iter;
			TNodeType type;	
			if(!test(be, en, "&{{") && *be == '&') {
		   		iter = eatUntil(be, en, "\n", pos);
				/*for(iter = be; !test(iter, en, '\n') && !test(iter, en, "//"); 
						increment(iter, pos)) 
				{
				}
				if(test(be, en, "//")) {
					eatWhitespaceComment(be, en, pos);
				}*/
				type = TNodeType::SingleCppLine;
			} else {
		   		iter = eatUntil(be, en, "\n>", pos);
				for(iter = be; 
					!test(iter, en, '\n') && !test(iter, en, "//") && !test(iter, en, '>'); 
					increment(iter, pos)) 
				{
				}
				if(test(be, en, "//")) {
					eatWhitespaceComment(be, en, pos);
				}
				type = TNodeType::Text;
			}
			auto posCopy = pos;
			//std::cout<<"||| "<<std::string(be, iter)<<std::endl;
			ret.push_back(
				std::make_unique<TNode>(std::string(be, iter), posCopy, type
				)
			);

			be = iter;

			char iterC = *iter;
			eat(be, iterC, pos);

			if(iterC == '>') 
			{
				break;
			}
		}
		eatWhitespaceComment(be, en, pos);
	}

	return ret;
}
Beispiel #6
0
bool FileLoader::openFile(const char* filename, bool write, bool caching /*= false*/)
{
	if(write) {
		m_file = fopen(filename, "wb");
		if(m_file) {
			uint32_t version = 0;
			writeData(&version, sizeof(version), false);
			return true;
		}
		else{
			m_lastError = ERROR_CAN_NOT_CREATE;
			return false;
		}
	}
	else {
		m_file = fopen(filename, "rb");
		if(m_file){
			uint32_t version;
			fread(&version, sizeof(version), 1, m_file);
			if(version > 0){
				fclose(m_file);
				m_file = NULL;
				m_lastError = ERROR_INVALID_FILE_VERSION;
				return false;
			}
			else{
				if(caching){
					m_use_cache = true;
					fseek(m_file, 0, SEEK_END);
					int file_size = ftell(m_file);
					m_cache_size = std::min(32768, std::max(file_size/20, 8192)) & ~0x1FFF;
				}
				
				//parse nodes
				if(safeSeek(4)){
					delete m_root;
					m_root = new NodeStruct();
					m_root->start = 4;
					int byte;
					if(safeSeek(4) && readByte(byte) && byte == NODE_START){
						bool ret = parseNode(m_root);
						return ret;
					}
					else{
						return false;
					}
				}
				else{
					m_lastError = ERROR_INVALID_FORMAT;
					return false;
				}
			}
		}
		else{
			m_lastError = ERROR_CAN_NOT_OPEN;
			return false;
		}
	}
}
Beispiel #7
0
 BmlDecoder (FILE * fp) {
     m_fp = fp;
     //m_table = new Table ();
     m_nbTags = 0;
     m_root = NULL;
     parseTable ();
     m_root = parseNode ();
 }
Beispiel #8
0
	void XMLDecoder::parse( XMLDocument* doc, const void* data, size_t len )
	{
		setData( data, len );
		XMLNode* node = parseDeclaration();
		doc->addNode( node );
		while( ( node = parseNode() ) != NULL )
			doc->addNode( node );
	}
Beispiel #9
0
int ios_plist_to_table(lua_State* L, plist_t iconState)
{
  lua_newtable(L);
  parseNode(L, iconState, 0);
  lua_rawgeti(L, -1, 1);
  lua_remove(L, -2);
  return 1;
}
Beispiel #10
0
// -------------------------------------------------------------------------------
void XMLPersister::parseChildrenOf( QDomNode& node, CTreeInformationElement& parent )
// -------------------------------------------------------------------------------
{
   QDomNode child = node.firstChild();
   while ( !child.isNull() )
   {
      parseNode(child, parent);
      child = child.nextSibling();
   }
}
Beispiel #11
0
void TreeWalker::parseTypeSpecifier(TypeSpecifierAST *node)
{
    parseNode(node->name());
    parseNode(node->cvQualify());
    parseNode(node->cv2Qualify());

    switch (node->nodeType()) {
    case NodeType_ClassSpecifier:
        parseClassSpecifier(static_cast<ClassSpecifierAST*>(node));
        break;
    case NodeType_EnumSpecifier:
        parseEnumSpecifier(static_cast<EnumSpecifierAST*>(node));
        break;
    case NodeType_ElaboratedTypeSpecifier:
        parseElaboratedTypeSpecifier(static_cast<ElaboratedTypeSpecifierAST*>(node));
        break;
    default:
        break;
    }
}
Beispiel #12
0
node* parser::parse ( Stream& istr )
{
  if ( ! istr.good () )
  return 0;

  node* pRoot = new node ( istr );

  parseNode ( istr, pRoot );

  return pRoot;
}
Beispiel #13
0
void Van::init() {
  scheduler_ = parseNode(FLAGS_scheduler);
  myNode_ = parseNode(FLAGS_my_node);
  LOG(INFO) << "I'm \n[" << myNode_.DebugString() << "]";

  context_ = zmq_ctx_new();
  CHECK(context_ != nullptr) << "Create 0mq context failed";

  zmq_ctx_set(context_, ZMQ_MAX_SOCKETS, 65536);
  bind();
  connect(scheduler_);

  if (isScheduler()) {
    CHECK(!zmq_socket_monitor(receiver_, "inproc://monitor", ZMQ_EVENT_ALL));
  } else {
    CHECK(!zmq_socket_monitor(senders_[scheduler_.id()], "inproc://monitor",
                              ZMQ_EVENT_ALL));
  }
  monitorThread_ = new std::thread(&Van::monitor, this);
  monitorThread_->detach();
}
Beispiel #14
0
// загрузка из файла
bool Item::load(QFile *file)
{
    QDomDocument doc;
    if (!doc.setContent(file->readAll())) return false;

    QDomElement docElem = doc.documentElement();

    // переходим к парсингу
    parseNode(docElem);

    return true;
}
//Reads in the file passed in and returns it as an XML node
XMLNode *xmlRead(char* file)
{
	chrPtr = 0;
  loadXMLFile(file);
  XMLNode *docNode = xmlCreateNode(DOCUMENT_NODE, DOCUMENT_NAME, NULL); 
  
  parseNode(docNode);
  
  free(xmlArray);
 
  return docNode;
}
Beispiel #16
0
// загрузка из строки
bool Item::load(const QString &xml)
{
    QDomDocument doc;
    if (!doc.setContent(xml)) return false;

    QDomElement docElem = doc.documentElement();

    // переходим к парсингу
    parseNode(docElem);

    return true;
}
/**
 * Parses a regular expression string and builds a regular expression
 * tree. The root node of that tree is returned.
 * @param string The regular expression string.
 * @param pos The position of the parser in the regular expression.
 * @param len The length of the whole regular expression string.
 * @return The root node of the expression tree.
 * @author Daniel Dreibrodt, Konstantin Steinmiller
 */
RETreeNode *REReaderWriter::parseNode(const char string[], int *pos, int len) {
	if(*pos>=len) {
		//end of string reached
		return NULL;
	}
    switch(string[*pos]) {
    	case '(' : {
    		(*pos)++;
    		RETreeNode *groupNode = parseNode(string, pos, len);
    		return parseNode(groupNode, string, pos, len);
    		break;
    	}
    	case ')' : {
    		throw "Read ')' but that is not allowed here!";
    		break;
    	}
    	case '|' : {
    		throw "Read '|' but that is not allowed here!";
    		break;
    	}
    	case '.' : {
    		throw "Read '.' but that is not allowed here!";
    		break;
    	}
    	case '*' : {
    		throw "Read '*' but that is not allowed here!";
    		break;
    	}
    	case ' ' : {
    		(*pos)++;
    		return parseNode(string, pos, len);
    		break;
    	}
    	default : {
    		RETreeNode *lit = parseLiteral(string,pos,len);
			return parseNode(lit, string, pos, len);
    		break;
    	}
    }
}
Beispiel #18
0
EntityVector Serializer::deserialize()
{
	EntityVector entities;
	QDomNodeList nodes = mDomElement.elementsByTagName(nodeKey);
	for (unsigned i = 0; i < nodes.length(); i++)
	{
		QDomNode node = nodes.at(i);
		QDomElement element = node.toElement();
		Entity entity = parseNode(element);
		entities.push_back(entity);
	}
	return entities;
}
Beispiel #19
0
SgfSequence * Parser::parseSequence(QIODevice & in) {
    SgfSequence * sequence = new Sequence();
    SgfNode * node;
    try {
        while (node = parseNode(in)) {
            sequence->addNode(node);
        }
    } catch (...) {
        delete node;
        delete sequence;
        throw;
    }
}
/*
 * Begin: Parse pwman3 XML Files.
 */
void KeePassXmlStreamReader::parsePwmanList(){
    groupTitle = "pwman3";

    while(xmlReader.readNextStartElement()){
        if(xmlReader.name() == "Node"){
            qDebug("Found Node in pwman3 XML list.");
            parseNode();
        }else{
            qDebug("Skipping pwman3 XML list child element: %s", xmlReader.name().toString().toUtf8().constData());
            xmlReader.skipCurrentElement();
        }
    }
    qDebug("Leaving parsePwmanList...");
}
Beispiel #21
0
StructureDataInformation* OsdParser::structFromXML(const QDomElement& xmlElem)
{
    QString name = xmlElem.attribute(QLatin1String("name"), i18n("<invalid name>"));
    StructureDataInformation* stru = new StructureDataInformation(name);
    QDomNode node = xmlElem.firstChild();
    while (!node.isNull())
    {
        DataInformation* data = parseNode(node, stru);
        if (data)
            stru->addDataTypeToStruct(data);
        node = node.nextSibling();
    }
    return stru;
}
Beispiel #22
0
UnionDataInformation* OsdParser::unionFromXML(const QDomElement& xmlElem)
{
    QString name = xmlElem.attribute(QLatin1String("name"), i18n("<invalid name>"));
    UnionDataInformation* un = new UnionDataInformation(name);
    QDomNode node = xmlElem.firstChild();
    while (!node.isNull())
    {
        DataInformation* data = parseNode(node, un);
        if (data)
            un->addDataTypeToUnion(data);
        node = node.nextSibling();
    }
    return un;
}
Beispiel #23
0
void XMLParser::parseNode(IEntity *entity,QDomNode *node)
{
    while(!node->isNull())
    {
        QString namesp;
        QString name;
        IEntity *auxent = NULL;
        QDomElement child = node->toElement();
        if(!child.isNull())
        {
#ifdef PARSER_DEBUG
            qDebug() << child.tagName();
#endif
            splitNode(child.tagName(),namesp,name);
            if(name.isEmpty())
                throw new XMLParserException("Unable to parse node\n");
            auxent = new IEntity(namesp,name);
        }
        if(node->hasAttributes())
        {
            QDomNamedNodeMap attributes = node->attributes();
            for(unsigned int i=0; i<=attributes.length(); i++)
            {
                QDomNode n = attributes.item(i);
                if(n.isAttr())
                {
#ifdef PARSER_DEBUG
                    qDebug() << n.toAttr().name()<< "=" << n.toAttr().value();
#endif
                    QString attnamesp;
                    QString attname;
                    splitNode(n.toAttr().name(),attnamesp,attname);
                    //TODO: add attribute with namespace
                    auxent->addAttribute(attname,n.toAttr().value());
                }
            }
        }
        if(node->isText())
        {
#ifdef PARSER_DEBUG
            qDebug() << node->toText().data();
#endif
            entity->addValue(node->toText().data());
        } else
            entity->addEntity(auxent);
        if (node->hasChildNodes())
            parseNode(auxent,&node->firstChild());
        node = &(node->nextSibling());
    }
}
Beispiel #24
0
void TreeWalker::parseFunctionDefinition(FunctionDefinitionAST *node)
{
    parseNode(node->functionSpecifier());
    parseNode(node->storageSpecifier());
    parseNode(node->typeSpec());
    parseNode(node->initDeclarator());
    parseNode(node->functionBody());
    parseNode(node->winDeclSpec());
}
Beispiel #25
0
 XmlNode * parseNode () {
     int type = fgetc (m_fp);
     if (type == 3) {
         char * data = decodeString ();
         return new XmlNode (data, CDATA);
     } else if (type > 0) {
         int index = decodeSize ();
         XmlNode * n = new XmlNode (m_tags[index], type == 1 ? OPEN_TAG : SELF_TAG);
         // parse attribute
         int attrIdx = decodeSize (); // index of first attibute
         while (attrIdx != 0) {
             char * value = decodeString ();
             n->addAttribute (new XmlAttribute (m_tags[attrIdx-1], value));
             attrIdx = decodeSize (); // index of next attibute
         }
         XmlNode * child = parseNode ();
         while (child != NULL) {
             n->addChild (child);
             child = parseNode ();
         }
         return n;
     } 
     return NULL;
 }
Beispiel #26
0
// unfortunately we get back all groups double wrapped, seems
// apple was preparing for something that never came, if that
// day does come this might need to go
void flatPackArray(lua_State* L, plist_t node, int depth)
{
  int i;
  if (nodeType(node) == PLIST_ARRAY)
  {
    for (i=0;i<groupSize(node);i++) 
    {
      flatPackArray(L, arrayElem(node, i), depth);
    }      
  }
  else
  {
    parseNode(L, node, depth);
  }
}
Beispiel #27
0
XmlNode * XmlReader::parseNode (XmlNode * node) {
    if (m_failure) { // stop further parsing on failure
        return NULL;
    }
    if (node == NULL) {
        if ( (node = parseElement ()) == NULL) {
            MESSAGE ("Error: cannot parse node at all\n");
            m_failure = true;
            return NULL; // parsing problem
        }
    }
    if (node->m_type == OPEN_TAG) {
        // read while CLOSE_TAG
        XmlNode * child = parseElement ();
        while (child != NULL && child->isClosing (node) == false) {
            if (child->m_type == CDATA) {
                node->addChild (child);
            } else if (child->m_type == SELF_TAG) {
                node->addChild (child);
            } else if (child->m_type == OPEN_TAG) {
                node->addChild (parseNode (child));
            } else if (child->m_type == CLOSE_TAG) { // not closing the right node so error
                MESSAGE ("unexpected closing tag %s for %s\n", child->m_name, node->m_name);
                m_failure = true;
                delete node;
                delete child;
                return NULL;
            }
            child = parseElement ();
        }
        if (child == NULL) {
            return NULL;
        }
        delete child;
    } else if (node->m_type == SELF_TAG || node->m_type == CDATA) {
        ; // nothing to do just return;
    } else if (node->m_type == CLOSE_TAG) { //error
        MESSAGE ("unexpected closing tag %s\n", node->m_name);
        m_failure = true;
        delete node;
        return NULL;
    }
    if (m_failure && node != NULL) {
        delete node;
        return NULL;
    }
    return node;
}
std::vector<LoaderFbxModelDesc> LoaderFbx::load(std::string filename)
{
	meshLoader_->reset();
	materialLoader_->reset();
	textureLoader_->reset();
	animationLoader_->reset();

	modelDescs_.clear();

	bool success = true;

	if(fbxScene_)
	{
		fbxScene_->Destroy();
		fbxScene_ = nullptr;
		success = createFbxScene();
	}
	else
		success = createFbxScene();
	if(success)
		success = loadScene(filename);


	FbxAxisSystem sceneAxisSystem = fbxScene_->GetGlobalSettings().GetAxisSystem();
	FbxAxisSystem xkillAxisSystem(FbxAxisSystem::eDirectX);
	if(sceneAxisSystem != xkillAxisSystem)
		xkillAxisSystem.ConvertScene(fbxScene_);
	
	sceneAxisSystem = fbxScene_->GetGlobalSettings().GetAxisSystem();


	FbxNode* node = fbxScene_->GetRootNode();
	if(node)
	{
		for(int i=0; i<node->GetChildCount(); i++)
			parseNode(node->GetChild(i));
	}


	for(unsigned int i=0; i<modelDescs_.size(); i++)
	{
		std::vector<LoaderFbxAnimationDesc>	animationDescs;
		animationLoader_->parseAnimation(fbxScene_, &animationDescs, modelDescs_[i].getMeshDesc().getBoneNodes());
		modelDescs_[i].setAnimationDescs(animationDescs);
	}
	return modelDescs_;
}
Beispiel #29
0
void TreeWalker::parseDeclarator(DeclaratorAST *node)
{
    parseAll(this, node->ptrOpList());
    parseNode(node->subDeclarator());
    parseNode(node->declaratorId());
    parseNode(node->bitfieldInitialization());
    parseAll(this, node->arrayDimensionList());
    parseNode(node->parameterDeclarationClause());
    parseNode(node->constant());
    parseNode(node->exceptionSpecification());
}
Beispiel #30
0
bool GraphMLHandler::startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts)
{
  if(done)
    return true;
  
  if(!localName.compare("key"))
    return parseKey(atts);
  else if(!localName.compare("graph"))
    return parseGraphElm(atts);
  else if(!localName.compare("node"))
    return parseNode(atts);
  else if(!localName.compare("edge"))
    return parseEdge(atts);
  else if(!localName.compare("data"))
    return parseData(atts);
  
  return true;
}