bool CProcessConfigReader::GetConfigurationAndPreserveSpace(std::string sAppName, STRING_LIST &Params)
{
    Params.clear();

    int nBrackets = 0;
    Params.clear();

    Reset();

    std::string sKey = "PROCESSCONFIG="+sAppName;

    if(GoTo(sKey))
    {
        std::string sBracket = GetNextValidLine();
        if(sBracket.find("{")==0)
        {
            nBrackets++;
            while(!GetFile()->eof())
            {
                std::string sLine = GetNextValidLine();
                MOOSTrimWhiteSpace(sLine);

                if(sLine.find("}")!=0)
                {
                    std::string sVal(sLine);
                    std::string sTok = MOOSChomp(sVal, "=");
                    MOOSTrimWhiteSpace(sTok);
                    MOOSTrimWhiteSpace(sVal);

                    if (!sTok.empty())
                    {

                        if (!sVal.empty())
                        {
                            Params.push_back(sTok+"="+sVal);
                        }
                        else if(sLine.find("[")!=std::string::npos || sLine.find("]")!=std::string::npos)
                        {
                            Params.push_back(sLine);
                        }
                    }
                }
                else
                {
                    return true;
                }

                //quick error check - we don't allow nested { on single lines
                if(sLine.find("{")==0)
                {
                    MOOSTrace("CProcessConfigReader::GetConfiguration() missing \"}\" syntax error in mission file\n");
                }
            }
        }
    }


    return false;

}
Example #2
0
Triggerconf::STRING_LIST Triggerconf::tokenize (string path)
{
	STRING_LIST ret;
	
	int first = 0;
	int last = 0; 

	while (true) {

		last = (int) path.find (PATH_DELIMITER, first);
		
		if (last == (int)string::npos) {
			if (path.length () - first >= 1)
				ret.push_back (path.substr (first, path.length () - first));			
			break;
		}
		
		if (last-first >= 1)
			ret.push_back (path.substr (first, last-first));

		first = last + 1;
	}

	return ret;
}
Example #3
0
Triggerconf::STRING_LIST Triggerconf::getChildsAttribute (DOMNode* root, string nodename, string attribute)
{
	STRING_LIST ret;
	
	if (root == NULL) {
		setError ("invalid root node");	
		return ret;
	}

	DOMNodeList* childs = root->getChildNodes ();
	if (childs == NULL) return ret;

	for (unsigned int i=0; i<childs->getLength (); i++) {
		
		DOMNode* child = childs->item (i);
		if (child == NULL || child->getNodeType () != DOMNode::ELEMENT_NODE) continue;

		const XMLCh* xnodename = child->getNodeName ();
		char* charname = XMLString::transcode (xnodename);
		
		if (nodename.compare (charname) == 0)
			ret.push_back (getAttributeValue (child, attribute));

		XMLString::release (&charname);

	} // for (unsigned int i=0; i<childs->getLength (); i++) 

	return ret;
}
Example #4
0
//-----------------------------------------------------------------------------
// Purpose: Parse the VSS history command and generate a list of files & versions
// Input  : *pFileName - 
// Output : STRING_LIST
//-----------------------------------------------------------------------------
STRING_LIST &ParseHistory( const char *pProjectName, const char *pFileName )
{
	int nameLen = strlen( pProjectName );
	STRING_LIST *list = new STRING_LIST;

	FILE *fp = fopen( pFileName, "r" );
	if ( fp )
	{
		char buf[1024];
		string currentFile;
		string project;
		int currentVersion;

		while ( !feof(fp) )
		{
			fgets( buf, 1024, fp );
			if ( !strncmp( buf, "*****", 5 ) )
			{
				char *pStr = buf + 7;
				strtok( pStr, " \n" );
				currentFile = pStr;
			}
			else if ( !strncmp( buf, "Version", 7 ) )
			{
				currentVersion = atoi( buf + 8 );
			}
			else if ( !strncmp( buf, "Checked in", 10 ) )
			{
				char *pStr = buf + 11;
				strtok( pStr, " \n" );

				if ( strncmp( pProjectName, pStr, nameLen ) )
				{
					project = pProjectName;
					pStr = StringSkipTo( pStr, '/' ); // skip $/
					pStr = StringSkipTo( pStr, '/' );	// skip xxx/
					project += "/";
					project += pStr;
				}
				else
				{
					project = pStr;
				}

				project += "/";
				project += currentFile;
				historyList tmp( project, currentVersion );
				list->push_back( tmp );
			}
		}
		fclose( fp );
	}
	return *list;
}
Example #5
0
bool CFaceXYPoint::GetRegistrations(STRING_LIST &List)
{

    List.push_back("NAV_X");
    List.push_back("NAV_Y");

    //always call base class version
    CMaintainHeading::GetRegistrations(List);

    return true;
}
Example #6
0
BOOL Language::GetSectionNames(STRING_LIST &nameList) const
{
	const int BUF_MAX_SIZE = 1024*2;
	TCHAR *pSectionBuf = new TCHAR[BUF_MAX_SIZE];
	DWORD dwNamesLen = GetPrivateProfileSectionNames((LPTSTR)pSectionBuf, BUF_MAX_SIZE, m_strFileName);
	if(0 == dwNamesLen)
	{
		delete[] pSectionBuf;
		return FALSE;
	}
	TCHAR *pBuf = pSectionBuf;
	size_t nLen = 0;
	do 
	{
		nameList.push_back((LPTSTR)pBuf);
		nLen = std::wcslen(pBuf) + 1;
		pBuf += nLen;
		dwNamesLen -= nLen;
	} while (dwNamesLen > 0);
	delete[] pSectionBuf;
	return TRUE;
}
Example #7
0
Triggerconf::STRING_LIST Triggerconf::getConfigAttributeNames (string module, string submodule, string configname)
{
	STRING_LIST ret;

	if (! existsConfigElement (module, submodule, configname)) return ret;

	DOMNode* node = selectConfigElement (module, submodule, configname);
	if (node == NULL || node->getNodeType () != DOMNode::ELEMENT_NODE) return ret;

	DOMElement* elem = (DOMElement*) node;
	DOMNamedNodeMap* attributes = elem->getAttributes ();

	for (unsigned int i=0; i<attributes->getLength (); i++) {
		DOMNode* attr = attributes->item (i);
		const XMLCh* xname = attr->getNodeName ();	
		char* cname = XMLString::transcode (xname);

		ret.push_back (cname);	
		XMLString::release (&cname);
	}

	return ret;
}
Example #8
0
bool MoveEvent::configureEvent(xmlNodePtr p)
{
	std::string str;
	int intValue;
	if(readXMLString(p, "event", str)){
		if(asLowerCaseString(str) == "stepin"){
			m_eventType = MOVE_EVENT_STEP_IN;
		}
		else if(asLowerCaseString(str) == "stepout"){
			m_eventType = MOVE_EVENT_STEP_OUT;
		}
		else if(asLowerCaseString(str) == "equip"){
			m_eventType = MOVE_EVENT_EQUIP;
		}
		else if(asLowerCaseString(str) == "deequip"){
			m_eventType = MOVE_EVENT_DEEQUIP;
		}
		else if(asLowerCaseString(str) == "additem"){
			m_eventType = MOVE_EVENT_ADD_ITEM;
		}
		else if(asLowerCaseString(str) == "removeitem"){
			m_eventType = MOVE_EVENT_REMOVE_ITEM;
		}
		else{
			std::cout << "Error: [MoveEvent::configureMoveEvent] No valid event name " << str << std::endl;
			return false;
		}

		if(m_eventType == MOVE_EVENT_EQUIP || m_eventType == MOVE_EVENT_DEEQUIP){
			if(readXMLString(p, "slot", str)){
				if(asLowerCaseString(str) == "head"){
					slot = SLOT_HEAD;
				}
				else if(asLowerCaseString(str) == "necklace"){
					slot = SLOT_NECKLACE;
				}
				else if(asLowerCaseString(str) == "backpack"){
					slot = SLOT_BACKPACK;
				}
				else if(asLowerCaseString(str) == "armor"){
					slot = SLOT_ARMOR;
				}
				else if(asLowerCaseString(str) == "right-hand"){
					slot = SLOT_RIGHT;
				}
				else if(asLowerCaseString(str) == "left-hand"){
					slot = SLOT_LEFT;
				}
				else if(asLowerCaseString(str) == "legs"){
					slot = SLOT_LEGS;
				}
				else if(asLowerCaseString(str) == "feet"){
					slot = SLOT_FEET;
				}
				else if(asLowerCaseString(str) == "ring"){
					slot = SLOT_RING;
				}
				else if(asLowerCaseString(str) == "ammo"){
					slot = SLOT_AMMO;
				}
				else{
					std::cout << "Warning: [MoveEvent::configureMoveEvent] " << "Unknown slot type " << str << std::endl;
				}
			}

			wieldInfo = 0;
			if(readXMLInteger(p, "lvl", intValue) || readXMLInteger(p, "level", intValue)){
	 			reqLevel = intValue;
				if(reqLevel > 0){
					wieldInfo |= WIELDINFO_LEVEL;
				}
			}
			if(readXMLInteger(p, "maglv", intValue) || readXMLInteger(p, "maglevel", intValue)){
	 			reqMagLevel = intValue;
				if(reqMagLevel > 0){
					wieldInfo |= WIELDINFO_MAGLV;
				}
			}
			if(readXMLInteger(p, "prem", intValue) || readXMLInteger(p, "premium", intValue)){
				premium = (intValue != 0);
				if(premium){
					wieldInfo |= WIELDINFO_PREMIUM;
				}
			}

			//Gather vocation information
			typedef std::list<std::string> STRING_LIST;
			STRING_LIST vocStringList;
			xmlNodePtr vocationNode = p->children;
			while(vocationNode){
				if(xmlStrcmp(vocationNode->name,(const xmlChar*)"vocation") == 0){
					if(readXMLString(vocationNode, "name", str)){
						int32_t vocationId = g_vocations.getVocationId(str);

						if(vocationId != -1){
							vocEquipMap[vocationId] = true;
							intValue = 1;
							readXMLInteger(vocationNode, "showInDescription", intValue);
							if(intValue != 0){
								toLowerCaseString(str);
								vocStringList.push_back(str);
							}
						}
					}
				}

				vocationNode = vocationNode->next;
			}

			if(!vocStringList.empty()){
				for(STRING_LIST::iterator it = vocStringList.begin(); it != vocStringList.end(); ++it){
					if(*it != vocStringList.front()){
						if(*it != vocStringList.back()){
							vocationString += ", ";
						}
						else{
							vocationString += " and ";
						}
					}
					vocationString += *it;
					vocationString += "s";
				}
				wieldInfo |= WIELDINFO_VOCREQ;
			}
		}
	}
	else{
		std::cout << "Error: [MoveEvent::configureMoveEvent] No event found." << std::endl;
		return false;
	}
	return true;
}
Example #9
0
bool Sonar::OnStartUp()
{
  	AppCastingMOOSApp::OnStartUp();
	setlocale(LC_ALL, "C");
	list<string> sParams;
	m_MissionReader.EnableVerbatimQuoting(false);

	if(m_MissionReader.GetConfiguration(GetAppName(), sParams))
	{
    MOOSTrace("iSonar: Reading configuration\n");
    list<string>::iterator p;
    for(p = sParams.begin() ; p != sParams.end() ; p++)
    {
			string original_line = *p;
			string param = stripBlankEnds(toupper(biteString(*p, '=')));
			string value = stripBlankEnds(*p);

			MOOSTrace(original_line);

			if(MOOSStrCmp(param, "RANGE"))
			    m_msgHeadCommand.setRange(atof(value.c_str()));
      if(MOOSStrCmp(param, "VOS"))
          m_msgHeadCommand.setVOS(atof(value.c_str()));
      if(MOOSStrCmp(param, "INVERT"))
          m_msgHeadCommand.setInverted(atoi(value.c_str()));
			if(MOOSStrCmp(param, "NBINS"))
      {
        m_iParamBins = atoi(value.c_str());
        m_msgHeadCommand.setNbins(m_iParamBins);
      }
			if(MOOSStrCmp(param, "ANGLESTEP"))
			    m_msgHeadCommand.setAngleStep(atof(value.c_str()));
			if(MOOSStrCmp(param, "CONTINUOUS"))
			    m_msgHeadCommand.setContinuous(MOOSStrCmp(value,"true"));
			if(MOOSStrCmp(param, "GAIN"))
			    m_msgHeadCommand.setGain(atof(value.c_str()));
			if(MOOSStrCmp(param, "LEFTLIMIT"))
			    m_msgHeadCommand.setLeftLimit(atof(value.c_str()));
			if(MOOSStrCmp(param, "RIGHTLIMIT"))
			    m_msgHeadCommand.setRightLimit(atof(value.c_str()));
      if(MOOSStrCmp(param, "POWERED_AT_START"))
          m_bIsPowered = MOOSStrCmp(value.c_str(),"TRUE");
      if(MOOSStrCmp(param, "SERIAL_PORT"))
          m_portName = value.c_str();
      if(MOOSStrCmp(param, "SONAR_TYPE"))
      {
          m_snrType = (MOOSStrCmp(value.c_str(),"Miniking"))?SeaNetMsg::MiniKingNotDST:SeaNetMsg::SonarTypeError;
          if (m_snrType == SeaNetMsg::SonarTypeError)
            m_snrType = (MOOSStrCmp(value.c_str(),"Micron"))?SeaNetMsg::MicronDST:SeaNetMsg::SonarTypeError;
          if (m_snrType == SeaNetMsg::SonarTypeError)
            reportConfigWarning("Sonar type initialization error...\n");
      }
    }
	}
	else
		MOOSTrace("No configuration read.\n");

	m_bPortOpened = this->m_Port.Create(m_portName.c_str(), 115200);
  if(!m_bPortOpened)
    reportConfigWarning("Error Openning Serial Port");

  string tt;
  STRING_LIST params;
  // string ttt1("PORT=");
  // char numstr1[30] = {0}; // enough to hold all numbers up to 64-bits
  // sprintf(numstr1, "%s", m_portName.c_str());
  // tt = ttt1 + numstr1;
  // params.push_back(tt);
  // tt = "";
  // string ttt("BAUDRATE=");
  // char numstr[30] = {0}; // enough to hold all numbers up to 64-bits
  // sprintf(numstr, "%d", 115200);
  // tt = ttt + numstr;
  // params.push_back(tt);

  params.push_back("PORT=" + m_portName);
  params.push_back("BAUDRATE=115200");

  if(m_bPortOpened)
  {
    m_bPortOpened = this->m_Port.Configure(params);
  	//this->m_Port.SetTermCharacter('\n');
  	m_Port.Flush();
  }

  	m_timewarp = GetMOOSTimeWarp();

  	RegisterVariables();

  	if (m_bPortOpened && m_bIsPowered && !m_serial_thread.IsThreadRunning())
      m_serial_thread.Start();

	return(true);
}
Example #10
0
bool Weapon::configureEvent(xmlNodePtr p)
{
	int32_t intValue;
	std::string strValue;

	if (readXMLInteger(p, "id", intValue)) {
		id = intValue;
	} else {
		std::cout << "Error: [Weapon::configureEvent] Weapon without id." << std::endl;
		return false;
	}

	if (readXMLInteger(p, "lvl", intValue) || readXMLInteger(p, "level", intValue)) {
		level = intValue;
	}

	if (readXMLInteger(p, "maglv", intValue) || readXMLInteger(p, "maglevel", intValue)) {
		magLevel = intValue;
	}

	if (readXMLInteger(p, "mana", intValue)) {
		mana = intValue;
	}

	if (readXMLInteger(p, "manapercent", intValue)) {
		manaPercent = intValue;
	}

	if (readXMLInteger(p, "soul", intValue)) {
		soul = intValue;
	}

	if (readXMLInteger(p, "exhaustion", intValue)) {
		exhaustion = intValue;
	}

	if (readXMLInteger(p, "prem", intValue)) {
		premium = (intValue == 1);
	}

	if (readXMLInteger(p, "enabled", intValue)) {
		enabled = (intValue == 1);
	}

	if (readXMLInteger(p, "unproperly", intValue)) {
		wieldUnproperly = (intValue == 1);
	}

	if (readXMLString(p, "ammo", strValue)) {
		std::cout << "Warning: ammo is not longer used in weapons.xml." << std::endl;
	}

	typedef std::list<std::string> STRING_LIST;
	STRING_LIST vocStringList;
	xmlNodePtr vocationNode = p->children;

	while (vocationNode) {
		if (xmlStrcmp(vocationNode->name, (const xmlChar*)"vocation") == 0) {
			if (readXMLString(vocationNode, "name", strValue)) {
				int32_t vocationId = g_vocations.getVocationId(strValue);

				if (vocationId != -1) {
					vocWeaponMap[vocationId] = true;
					int32_t promotedVocation = g_vocations.getPromotedVocation(vocationId);

					if (promotedVocation != 0) {
						vocWeaponMap[promotedVocation] = true;
					}

					readXMLInteger(vocationNode, "showInDescription", intValue);

					if (intValue != 0) {
						toLowerCaseString(strValue);
						vocStringList.push_back(strValue);
					}
				}
			}
		}

		vocationNode = vocationNode->next;
	}

	range = Item::items[id].shootRange;

	std::string vocationString;

	if (!vocStringList.empty()) {
		for (STRING_LIST::iterator it = vocStringList.begin(); it != vocStringList.end(); ++it) {
			if (*it != vocStringList.front()) {
				if (*it != vocStringList.back()) {
					vocationString += ", ";
				} else {
					vocationString += " and ";
				}
			}

			vocationString += *it;
			vocationString += "s";
		}
	}

	uint32_t wieldInfo = 0;

	if (getReqLevel() > 0) {
		wieldInfo |= WIELDINFO_LEVEL;
	}

	if (getReqMagLv() > 0) {
		wieldInfo |= WIELDINFO_MAGLV;
	}

	if (!vocationString.empty()) {
		wieldInfo |= WIELDINFO_VOCREQ;
	}

	if (isPremium()) {
		wieldInfo |= WIELDINFO_PREMIUM;
	}

	if (wieldInfo != 0) {
		ItemType& it = Item::items.getItemType(id);
		it.wieldInfo = wieldInfo;
		it.vocationString = vocationString;
		it.minReqLevel = getReqLevel();
		it.minReqMagicLevel = getReqMagLv();
	}

	if (configureWeapon(Item::items[getID()])) {
		return true;
	}

	return false;
}
Example #11
0
void CFaceXYPoint::GetChartNodeContents(STRING_LIST& contents) const
{
    contents.push_back(MOOSFormat("Waypoint: (%7.2f,%7.2f)", m_XDOF.GetDesired(), m_YDOF.GetDesired()));
}
bool CMOOSRemoteLite::PrintNavSummary()
{
    STRING_LIST ToPrint;
    ToPrint.push_back("NAV_X");
    ToPrint.push_back("NAV_Y");
    ToPrint.push_back("NAV_Z");
    ToPrint.push_back("NAV_YAW");
    ToPrint.push_back("NAV_ALTITUDE");
    ToPrint.push_back("NAV_DEPTH");
    ToPrint.push_back("NAV_SPEED");



    ostringstream os;
//    ostrstream os;

    os<<"Navigation Summary:"<<endl;


    STRING_LIST::iterator p;

    for(p = ToPrint.begin();p!=ToPrint.end();p++)
    {
        string sWhat = *p;
        NAVVAR_MAP::iterator q = m_NavVars.find(sWhat);

        if(q!=m_NavVars.end())
        {
            CNavVar & rVar = q->second;

            //make left justified
            os.setf(ios::left);
            os<<setw(15)<<rVar.m_sPrintName.c_str()<<"t=";

            os.setf(ios::fixed);

            if(rVar.m_dfTime==-1)
            {
                os<<setw(10)<<"****";
                os<<setw(3)<<" : ";
                os<<setw(10)<<"****";
            }
            else
            {
                os<<setw(10)<<setprecision(1)<<rVar.m_dfTime;
                os<<setw(3)<<" : ";
                os<<setw(10)<<setprecision(1)<<rVar.m_dfVal*rVar.m_dfScaleBy;
            }
            os<<endl;
//            os.unsetf(ios::right);

        }
    }
    os<<ends;


    MOOSTrace("%s",string(os.str()).c_str());

    //  os.rdbuf()->freeze(0);

    return true;
}