示例#1
0
文件: Project.cpp 项目: hzx/mutant
int parseProject(Project& project) {
  /* project.filename = getCurrentDir() + "/project.mutant"; */
  /* if (not existsPath(project.filename)) return ERROR_FAIL; */

  /* project.content = getFileContent(project.filename); */

  // find \n or right
  int left = 0;
  int right = project.content.length();
  int cursor;
  int error;

  while (left < right) {
    cursor = findSymbol(project.content, '\n', left, right);

    if (cursor - left > 0) { // skip empty line
      if (project.content[left] == '-') {
        error = parseProjectOption(project, left, cursor);
        if (error < 0) return error;
      } else {
        std::unique_ptr<Task> task(new Task());
        error = parseTask(project.content, task.get(), left, cursor);
        if (error >= 0) project.tasks.push_back(task.release());
        if (error < 0) return error;
      }
    }

    left = cursor + 1;
  }

  return ERROR_OK;
}
bool AllneticImportHandler::startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts) {
    if (qName.compare(QString("project")) == 0) {
        _currentProject = parseProject(atts);
        _projects->push_back(_currentProject);
    }
    if (qName.compare(QString("task")) == 0) {
        _currentTask = parseTask(atts);
        _currentProject->addTask(_currentTask);
        if (errorOcurred()) {
            return false;
        }
    }
    if (qName.compare(QString("period")) == 0) {
        TaskLog* log = parseTaskLog(atts);
        _currentTask->addLog(log);
    }
    return true;
}
示例#3
0
bool CmdEdit::editFile (Task& task)
{
  // Check for file permissions.
  Directory location (context.config.get ("data.location"));
  if (! location.writable ())
    throw std::string (STRING_EDIT_UNWRITABLE);

  // Create a temp file name in data.location.
  std::stringstream file;
  file << "task." << getpid () << "." << task.id << ".task";

  // Determine the output date format, which uses a hierarchy of definitions.
  //   rc.dateformat.edit
  //   rc.dateformat
  std::string dateformat = context.config.get ("dateformat.edit");
  if (dateformat == "")
    dateformat = context.config.get ("dateformat");

  // Change directory for the editor
  std::string current_dir = Directory::cwd ();
  int ignored = chdir (location._data.c_str ());
  ++ignored; // Keep compiler quiet.

  // Format the contents, T -> text, write to a file.
  std::string before = formatTask (task, dateformat);
  std::string before_orig = before;
  File::write (file.str (), before);

  // Determine correct editor: .taskrc:editor > $VISUAL > $EDITOR > vi
  std::string editor = context.config.get ("editor");
  char* peditor = getenv ("VISUAL");
  if (editor == "" && peditor) editor = std::string (peditor);
  peditor = getenv ("EDITOR");
  if (editor == "" && peditor) editor = std::string (peditor);
  if (editor == "") editor = "vi";

  // Complete the command line.
  editor += " ";
  editor += "\"" + file.str () + "\"";

ARE_THESE_REALLY_HARMFUL:
  bool changes = false; // No changes made.

  // Launch the editor.
  std::cout << format (STRING_EDIT_LAUNCHING, editor) << "\n";
  if (-1 == system (editor.c_str ()))
    std::cout << STRING_EDIT_NO_EDITS << "\n";
  else
    std::cout << STRING_EDIT_COMPLETE << "\n";

  // Slurp file.
  std::string after;
  File::read (file.str (), after);

  // Update task based on what can be parsed back out of the file, but only
  // if changes were made.
  if (before_orig != after)
  {
    std::cout << STRING_EDIT_CHANGES << "\n";
    std::string problem = "";
    bool oops = false;

    try
    {
      parseTask (task, after, dateformat);
    }

    catch (const std::string& e)
    {
      problem = e;
      oops = true;
    }

    if (oops)
    {
      std::cerr << STRING_ERROR_PREFIX << problem << "\n";

      // Preserve the edits.
      before = after;
      File::write (file.str (), before);

      if (confirm (STRING_EDIT_UNPARSEABLE))
        goto ARE_THESE_REALLY_HARMFUL;
    }
    else
      changes = true;
  }
  else
  {
    std::cout << STRING_EDIT_NO_CHANGES << "\n";
    changes = false;
  }

  // Cleanup.
  File::remove (file.str ());
  ignored = chdir (current_dir.c_str ());
  return changes;
}
示例#4
0
bool FSMDescrip::loadFromXML(const std::string& xmlName, bool verbose) {
  logger << Logger::INFO_MSG << "Loading behavior from xml: " << xmlName;
  TiXmlDocument xml(xmlName);
  bool loadOkay = xml.LoadFile();

  if (!loadOkay) {
    logger << Logger::ERR_MSG << "Could not load behavior configuration xml (";
    logger << xmlName << ") due to xml syntax errors.\n";
    logger << "\t" << xml.ErrorDesc();
    return false;
  }

  TiXmlElement* popNode = xml.RootElement();
  if (!popNode) {
    logger << Logger::ERR_MSG << "Root element does not exist.";
    return false;
  }
  if (popNode->ValueStr() != "BFSM") {
    logger << Logger::ERR_MSG << "Root element value should be \"BFSM\".";
    return false;
  }

  std::string absPath;
  os::path::absPath(xmlName, absPath);
  std::string junk;
  os::path::split(absPath, _behaviorFldr, junk);
  logger << Logger::INFO_MSG << "Behavior root: " << _behaviorFldr;

  TiXmlElement* child;
  for (child = popNode->FirstChildElement(); child; child = child->NextSiblingElement()) {
    if (child->ValueStr() == "GoalSet") {
      int i;
      if (!child->Attribute("id", &i)) {
        logger << Logger::ERR_MSG << "GoalSet requires an \"id\" property.";
        return false;
      }
      size_t setID = static_cast<size_t>(i);
      // confirm that the id doesn't already exist
      if (_goalSets.find(setID) != _goalSets.end()) {
        logger << Logger::WARN_MSG << "Found multiple GoalSets with the same id: ";
        logger << setID << ".\n\tGoal definitions will be merged!";
      } else {
        _goalSets[setID] = new GoalSet();
      }
      TiXmlElement* goalNode;
      for (goalNode = child->FirstChildElement(); goalNode;
           goalNode = goalNode->NextSiblingElement()) {
        if (goalNode->ValueStr() == "Goal") {
          Goal* goal = parseGoal(goalNode, _behaviorFldr);
          if (goal == 0x0) {
            logger << Logger::ERR_MSG << "Error parsing a goal description.";
            return false;
          }
          // Make sure that this goal doesn't duplicate previous goal ids
          if (!_goalSets[setID]->addGoal(goal->getID(), goal)) {
            logger << Logger::ERR_MSG << "GoalSet " << setID;
            logger << " has two goals with the identifier: " << goal->getID();
            logger << " (second appears on line " << goalNode->Row() << ").";
            return false;
          }
        } else {
          logger << Logger::WARN_MSG
                 << "Found a child tag of the GoalSet that "
                    "is not a \"Goal\" tag on line "
                 << goalNode->Row()
                 << ". "
                    "It will be ignored.";
        }
      }

    } else if (child->ValueStr() == "State") {
      if (!parseState(child, _behaviorFldr, _states)) {
        return false;
      }
    } else if (child->ValueStr() == "Transition") {
      std::string from;
      Transition* trans = parseTransition(child, _behaviorFldr, from);
      if (trans == 0x0) {
        return false;
      }

      addTransition(from, trans);
    } else if (child->ValueStr() == "VelModifier") {
      VelModifier* vel = parseVelModifier(child, _behaviorFldr);
      if (vel == 0x0) {
        return false;
      } else {
        _velModifiers.push_back(vel);
      }
    } else if (child->ValueStr() == "Task") {
      Task* task = parseTask(child, _behaviorFldr);
      if (task == 0x0) {
        logger << Logger::WARN_MSG << "User-specified Task on line ";
        logger << child->Row()
               << " couldn't be instantiated.  "
                  "It is being ignored.";
      } else {
        _tasks.push_back(task);
      }
    } else if (child->ValueStr() == "EventSystem") {
      if (!EVENT_SYSTEM->parseEvents(child, _behaviorFldr)) {
        return false;
      }
    } else {
      logger << Logger::ERR_MSG << "Unrecognized tag as child of <Population>: <";
      logger << child->ValueStr() << ">.";
      return false;
    }
  }

  return true;
}
bool MoDeL1Parser::parse(DesignerModelComponent* model, QDomDocument& doc)
{
	QList<parseTask> taskList;
	taskList.push_back(parseTask(QDomElement(), model->getEngine()->globalObject(), 0));
	size_t curTask = 0;
	while(curTask<(size_t)taskList.size())
	{
		switch(taskList[curTask].taskHint)
		{
		case 0:   //
			{
				//defaultAction
				//standardObject
				QDomDocument curElem = doc;
				//create object.
				QScriptValue newItemValue = model->getEngine()->newObject();

				newItemValue.setProperty("*tag*", curElem.nodeName());
				//[write properties]
				for(int attrIndex = 0 ; attrIndex < curElem.attributes().count(); attrIndex++)
				{
					{
						newItemValue.setProperty(  curElem.attributes().item(attrIndex).nodeName(), curElem.attributes().item(attrIndex).nodeValue());
					}
				}
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="MoDeL")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 1));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
			}
			break;
		case 1:   //#object$standardObject~/model
			{
				//standardObject
				QDomElement curElem = taskList[curTask].taskElem;
				//create object.
				QScriptValue newItemValue = model->getEngine()->newObject();

				newItemValue.setProperty("*tag*", curElem.nodeName());
				//[write properties]
				for(int attrIndex = 0 ; attrIndex < curElem.attributes().count(); attrIndex++)
				{
					{
						newItemValue.setProperty(  curElem.attributes().item(attrIndex).nodeName(), curElem.attributes().item(attrIndex).nodeValue());
					}
				}
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="dbInterface")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 2));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				QScriptValue curTargetItem = model->getEngine()->globalObject();
				writeValueToModel(newItemValue, curTargetItem, "/model");
			}
			break;
		case 2:   //#object$ignoreThis
			{
				//skipThis
				QScriptValue newItemValue = taskList[curTask].taskParent;
				QDomElement curElem = taskList[curTask].taskElem;
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="input")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 3));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
			}
			break;
		case 3:   //#object$ignoreThis
			{
				//skipThis
				QScriptValue newItemValue = taskList[curTask].taskParent;
				QDomElement curElem = taskList[curTask].taskElem;
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="listOfParameters")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 4));
					}
					else if(childElem.nodeName()=="listOfRules")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 10));
					}
					else if(childElem.nodeName()=="listOfCompartments")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 14));
					}
					else if(childElem.nodeName()=="listOfSpecies")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 21));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
			}
			break;
		case 4:   //#array$createArray~/model/parameters
			{
				//createArray
				QScriptValue newItemValue;
				newItemValue = model->getEngine()->newArray(0);
				QDomElement curElem = taskList[curTask].taskElem;
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="parameter")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 5));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				QScriptValue curTargetItem = model->getEngine()->globalObject();
				writeValueToModel(newItemValue, curTargetItem, "/model/parameters");
			}
			break;
		case 5:   //#object$standardObject$appendToArray^
			{
				//standardObject
				QDomElement curElem = taskList[curTask].taskElem;
				//create object.
				QScriptValue newItemValue = model->getEngine()->newObject();

				newItemValue.setProperty("*tag*", curElem.nodeName());
				//[write properties]
				for(int attrIndex = 0 ; attrIndex < curElem.attributes().count(); attrIndex++)
				{
					{
						newItemValue.setProperty(  curElem.attributes().item(attrIndex).nodeName(), curElem.attributes().item(attrIndex).nodeValue());
					}
				}
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="id")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 6));
					}
					else if(childElem.nodeName()=="value")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 7));
					}
					else if(childElem.nodeName()=="units")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 8));
					}
					else if(childElem.nodeName()=="constant")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 9));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				appendValueToModel(newItemValue, taskList[curTask].taskParent, "");
			}
			break;
		case 6:   //#value^/id
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/id");
			}
			break;
		case 7:   //#value^/value
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/value");
			}
			break;
		case 8:   //#value^/units
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/units");
			}
			break;
		case 9:   //#value^/constant
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/constant");
			}
			break;
		case 10:   //#array$createArray~/model/rules
			{
				//createArray
				QScriptValue newItemValue;
				newItemValue = model->getEngine()->newArray(0);
				QDomElement curElem = taskList[curTask].taskElem;
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="assignmentRule")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 11));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				QScriptValue curTargetItem = model->getEngine()->globalObject();
				writeValueToModel(newItemValue, curTargetItem, "/model/rules");
			}
			break;
		case 11:   //#object$standardObject$appendToArray^
			{
				//standardObject
				QDomElement curElem = taskList[curTask].taskElem;
				//create object.
				QScriptValue newItemValue = model->getEngine()->newObject();

				newItemValue.setProperty("*tag*", curElem.nodeName());
				//[write properties]
				for(int attrIndex = 0 ; attrIndex < curElem.attributes().count(); attrIndex++)
				{
					{
						newItemValue.setProperty(  curElem.attributes().item(attrIndex).nodeName(), curElem.attributes().item(attrIndex).nodeValue());
					}
				}
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="variable")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 12));
					}
					else if(childElem.nodeName()=="math")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 13));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				appendValueToModel(newItemValue, taskList[curTask].taskParent, "");
			}
			break;
		case 12:   //#value$setProperty^/variable
			{
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/variable");
			}
			break;
		case 13:   //#value$setProperty^/function
			{
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/function");
			}
			break;
		case 14:   //#array$createArray~/model/compartments
			{
				//createArray
				QScriptValue newItemValue;
				newItemValue = model->getEngine()->newArray(0);
				QDomElement curElem = taskList[curTask].taskElem;
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="compartment")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 15));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				QScriptValue curTargetItem = model->getEngine()->globalObject();
				writeValueToModel(newItemValue, curTargetItem, "/model/compartments");
			}
			break;
		case 15:   //#object$standardObject$appendToArray^
			{
				//standardObject
				QDomElement curElem = taskList[curTask].taskElem;
				//create object.
				QScriptValue newItemValue = model->getEngine()->newObject();

				newItemValue.setProperty("*tag*", curElem.nodeName());
				//[write properties]
				for(int attrIndex = 0 ; attrIndex < curElem.attributes().count(); attrIndex++)
				{
					if(curElem.attributes().item(attrIndex).nodeName()=="db")
					{
						taskList.push_back(parseTask(curElem, newItemValue, 16));
					}
					else
					{
						newItemValue.setProperty(  curElem.attributes().item(attrIndex).nodeName(), curElem.attributes().item(attrIndex).nodeValue());
					}
				}
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="id")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 17));
					}
					else if(childElem.nodeName()=="size")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 18));
					}
					else if(childElem.nodeName()=="outside")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 19));
					}
					else if(childElem.nodeName()=="constant")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 20));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				appendValueToModel(newItemValue, taskList[curTask].taskParent, "");
			}
			break;
		case 16:   //#value$getProperty(db)^/*iGame1*/db
			{
				//getProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.attribute("db"));
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/*iGame1*/db");
			}
			break;
		case 17:   //#value^/id
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/id");
			}
			break;
		case 18:   //#value^/size
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/size");
			}
			break;
		case 19:   //#value^/outside
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/outside");
			}
			break;
		case 20:   //#value^/constant
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/constant");
			}
			break;
		case 21:   //#array$createArray~/model/species
			{
				//createArray
				QScriptValue newItemValue;
				newItemValue = model->getEngine()->newArray(0);
				QDomElement curElem = taskList[curTask].taskElem;
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="species")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 22));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				QScriptValue curTargetItem = model->getEngine()->globalObject();
				writeValueToModel(newItemValue, curTargetItem, "/model/species");
			}
			break;
		case 22:   //#object$standardObject$appendToArray^
			{
				//standardObject
				QDomElement curElem = taskList[curTask].taskElem;
				//create object.
				QScriptValue newItemValue = model->getEngine()->newObject();

				newItemValue.setProperty("*tag*", curElem.nodeName());
				//[write properties]
				for(int attrIndex = 0 ; attrIndex < curElem.attributes().count(); attrIndex++)
				{
					if(curElem.attributes().item(attrIndex).nodeName()=="db")
					{
						taskList.push_back(parseTask(curElem, newItemValue, 23));
					}
					else
					{
						newItemValue.setProperty(  curElem.attributes().item(attrIndex).nodeName(), curElem.attributes().item(attrIndex).nodeValue());
					}
				}
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="id")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 24));
					}
					else if(childElem.nodeName()=="compartment")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 25));
					}
					else if(childElem.nodeName()=="initialConcentration")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 26));
					}
					else if(childElem.nodeName()=="constant")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 27));
					}
					else if(childElem.nodeName()=="boundaryCondition")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 28));
					}
					else if(childElem.nodeName()=="cnModel")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 29));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				appendValueToModel(newItemValue, taskList[curTask].taskParent, "");
			}
			break;
		case 23:   //#value$getProperty(db)^/*iGame1*/db
			{
				//getProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.attribute("db"));
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/*iGame1*/db");
			}
			break;
		case 24:   //#value^/id
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/id");
			}
			break;
		case 25:   //#value^/compartment
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/compartment");
			}
			break;
		case 26:   //#value^/initialConcentration
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/initialConcentration");
			}
			break;
		case 27:   //#value^/constant
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/constant");
			}
			break;
		case 28:   //#value^/boundaryCondition
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/boundaryCondition");
			}
			break;
		case 29:   //#object$standardObject^/*iGame1*
			{
				//standardObject
				QDomElement curElem = taskList[curTask].taskElem;
				//create object.
				QScriptValue newItemValue = model->getEngine()->newObject();

				newItemValue.setProperty("*tag*", curElem.nodeName());
				//[write properties]
				for(int attrIndex = 0 ; attrIndex < curElem.attributes().count(); attrIndex++)
				{
					{
						newItemValue.setProperty(  curElem.attributes().item(attrIndex).nodeName(), curElem.attributes().item(attrIndex).nodeValue());
					}
				}
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="listOfChains")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 30));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/*iGame1*");
			}
			break;
		case 30:   //#array$createArray^/chains
			{
				//createArray
				QScriptValue newItemValue;
				newItemValue = model->getEngine()->newArray(0);
				QDomElement curElem = taskList[curTask].taskElem;
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="chain")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 31));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/chains");
			}
			break;
		case 31:   //#object$standardObject$appendToArray^
			{
				//standardObject
				QDomElement curElem = taskList[curTask].taskElem;
				//create object.
				QScriptValue newItemValue = model->getEngine()->newObject();

				newItemValue.setProperty("*tag*", curElem.nodeName());
				//[write properties]
				for(int attrIndex = 0 ; attrIndex < curElem.attributes().count(); attrIndex++)
				{
					{
						newItemValue.setProperty(  curElem.attributes().item(attrIndex).nodeName(), curElem.attributes().item(attrIndex).nodeValue());
					}
				}
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="listOfParts")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 32));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				appendValueToModel(newItemValue, taskList[curTask].taskParent, "");
			}
			break;
		case 32:   //#array$createArray^/parts
			{
				//createArray
				QScriptValue newItemValue;
				newItemValue = model->getEngine()->newArray(0);
				QDomElement curElem = taskList[curTask].taskElem;
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="part")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 33));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/parts");
			}
			break;
		case 33:   //#object$standardObject$appendToArray^
			{
				//standardObject
				QDomElement curElem = taskList[curTask].taskElem;
				//create object.
				QScriptValue newItemValue = model->getEngine()->newObject();

				newItemValue.setProperty("*tag*", curElem.nodeName());
				//[write properties]
				for(int attrIndex = 0 ; attrIndex < curElem.attributes().count(); attrIndex++)
				{
					{
						newItemValue.setProperty(  curElem.attributes().item(attrIndex).nodeName(), curElem.attributes().item(attrIndex).nodeValue());
					}
				}
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					if(childElem.nodeName()=="partReference")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 34));
					}
					else if(childElem.nodeName()=="partLabel")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 35));
					}
					else if(childElem.nodeName()=="partType")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 36));
					}
					else if(childElem.nodeName()=="partCategory")
					{
						taskList.push_back(parseTask(childElem, newItemValue, 37));
					}
					else
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
				appendValueToModel(newItemValue, taskList[curTask].taskParent, "");
			}
			break;
		case 34:   //#value^/reference
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/reference");
			}
			break;
		case 35:   //#value^/label
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/label");
			}
			break;
		case 36:   //#value^/type
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/type");
			}
			break;
		case 37:   //#value^/category
			{
				//defaultAction
				//setProperty
				QScriptValue newItemValue;
				newItemValue = QScriptValue(taskList[curTask].taskElem.text());
				QScriptValue curTargetItem = taskList[curTask].taskParent;
				writeValueToModel(newItemValue, curTargetItem, "/category");
			}
			break;
		default:
			{
				//standardObject
				QDomElement curElem = taskList[curTask].taskElem;
				//create object.
				QScriptValue newItemValue = model->getEngine()->newObject();

				newItemValue.setProperty("*tag*", curElem.nodeName());
				//[append this Item To *subobjects*]
				appendValueToModel(newItemValue, taskList[curTask].taskParent, "/*subobjects*");

				//[write properties]
				for(int attrIndex = 0 ; attrIndex < curElem.attributes().count(); attrIndex++)
				{
					{
						newItemValue.setProperty(  curElem.attributes().item(attrIndex).nodeName(), curElem.attributes().item(attrIndex).nodeValue());
					}
				}
				//[write children objects]
				for(QDomElement childElem = curElem.firstChildElement();
					!childElem.isNull(); childElem = childElem.nextSiblingElement())
				{
					{
						taskList.push_back(parseTask(childElem, newItemValue, (size_t)-1));
					}
				}
			}
			break;
		};
		curTask++;
	}
	return true;
}