Exemple #1
0
	/* From XSLT_StylesheetParser::Callback: */
	virtual OP_STATUS LoadOtherStylesheet(URL stylesheet_url, XMLTokenHandler *token_handler, BOOL is_import)
	{
		if (!thread)
			return OpStatus::ERR;

		FramesDocument *doc = thread->GetScheduler()->GetFramesDocument();

		if (!DOM_XSLTAllowAccess(OpSecurityManager::XSLT_IMPORT_OR_INCLUDE, doc, stylesheet_url))
			/* FIXME: Should send a console message saying why here. */
			return OpStatus::ERR;

		XMLParser *parser;

		RETURN_IF_ERROR(XMLParser::Make(parser, NULL, doc, token_handler, stylesheet_url));

		OP_STATUS status = parser->Load(doc->GetURL(), TRUE);

		if (OpStatus::IsError(status))
		{
			OP_DELETE(parser);
			return status;
		}

		return OpStatus::OK;
	}
Exemple #2
0
int main(int argc, char **argv)
{
  std::string nodeName = "node";
  std::string hostName = "localhost";
  std::string configFile = "";
  
  for(int i = 0; i < argc; i++)
  {
    if(!strcmp(argv[i], "-nodename"))
      nodeName = argv[i+1];
    if(!strcmp(argv[i], "-hostname"))
      hostName = argv[i+1];
    if(!strcmp(argv[i], "-config"))
      configFile = argv[i+1];
  }

  std::vector<boost::thread*> compThreads;
  XMLParser nodeParser;
  std::string configFileName = nodeName + ".xml";
  if (configFile.length() > 0)
    configFileName = configFile;
  if (nodeParser.Parse(configFileName))
  {      
    ros::init(argc, argv, nodeName.c_str());

    // Create Node Handle
    ros::NodeHandle n;

    ROS_INFO_STREAM(nodeName << " thread id = " << boost::this_thread::get_id());
    
    for (int i=0;i<nodeParser.compConfigList.size();i++)
    {
      std::string libraryLocation = nodeParser.compConfigList[i].libraryLocation;
      void *hndl = dlopen(libraryLocation.c_str(), RTLD_NOW);
      if(hndl == NULL)
      {
	cerr << dlerror() << endl;
	exit(-1);
      }
      void *mkr = dlsym(hndl, "maker");
      Component *comp_inst = ((Component *(*)(ComponentConfig &, int , char **))(mkr))
	(nodeParser.compConfigList[i], argc, argv);

      // Create Component Threads
      boost::thread *comp_thread = new boost::thread(componentThreadFunc, comp_inst);
      compThreads.push_back(comp_thread);
      ROS_INFO_STREAM(nodeName << " has started " << nodeParser.compConfigList[i].compName);
    }
    for (int i=0;i<compThreads.size();i++)
    {
      compThreads[i]->join();
    }
    return 0; 
  }
  else
  {
    printf("ERROR::Unable to parse XML file\n");
    return -1;
  }
}
Exemple #3
0
void MainDlg::parseListDotXml() {
    //extract ZIP file
    bool extracted = FileTools::getInstance()->unzip(tmpDir, "/list.zip");
    if (!extracted) {
        //TODO: get error message
        hasError = true;
    }

    //verify MD5 sum.
    QString calculatedMd5 = md5::md5FromFile(tmpDir.path()+"/list.xml");
    QFile md5File(tmpDir.path()+"/list.md5");
    if (!md5File.open(QIODevice::ReadOnly)) {
        hasError = true;
    } else {
        QString originalMd5(md5File.readLine());
        if (originalMd5.compare(calculatedMd5)) {
            hasError = true;
        }
    }

    //actually parse XML file
    if (!hasError) {
        XMLParser xml;

        connect(&xml, SIGNAL(hasNewItem(SoftwareEntry*)), this, SLOT(addSoftwareEntry(SoftwareEntry*)));
        connect(&xml, SIGNAL(finished()), this, SLOT(buildTabContent()));

        xml.readFile(tmpDir.path()+"/list.xml");
    }
void DictionaryInfo::ReadLangTo(const GUTF8String& str, bool bEncoded)
{
	strLangToCode = "";
	langToLoc.clear();

	if (str.length() == 0)
		return;

	string strTemp = str;
	if (bEncoded)
		Base64Decode(strTemp);

	strLangToRaw = strTemp.c_str();

	stringstream sin(strTemp.c_str());
	XMLParser parser;
	if (parser.Parse(sin))
	{
		wstring strCode;
		if (parser.GetRoot()->GetAttribute(pszAttrCode, strCode))
			strLangToCode = MakeUTF8String(strCode);

		ReadLocalizedStrings(langToLoc, *parser.GetRoot());
	}
}
	HRESULT XmlFileParser::LoadXMLFile( const CHAR* strFilename,void* pNode,UINT nType)
	{
		XMLParser parser;
		XmlFileParser XATGParser;

		g_strParseError[0] = '\0';
		
		localFind = true;
		m_nType = nType;
		if(m_nType == 1)
		{
			pArcadeInfo = (ArcadeInfo*)pNode;
		}

		parser.RegisterSAXCallbackInterface( &XATGParser );


		HRESULT hr = parser.ParseXMLFile( strFilename );

		if( SUCCEEDED( hr ) )
		{

		}
		return hr;
	}
int main()
{
    XMLParser   parser;
    ub4         flags;
    uword       ecode;
    flags = XML_FLAG_VALIDATE | XML_FLAG_DISCARD_WHITESPACE;

    cout << "\nXML C++ DOM Namespace\n";

    cout << "Initializing XML package...\n";

    if (ecode = parser.xmlinit())
    {
        cout << "Failed to initialize XML parser, error " << ecode;
        return 1;
    }

    cout << "Parsing '" << DOCUMENT << "'...\n";
    cout.flush();
    if (ecode = parser.xmlparse((oratext *) DOCUMENT, (oratext *) 0, flags))
	return 1;

    cout << "\nThe elements are:\n";
    dump(parser.getDocumentElement());

    (void) parser.xmlterm();	// terminate LPX package

    return 0;
}
Exemple #7
0
void ChatLayer::requestFinishedCallback(CCNode* pSender,void *data)
{
    CCHttpResponse *response =  (CCHttpResponse*)data;
	if(response==NULL)
	{
		return;
	}
	int statusCode = response->getResponseCode();
	char statusString[64] = {};
	CCLOG(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());

	if (!response->isSucceed())   
	{  
		CCLog("response failed");  
		CCLog("error buffer: %s", response->getErrorBuffer());  
		return;  
	}
	std::vector<char> *buffer = response->getResponseData(); 

	std::string content(buffer->begin(),buffer->end());

	XMLParser *xmlParser = XMLParser::parseWithString(content.c_str());
	CCLOG("%s",xmlParser->getString("content")->getCString());

//	parseJson();
}
Exemple #8
0
void Container::loadCache(std::string fichier, QTreeWidget *treeView){
    std::cout << "Opening file \"" << fichier << "\"" << std::endl;

    XMLParser *xmlParser = new XMLParser(fichier.c_str());
    this->root = xmlParser->parseProject();
    this->addProject(treeView, this->root);
}
Exemple #9
0
static void
parser_start_element (GMarkupParseContext  *context,
                      const gchar          *element_name,
                      const gchar         **attribute_names,
                      const gchar         **attribute_values,
                      gpointer              user_data,
                      GError              **error)
{
  XMLParserState  new_state;
  XMLParser      *parser = (XMLParser *) user_data;

  switch (parser->state)
    {
    case XML_PARSER_STATE_TOPLEVEL:
    default:
      if (parser->start_element &&
          (new_state = parser->start_element (parser->state,
                                              element_name,
                                              attribute_names,
                                              attribute_values,
                                              parser->user_data,
                                              error)))
        {
          parser->last_state = parser->state;
          parser->state      = new_state;
          break;
        }
      /* else fallthru */
    case XML_PARSER_STATE_UNKNOWN:
      parser_start_unknown (parser);
      break;
    }

  g_string_truncate (parser->cdata, 0);
}
Exemple #10
0
void validateXml(const string& sXML, const string& sSchema, const string& sXMLName,
        const string& sSchemaName)
{
    XMLParser parser;
    parser.setSchema(sSchema, sSchemaName);

    parser.parse(sXML, sXMLName);
}
Exemple #11
0
int NBUSPacket::parseHeader(void *data, unsigned int length)
{
	XMLParser *pXmlParser = XMLParser::getInstance();

	IXML *pIXml = pXmlParser->parseXML((char *)data, length);

	if (pIXml == NULL)
	{
		delete pXmlParser;
		LOGE("Header XML corruption");
		return -1;
	}

	this->mHeaderLength = length;
	this->mpXml = pIXml;

	if (pIXml->getXMLType() == XML_TYPE_EVENT)
	{
		EventXML *pEventXml = (EventXML *)pIXml;

		this->mpXml = pEventXml;

		this->mDataLength = pEventXml->getLength();

		this->mPacketLength = strlen(NBUS_PACKET_START_CODE) + NBUS_PACKET_HEADER_LEGNTH_BYTES + this->mHeaderLength + this->mDataLength;
		this->mpPacket = new char[this->mPacketLength];

		memcpy(this->mpPacket, NBUS_PACKET_START_CODE, strlen(NBUS_PACKET_START_CODE));

		this->mpHeader = (char *)this->mpPacket + strlen(NBUS_PACKET_START_CODE) + NBUS_PACKET_HEADER_LEGNTH_BYTES;

		memcpy(this->mpHeader, data, length);

		if (this->mDataLength)
		{
			this->mpData = (char *)this->mpHeader + this->mHeaderLength;
		}
	}
	else if (pIXml->getXMLType() == XML_TYPE_COMMAND)
	{
		CommandXML *pCmdXml = (CommandXML *)pIXml;

		this->mpXml = pCmdXml;

		this->mPacketLength = strlen(NBUS_PACKET_START_CODE) + NBUS_PACKET_HEADER_LEGNTH_BYTES + this->mHeaderLength;
		this->mpPacket = new char[this->mPacketLength];

		memcpy(this->mpPacket, NBUS_PACKET_START_CODE, strlen(NBUS_PACKET_START_CODE));

		this->mpHeader = (char *)this->mpPacket + strlen(NBUS_PACKET_START_CODE) + NBUS_PACKET_HEADER_LEGNTH_BYTES;

		memcpy(this->mpHeader, data, length);
	}

	delete pXmlParser;

	return 0;
}
	//----------------------------------------------------------------------
	StatementData DeclareTextureSampleNodeProcessor::ProcessAsRoot( XMLParser& parser, XMLNode* node )
	{
		if( parser.validateXMLAttributes( node, "name,textureSampleName","" ) )
		{
			std::string name = parser.getXMLAttributeAsString( node, "name", "" );
			m_shaderGenerator->AddUniform( "Texture2D", name );
		}
		return StatementData();
	}
Exemple #13
0
XMLParser* XMLParser::parseWithFile(const char *xmlFileName) {
	XMLParser *pXMLParser = new XMLParser();
	if (pXMLParser->initWithFile(xmlFileName)) {
		pXMLParser->autorelease();
		return pXMLParser;
	}
	CC_SAFE_DELETE(pXMLParser);
	return NULL;
}
Exemple #14
0
XMLParser* XMLParser::parseWithString(const char *content) {
	XMLParser *pXMLParser = new XMLParser();
	if (pXMLParser->initWithString(content)) {
		pXMLParser->autorelease();
		return pXMLParser;
	}
	CC_SAFE_DELETE(pXMLParser);
	return NULL;
}
Exemple #15
0
bool Job::createFromFile(QString filename)
{
	XMLParser bitsParser;
	Task *tempTask;
	QFile *xmlFile = new QFile(filename);
	bitsParser.parseFile(xmlFile);
	
	QMapIterator<QString, QMap<QString,QVariant> > it(bitsParser.properties);
	while (it.hasNext())
	{
		it.next();
		if (it.key() == "Job")
			setAttributeValue("Filename",filename);
		else if (it.key() == "Task")
		{
			tempTask = new Task;
			tempTask->setAttributeValue("Filename",filename);
		}
		else
			continue;
		
		QMapIterator<QString,QVariant> j(it.value());
		while (j.hasNext())
		{
			j.next();
			if (it.key() == "Job")
			{
				addAttribute(j.key());
				setAttributeValue(j.key(),j.value());
			}
			else if (it.key() == "Task" && tempTask)
			{
				if (j.key() != "Name" && j.key() != "StartDate" && j.key() != "EndDate" && j.key() != "TimeSpent" && j.key() != "TaskID" && j.key() != "HotKey" && j.key() != "Completed")
					tempTask->addAttribute(j.key());
				tempTask->setAttributeValue(j.key(),j.value());
			}
		}
		if (it.key() == "Task" && tempTask)
		{
			if (tempTask->isValid())
				addTask(tempTask);	
			else
				emit statusChanged("Invalid Task not added!");
		}
			
	}
	if (isValid())
	{
		makeTaskIDs();
		writeConfigFile();
	}
	else
		emit statusChanged(QString("Invalid Job in %1 not added!").arg(filename));
	xmlFile->close();
	delete xmlFile;
	return true;
}
Exemple #16
0
void XMLParser::handleError( void *pArg,  const char *pMsg,
                             xmlParserSeverities severity,
                             xmlTextReaderLocatorPtr locator)
{
    XMLParser *pThis = (XMLParser*)pArg;
    int line = xmlTextReaderLocatorLineNumber( locator );
    msg_Err( pThis->getIntf(), "XML parser error (line %d) : %s", line, pMsg );
    pThis->m_errors = true;
}
ParserElement::ref StringTreeParser::parse(const std::string &xml) {
	PlatformXMLParserFactory factory;
	DefaultStringTreeParser client;
	XMLParser *parser = factory.createXMLParser(&client);
	
	parser->parse(xml);
	ParserElement::ref root = client.getRoot();
	delete parser;
	return root;
}
Exemple #18
0
	void D3DCEGUI::init(ID3D11Device *pD3D11Device, ID3D11DeviceContext *pD3D11DeviceContext)
	{
		// create renderer and enable extra states
		Direct3D11Renderer& cegui_renderer = Direct3D11Renderer::create(pD3D11Device, pD3D11DeviceContext);
		//	cegui_renderer.enableExtraStateSettings(true);

		// create CEGUI system object
		CEGUI::System::create(cegui_renderer);

		// setup resource directories
		DefaultResourceProvider* rp = static_cast<DefaultResourceProvider*>(System::getSingleton().getResourceProvider());
		rp->setResourceGroupDirectory("schemes", "../../media/datafiles/schemes/");
		rp->setResourceGroupDirectory("imagesets", "../../media/datafiles/imagesets/");
		rp->setResourceGroupDirectory("fonts", "../../media/datafiles/fonts/");
		rp->setResourceGroupDirectory("layouts", "../../media/datafiles/layouts/");
		rp->setResourceGroupDirectory("looknfeels", "../../media/datafiles/looknfeel/");
		rp->setResourceGroupDirectory("lua_scripts", "../../media/datafiles/lua_scripts/");
		rp->setResourceGroupDirectory("schemas", "../../media/datafiles/xml_schemas/");

		// set default resource groups
		ImageManager::setImagesetDefaultResourceGroup("imagesets");
		CEGUI::Font::setDefaultResourceGroup("fonts");
		Scheme::setDefaultResourceGroup("schemes");
		WidgetLookManager::setDefaultResourceGroup("looknfeels");
		WindowManager::setDefaultResourceGroup("layouts");
		ScriptModule::setDefaultResourceGroup("lua_scripts");

		XMLParser* parser = System::getSingleton().getXMLParser();
		if (parser->isPropertyPresent("SchemaDefaultResourceGroup"))
			parser->setProperty("SchemaDefaultResourceGroup", "schemas");

		// load TaharezLook scheme and DejaVuSans-10 font
		SchemeManager::getSingleton().createFromFile("TaharezLook.scheme", "schemes");
		FontManager::getSingleton().createFromFile("DejaVuSans-10.font");

		// set default font and cursor image and tooltip type
		System::getSingleton().getDefaultGUIContext().setDefaultFont("DejaVuSans-10");
		System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");
		System::getSingleton().getDefaultGUIContext().setDefaultTooltipType("TaharezLook/Tooltip");

		/////////////////////////////////////////////////////////////
		// Add your gui initialisation code in here.
		// You should preferably use layout loading because you won't
		// have to recompile everytime you change the layout. But you
		// can also use static window creation code here, of course.
		/////////////////////////////////////////////////////////////

		//System::getSingleton().notifyDisplaySizeChanged(Sizef(800.f, 600.f));

		// load layout
		Window* root = WindowManager::getSingleton().loadLayoutFromFile("application_templates.layout");
		System::getSingleton().getDefaultGUIContext().setRootWindow(root);
		// notify system of the window size
		renderer= static_cast<Direct3D11Renderer*>(System::getSingleton().getRenderer());
	}
	//--------------------------------------------------
	ChorusDSP::ChorusDSP( XMLParser& parser, XMLNode* chorusNode )
		:	DSP( MONKY_DSP_TYPE_CHORUS )
	{
		const float NO_VALUE_SPECIFIED = -1000000000.0f;
		parser.validateXMLChildElements( chorusNode, "", "WetVolume" );
		parser.validateXMLAttributes( chorusNode, "", "type,dryVolume,delayMS,modulationRate,modulationDepth" );
		float dryVolume = parser.getXMLAttributeAsFloat( chorusNode, "dryVolume", NO_VALUE_SPECIFIED );
		float delay = parser.getXMLAttributeAsFloat( chorusNode, "delayMS", NO_VALUE_SPECIFIED );
		float modulationRate = parser.getXMLAttributeAsFloat( chorusNode, "modulationRate", NO_VALUE_SPECIFIED );
		float modulationDepth = parser.getXMLAttributeAsFloat( chorusNode, "modulationDepth", NO_VALUE_SPECIFIED );
				
		for( const XMLNode* wetNode = chorusNode->FirstChildElement( "WetVolume" ); wetNode != nullptr; wetNode = wetNode->NextSiblingElement( "WetVolume" ) )
		{
			parser.validateXMLAttributes( wetNode, "channel,volume", "" );
			int channel = parser.getXMLAttributeAsInt( wetNode, "channel", -1 );
			float volume = parser.getXMLAttributeAsFloat( wetNode, "volume", 0.0f );
			if( channel > 0 )
				setWetMixVolume( channel, volume );
		}

		if( dryVolume != NO_VALUE_SPECIFIED )
			setDryMixVolume( dryVolume );
		if( delay != NO_VALUE_SPECIFIED )
			setDelayMS( delay );
		if( modulationRate != NO_VALUE_SPECIFIED )
			setModulationRate( modulationRate );
		if( modulationDepth != NO_VALUE_SPECIFIED )
			setModulationDepth( modulationDepth );
	}
void
dmz::ArchivePluginAutoSave::update_plugin_state (
      const PluginStateEnum State,
      const UInt32 Level) {

   if (State == PluginStateStart) {

      if (_firstStart && _saveFile && is_valid_path (_saveFile) && _archiveMod) {

         _log.info << "Restoring from auto save archive: " << _saveFile << endl;

         Config global ("global");
         XMLParser parser;
         XMLInterpreterConfig interpreter (global);
         parser.set_interpreter (&interpreter);

         FILE *file = open_file (_saveFile, "rb");

         if (file) {

            Boolean error (False);
            String buffer;

            while (read_file (file, 1024, buffer) && !error) {

               const Int32 Length = buffer.get_length ();
               const char *cbuf = buffer.get_buffer ();

               if (!parser.parse_buffer (cbuf, Length, Length < 1024)) {

                  error = True;
                  _log.error << "Unable to restore from auto save archive: " << _saveFile
                     << " : " << parser.get_error ();
               }
            }

            close_file (file);

            Config data;

            if (!error && global.lookup_all_config_merged ("dmz", data)) {

               _archiveMod->process_archive (_archiveHandle, data);
            }
         }
      }

      _firstStart = False;
   }
   else if (State == PluginStateShutdown) {

      if (is_valid_path (_saveFile)) { remove_file (_saveFile); }
   }
}
	//-----------------------------------------------------
	OscillatorDSP::OscillatorDSP( XMLParser& parser, XMLNode* oscillatorNode )
		:	DSP( MONKY_DSP_TYPE_OSCILLATOR )
	{
		const float NO_VALUE_SPECIFIED = -1000000000.0f;
		parser.validateXMLAttributes( oscillatorNode, "", "type,oscillatorType,freq" );
		std::string typeStr = parser.getXMLAttributeAsString( oscillatorNode, "oscillatorType", "SINE" );
		float freq = parser.getXMLAttributeAsFloat( oscillatorNode, "freq", NO_VALUE_SPECIFIED );

		setType( getOscillatorType( typeStr ) );
		if( freq != NO_VALUE_SPECIFIED )
			setFrequency( freq );
	}
Exemple #22
0
void Container::saveCache(std::string fichier){
    XMLParser *xmlParser = new XMLParser(fichier.c_str());
    xmlParser->setListRoot(this->root, PROJECT_TAG);
    if ( xmlParser->save_file(fichier.c_str()) )
    {
        std::cout << "Save project at \""<< fichier.c_str() << "\"" << std::endl;
    }
    else
    {
        std::cout << "Can't save project at \"" << fichier.c_str() << "\"" << std::endl;
    }
}
bool ExportMaterialDatabase::Initialize( const CHAR* strFileName )
{
    MaterialDatabaseReader mdr;
    XMLParser xp;
    xp.RegisterSAXCallbackInterface( &mdr );
    HRESULT hr = xp.ParseXMLFile( strFileName );
    if( hr == S_OK )
    {
        strcpy_s( g_strMaterialDBFileName, strFileName );
    }
    return ( hr == S_OK );
}
void SimulationOptions::generateConfigFile( const std::string & filename )
{
	XMLParser xmlOpts;
	_setupXMLStructure(xmlOpts);

	if (fileCanBeOpened(filename)) {
		throw GenericException("Cannot generate config file \"" + filename + "\", file already exists.");
	}

	xmlOpts.writeXMLFile(filename);

	std::cout << "Default configuration written to " << filename << ".\n";
}
Exemple #25
0
OP_STATUS
WebFeedStorage::LocalLoad(const uni_char *file_name)
{
	OP_STATUS oom = OpStatus::OK;

	OpFile feed_file;
	OpStringC file_name_str(file_name);
	oom = feed_file.Construct(file_name_str.CStr(), OPFILE_WEBFEEDS_FOLDER);
	if (OpStatus::IsError(oom))
		return oom;

	UnicodeFileInputStream in_stream;
	RETURN_IF_ERROR(in_stream.Construct(&feed_file, URL_XML_CONTENT, TRUE));

	XMLParser *parser;
	URL dummy;
	RETURN_IF_ERROR(XMLParser::Make(parser, NULL, g_main_message_handler, this, dummy));
	OpStackAutoPtr<XMLParser> protected_parser(parser);

	// Set up XML configuration for parsing web feed storage:
	XMLParser::Configuration configuration;
	configuration.load_external_entities = XMLParser::LOADEXTERNALENTITIES_NO;
	configuration.max_tokens_per_call = 0;  // unlimited
#if defined(_DEBUG) && defined(XML_ERRORS)
	configuration.generate_error_report = TRUE;
#endif

	parser->SetConfiguration(configuration);

	int buf_len = 2048;

	BOOL more = in_stream.has_more_data();
	while (OpStatus::IsSuccess(oom) && more && !parser->IsFailed())
	{
		uni_char *buf = in_stream.get_block(buf_len);
		more = in_stream.has_more_data();

		OP_ASSERT(buf_len % sizeof(uni_char) == 0);
		buf_len /= sizeof(uni_char);

		OP_ASSERT(buf);
		if (!buf)
			return OpStatus::ERR;
		
		oom = parser->Parse(buf, buf_len, more);
		OP_ASSERT(!parser->IsFailed());
#if defined(_DEBUG) && defined XML_ERRORS
		if (parser->IsFailed())
		{
			XMLRange range;
			const char *error, *url, *fragment;
		
			range = parser->GetErrorPosition();
			parser->GetErrorDescription(error, url, fragment);
		}
#endif // defined(_DEBUG) && defined(XML_ERRORS)
	}

	return OpStatus::OK;
}
//
// loadOptionsFromConfigFile() - any values specified in the config file will override the original hard-coded defaults.
//
void SimulationOptions::loadOptionsFromConfigFile( const std::string & filename )
{
	XMLParser xmlOpts;
	_setupXMLStructure(xmlOpts);

	if (fileCanBeOpened(filename)) {
		xmlOpts.parseXMLFile(filename, true);
	}
	else {
		throw GenericException("Cannot find the specified config file \"" + filename + "\".");
	}

	/*
	// debugging output, keep it here for now
	std::cout << "CONFIG-FILE DEFAULTS:\n";
	for (ModuleOptionsDatabase::iterator iter = moduleOptionsDatabase.begin(); iter != moduleOptionsDatabase.end(); ++iter) {
		std::cout << "module \"" << (*iter).first << "\"\n";
		for (OptionDictionary::iterator k = (*iter).second.begin(); k != (*iter).second.end(); ++k) {
			std::cout << "    " << (*k).first << " --> " << (*k).second << "\n";
		}
		std::cout << "\n";
	}
	*/


	//
	// do error checking and option conversions next, try to be user-friendly where possible.
	//

	/// @todo add some path-cleanup and error checking here in SimulationOptions.cpp.

	// transform clockMode option to lower case
	engineOptions.clockMode = Util::toLower(engineOptions.clockMode);

	if ((engineOptions.clockMode != "fixed-fast") && (engineOptions.clockMode != "fixed-real-time") && (engineOptions.clockMode != "variable-real-time")) {
		std::cerr << "WARNING: Bad option value for clockMode in configuration file.\n         Valid options are: \"fixed-fast\", \"fixed-real-time\" or \"variable-real-time\".\n         For now, setting default to \"fixed-fast\", which may be overridden by command-line or GUI.";
		engineOptions.clockMode = "fixed-fast";
	}

	glfwEngineDriverOptions.stereoMode = Util::toLower(glfwEngineDriverOptions.stereoMode);
	if ((glfwEngineDriverOptions.stereoMode != "off") &&
		(glfwEngineDriverOptions.stereoMode != "side-by-side") &&
		(glfwEngineDriverOptions.stereoMode != "top-and-bottom") &&
		(glfwEngineDriverOptions.stereoMode != "quadbuffer"))
	{
		std::cerr << "WARNING: Bad option value for stereoMode in configuration file.\n         Valid options are: \"off\", \"side-by-side\", \"top-and-bottom\", or \"quadbuffer\".\n         For now, setting default to \"" << DEFAULT_STEREO_MODE <<  "\", which may be overridden by command-line or GUI.";

		glfwEngineDriverOptions.stereoMode = DEFAULT_STEREO_MODE;
	}
}
Exemple #27
0
	//---------------------------------------------------
	TremoloDSP::TremoloDSP( XMLParser& parser, XMLNode* tremoloNode )
		:	DSP( MONKY_DSP_TYPE_TREMOLO )
	{
		const float NO_VALUE_SPECIFIED = -1000000000.0f;
		parser.validateXMLAttributes( tremoloNode, "", "type,frequency,depth,shape,timeSkewing,duty,flatness,phase,spread" );
		float frequency = parser.getXMLAttributeAsFloat( tremoloNode, "frequency", NO_VALUE_SPECIFIED );
		float depth = parser.getXMLAttributeAsFloat( tremoloNode, "depth", NO_VALUE_SPECIFIED );
		float shape = parser.getXMLAttributeAsFloat( tremoloNode, "shape", NO_VALUE_SPECIFIED );
		float timeSkewing = parser.getXMLAttributeAsFloat( tremoloNode, "timeSkewing", NO_VALUE_SPECIFIED );
		float duty = parser.getXMLAttributeAsFloat( tremoloNode, "duty", NO_VALUE_SPECIFIED );
		float flatness = parser.getXMLAttributeAsFloat( tremoloNode, "flatness", NO_VALUE_SPECIFIED );
		float phase = parser.getXMLAttributeAsFloat( tremoloNode, "phase", NO_VALUE_SPECIFIED );
		float spread = parser.getXMLAttributeAsFloat( tremoloNode, "spread", NO_VALUE_SPECIFIED );

		if( frequency != NO_VALUE_SPECIFIED )
			setFrequency( frequency );
		if( depth != NO_VALUE_SPECIFIED )
			setDepth( depth );
		if( shape != NO_VALUE_SPECIFIED )
			setShape( shape );
		if( timeSkewing != NO_VALUE_SPECIFIED )
			setTimeSkewing( timeSkewing );
		if( duty != NO_VALUE_SPECIFIED )
			setDuty( duty );
		if( flatness != NO_VALUE_SPECIFIED )
			setFlatness( flatness );
		if( phase != NO_VALUE_SPECIFIED )
			setPhase( phase );
		if( spread != NO_VALUE_SPECIFIED )
			setSpread( spread );
	}
Exemple #28
0
bool FairyMenu::init()
{
    bool bRet = false;
    do 
    {
        CC_BREAK_IF(! CCLayer::init());
		AnimatePacker::getInstance()->loadAnimations("skill/loading.xml"); 
		CCString *fileName = CCString::createWithFormat(BattleMusic, 2);
		SimpleAudioEngine::sharedEngine()->playBackgroundMusic(fileName->getCString(), true);
        CCSize size = CCDirector::sharedDirector()->getWinSize();
		CCSprite *fairyMenuBack = CCSprite::create(menuBack);
		this->addChild(fairyMenuBack);
		fairyMenuBack->setPosition(ccp(size.width / 2, size.height / 2));
		CCSprite *fairyMenuMenu = CCSprite::create(menuMenu);
		this->addChild(fairyMenuMenu);
		fairyMenuMenu->setPosition(ccp(size.width / 2, size.height / 2 - 100));
		CCSprite *menuLoading=CCSprite::create();
		this->addChild(menuLoading);
		menuLoading->setPosition(ccp(size.width/2, size.height/2 + 60));
		menuLoading->runAction(CCRepeatForever::create(AnimatePacker::getInstance()->getAnimate("loading")));
		int itemPosition[3][2]  = {{5, 0 - 90 }, {5, -205}, {5, 0 - 310}};
		XMLParser *scene = XMLParser::parseWithFile("data/common.xml");
		CCString* menuStart = scene->getString("menu_start");
		CCString* menuIntro = scene->getString("menu_intro");
		CCString* menuExit = scene->getString("menu_exit");
		CCMenu* menu = CCMenu::create();
		for(int i =0; i < 3; i++){
			CCSprite* fairyMenuButton = CCSprite::create(menuItem);
			CCMenuItemSprite* fairyMenuButtonItem = CCMenuItemSprite::create(fairyMenuButton, fairyMenuButton, this, menu_selector(FairyMenu::fairyMenuCallback));
			fairyMenuButtonItem->setPosition(ccp(itemPosition[i][0] ,itemPosition[i][1]));
			fairyMenuButtonItem->setTag(i + 1);
			menu->addChild(fairyMenuButtonItem);
		}
		this->addChild(menu);
		CCLabelTTF* fairyMenuStart = CCLabelTTF::create(menuStart->getCString(), "Arial", 30);
		this->addChild(fairyMenuStart);
		fairyMenuStart->setPosition(ccp(size.width/2, size.height/2 - 90));
		CCLabelTTF* fairyMenuIntro = CCLabelTTF::create(menuIntro->getCString(), "Arial", 30);
		this->addChild(fairyMenuIntro);
		fairyMenuIntro->setPosition(ccp(size.width/2, size.height/2 - 204));
		CCLabelTTF* fairyMenuExit = CCLabelTTF::create(menuExit->getCString(), "Arial", 30);
		this->addChild(fairyMenuExit);
		fairyMenuExit->setPosition(ccp(size.width/2, size.height/2 - 310));
        bRet = true;
    } while (0);

    return bRet;
}
Exemple #29
0
ParserElement::ref StringTreeParser::parse(const std::string &xml) {
	PlatformXMLParserFactory factory;
	DefaultStringTreeParser client;
#if (SWIFTEN_VERSION >= 0x040000)
	std::unique_ptr<XMLParser> parser = factory.createXMLParser(&client);
#else
	XMLParser *parser = factory.createXMLParser(&client);
#endif
	
	parser->parse(xml);
	ParserElement::ref root = client.getRoot();
#if (SWIFTEN_VERSION < 0x040000)
	delete parser;
#endif
	return root;
}
//------------------------------------------//
// AssetMetaDataParser::WriteMetaData				
//------------------------------------------//
bool AssetMetaDataParser::WriteMetaDataToFile(
class File& metaDataFile,
	const struct AssetMetaData& metaData)
{
	if (!CheckMetaDataFileIsValid(metaDataFile))
	{
		return false;
	}

	// Check if the file is new and cleared
	if (metaDataFile.GetFilemode() != File::READ_WRITE_NEW)
	{
		Log::GetLog().LogHighMsg("MetaDataFile is not empty.");
		return false;
	}

	//Begin the XML parsing
	XMLParser parser;
	if (!parser.Parse(metaDataFile))
	{
		return false;
	}

	XMLElement baseElement = parser.CreateNewElement(ASSET_TAG);
	baseElement.CreateChildElement(ASSET_NAME_TAG, metaData.AssetName);
	
	//Determine readable name from TypeHash
	std::string assetType = "Invalid";
	if (!mAssetFileTypeExtensions->HashIsOfAssetTypeName(metaData.AssetTypeHash, assetType))
	{
		//Log that we cant determine type
	}

	baseElement.CreateChildElement(ASSET_TYPE_TAG, assetType);
	baseElement.CreateChildElement(ASSET_PATH_TAG, metaData.AssetFilePath);

	XMLElement attrElement = baseElement.CreateChildElement(ASSET_ATTRIBUTE_TAG);
	XMLElement scalarAttrElement = attrElement.CreateChildElement(ASSET_SCALAR_ATTRIBUTE_TAG);
	XMLElement vectorAttrElement = attrElement.CreateChildElement(ASSET_VECTOR_ATTRIBUTE_TAG);

	AssetScalarAttributeContainer& container = AssetDefaultAttributes<Texture2D>::DefaultScalarAttributes;
	for each (AssetScalarAttribute scalarAttr in container)
	{
		scalarAttrElement.CreateChildElement(scalarAttr.AttributeName, ToString(scalarAttr.AttributeValue));
	}