ConfigFile::ConfigFile(const std::string &fName){
	memset(offsetr,0,3*sizeof(double));
	memset(offsetp,0,3*sizeof(double));
   	memset(gravity,0,3*sizeof(double));
	camNear=camFar=-1;
        enablePhysics=0;
	try
	{
		xmlpp::DomParser parser;
		parser.set_validate();
		parser.set_substitute_entities(); //We just want the text to be resolved/unescaped automatically.
		std::string fName_fullpath=osgDB::findDataFile(fName);
		if (fName_fullpath!=std::string("")) {
			parser.parse_file(fName_fullpath);
			if(parser)
			{
				//Walk the tree:
				const xmlpp::Node* pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
				processXML(pNode);
			}
		} else {
			std::cerr << "Cannot locate file " << fName <<  std::endl;
			exit(0);
		}
	}
	catch(const std::exception& ex)
	{
		std::cerr << "Exception caught: " << ex.what() << std::endl;
		std::cerr << "Please check your XML file" << std::endl;
		exit(0);
	}

}
Ejemplo n.º 2
0
void Peer::PushMessage(const std::string& msg) {
    for(int i = 0; i < msg.size(); i++) {
        xmlBuffer.push_back( msg[i] );
        if ( msg[i] == '>') {
            processXML();
            xmlBuffer.clear();
        }
    }            
}
Ejemplo n.º 3
0
int processStationLinesXML()
{
    int ret = processXML(
                  "processStationLinesXML", // description
                  "StationLines.xml",       // xml file
                  "StationLines",           // xml node
                  "StationLines",           // master table
                  "StationLineRecord");     // record table
    initStationLinesLookup();
    return ret;
}
Ejemplo n.º 4
0
void XDNet::slotReadBuffer()
{
  long xmlSize;
  QString buffer;
  char ch;
  long read = 0;
  long totalread;
  QString str;

  do
  {
    buffer = "";

    while((ch = m_socket->getch()) != 0)
    {
      buffer += ch;
    }

    xmlSize = buffer.toLong();
    char data[xmlSize+1];

    totalread = 0;
    int aa;
    while(totalread != xmlSize)
    {
      aa = m_socket->bytesAvailable();
      read = m_socket->readBlock(&data[totalread], xmlSize-totalread);

      if(read == -1)
      {
        return;
      }

      //       if(read == 0) break;
      if(read == 0)
      {
        m_socket->waitForMore (-1, 0L);
      }

      totalread += read;
    }


    data[xmlSize] = 0;
    //     if(m_superglobalsCount == 9) {
    //       std::cerr << "read: " << totalread << ", datalen: [" << xmlSize << "]>>>>\n" << data << "\n<<<\n" << std::endl;
    //     }

    str.setAscii(data,xmlSize);
    processXML(str);

  }
  while(m_socket->bytesAvailable());
}
Ejemplo n.º 5
0
/// Load from a string in memory
Node::SPtr SceneLoaderXML::loadFromMemory ( const char *filename, const char *data, unsigned int size )
{
    notifyLoadingScene();

    xml::BaseElement* xml = xml::loadFromMemory (filename, data, size );

    Node::SPtr root = processXML(xml, filename);

    delete xml;
    return root;
}
/// Load from a string in memory
Node::SPtr SceneLoaderXML::loadFromMemory ( const char *filename, const char *data, unsigned int size )
{
    //::sofa::simulation::init();
    // 				std::cerr << "Loading simulation XML file "<<filename<<std::endl;
    xml::BaseElement* xml = xml::loadFromMemory (filename, data, size );

    Node::SPtr root = processXML(xml, filename);

    // 				std::cout << "load done."<<std::endl;
    delete xml;

    return root;
}
Ejemplo n.º 7
0
sofa::simulation::Node::SPtr SceneLoaderXML::load(const char *filename)
{
    sofa::simulation::Node::SPtr root;

    if (!canLoadFileName(filename))
        return 0;

    notifyLoadingScene();

    xml::BaseElement* xml = xml::loadFromFile ( filename );
    root = processXML(xml, filename);

    delete xml;

    return root;
}
sofa::simulation::Node::SPtr SceneLoaderXML::load(const char *filename)
{
    sofa::simulation::Node::SPtr root;

    if (!canLoadFileName(filename))
        return 0;

    //::sofa::simulation::init();
    // 				std::cerr << "Loading simulation XML file "<<filename<<std::endl;
    xml::BaseElement* xml = xml::loadFromFile ( filename );

    root = processXML(xml, filename);

    // 				std::cout << "load done."<<std::endl;
    delete xml;

    return root;
}
Ejemplo n.º 9
0
void Peer::onReadEvent(talk_base::AsyncSocket* socket) {
    unsigned char temp[2048];

    int ret = sock_->Recv(temp, sizeof(temp) - 1);
    if ( ret > 0) {
        temp[ret] = 0;

        //std::cout << "\t<===: " << temp << std::endl;
        std::string tempStr("\t<===: ");
        tempStr = tempStr + std::string( (const char *)temp );
        SignalPrintString( tempStr );

        for(int i = 0;i < ret; i++) {
            xmlBuffer.push_back( temp[i] );
            if ( temp[i] == '>') {
                processXML();        
                xmlBuffer.clear();
            }
        }
    }
}
Ejemplo n.º 10
0
int processProductsXML()
{
	int ret = 0;

	const char* s_subtableDeleteQuery =
		"DELETE FROM ProductAttribute WHERE "
		"NOT FK_ProductRecord IN (SELECT PrimaryKey FROM ProductRecord); "
		"DELETE FROM ProductDefaultAttribute WHERE "
		"NOT FK_ProductRecord IN (SELECT PrimaryKey FROM ProductRecord);";

	ret = processXML(
		"processProductsXML", // description
		"Products.xml",       // xml file
		"Products",           // xml node
		"Products",           // master table
		"ProductRecord",      // record table
		processProductsSubtableXML,
		s_subtableDeleteQuery);

	initProductsLookup();
	return ret;
}