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; }
void way(const shared_ptr<const OSM::Way> &way) { Osmium::OSM::TagList::const_iterator tagIt; for(tagIt = way->tags().begin(); tagIt != way->tags().end(); ++tagIt) { std::string sKey(tagIt->key()); std::string sVal(tagIt->value()); if(sKey.compare("natural") == 0) { if(sVal.compare("coastline") == 0) { Osmium::OSM::WayNodeList::const_iterator nodeIt; for(nodeIt = way->nodes().begin(); nodeIt != way->nodes().end(); ++nodeIt) { std::unordered_map<size_t,Node>::iterator findIt; size_t findId = nodeIt->ref(); findIt = m_listNodes.find(findId); if(findIt == m_listNodes.end()) { return; } // way pointing to node not in data set std::cout << std::fixed << std::setprecision(7) << findIt->second.lon << "," << std::fixed << std::setprecision(7) << findIt->second.lat << "," << 0 << "\n"; } } } } }
/*! \brief Read XML control data. * * \param Element TiXmlElement* A pointer to the parent node of the XML block. * \param IsXRC bool Whether this is an XRC file. * \param IsExtra bool Whether the data is extra information not conforming to the XRC standard. * \return bool Success or failure. * */ bool wxsLinearRegulator::OnXmlRead(TiXmlElement *Element, bool IsXRC, bool IsExtra) { for(size_t i = 0;i < m_arrTags.Count();i++){ delete m_arrTags[i]; } m_arrTags.Clear(); int i = 1; while(1){ wxString s = wxString::Format(wxT("tag_%d_value"), i); TiXmlElement *TagElem = Element->FirstChildElement(s.mb_str()); if(!TagElem){ break; } TagDesc *Desc = new TagDesc; long iVal; wxString sVal(TagElem->GetText(), wxConvUTF8); sVal.ToLong(&iVal); Desc->val = iVal; m_arrTags.Add(Desc); i++; } return wxsWidget::OnXmlRead(Element, IsXRC, IsExtra); }
bool fp_FieldTOCNumRun::calculateValue(void) { UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1]; // // First Find page number. // PL_StruxDocHandle sdh = getBlock()->getStruxDocHandle(); PD_Document * pDoc = getBlock()->getDocument(); PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1; FL_DocLayout * pLayout = getBlock()->getDocLayout(); fl_BlockLayout * pBlockInDoc = pLayout->findBlockAtPosition(pos); if(pBlockInDoc == NULL) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } fp_Line * pLine = static_cast<fp_Line *>(pBlockInDoc->getFirstContainer()); if(pLine == NULL) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } fp_Page * pPage = pLine->getPage(); UT_sint32 iPage = pLayout->findPage(pPage); if( iPage < 0) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } iPage++; // Start from Page 1. UT_String sVal(""); FootnoteType iType = getBlock()->getTOCNumType(); pLayout->getStringFromFootnoteVal(sVal,iPage,iType); const char * psz = sVal.c_str(); bool bStop = false; UT_sint32 i = 0; sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); for(i=1; (i<FPFIELD_MAX_LENGTH) && !bStop; i++) { sz_ucs_FieldValue[i] = static_cast<UT_UCSChar>(*psz); if(*psz == 0) { bStop = true; } else { psz++; } } return _setValue(sz_ucs_FieldValue); }
ECString ECConfig::FindVal(const EC_PCHAR pStr) const { ECString sStr(pStr); EC_S32 nSize = sStr.FindChar(CONFIG_ASSGINV_CHAR); if(nSize >= 0) { ECString sVal(pStr+nSize+1); sVal.Trim(); return sVal; } else if(pStr && (CONFIG_COMMENT_CHAR == pStr[0])) return ECString(pStr+1); return ECString(); }
/*! \brief Read XML control data. * * \param Element TiXmlElement* A pointer to the parent node of the XML block. * \param IsXRC bool Whether this is an XRC file. * \param IsExtra bool Whether the data is extra information not conforming to the XRC standard. * \return bool Success or failure. * */ bool wxsLinearMeter::OnXmlRead(TiXmlElement *Element, bool IsXRC, bool IsExtra) { for(size_t i = 0;i < m_arrTags.Count();i++){ delete m_arrTags[i]; } m_arrTags.Clear(); // TiXmlElement *TagElem = Element->FirstChildElement("tags"); // // Avoid crash if tags element doesn't exist. // if(TagElem){ // for(TiXmlElement *ValElem = TagElem->FirstChildElement(); // ValElem; // ValElem = ValElem->NextSiblingElement()) // { // TagDesc *Desc = new TagDesc; // long lVal; // wxString sVal(ValElem->GetText(), wxConvUTF8); // sVal.ToLong(&lVal); // Desc->val = lVal; // m_arrTags.Add(Desc); // } // } int i = 1; while(1){ wxString s = wxString::Format(wxT("tag_%d_value"), i); TiXmlElement *TagElem = Element->FirstChildElement(s.mb_str()); if(!TagElem){ break; } TagDesc *Desc = new TagDesc; long iVal; wxString sVal(TagElem->GetText(), wxConvUTF8); sVal.ToLong(&iVal); Desc->val = iVal; m_arrTags.Add(Desc); i++; } return wxsWidget::OnXmlRead(Element, IsXRC, IsExtra); }
QString QSString::value() const { return sVal(); }
bool fp_FieldTOCNumRun::calculateValue(void) { UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1]; // // First Find page number. // pf_Frag_Strux* sdh = getBlock()->getStruxDocHandle(); PD_Document * pDoc = getBlock()->getDocument(); PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1; FL_DocLayout * pLayout = getBlock()->getDocLayout(); fl_BlockLayout * pBlockInDoc = pLayout->findBlockAtPosition(pos); if(pBlockInDoc == NULL) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } fp_Line * pLine = static_cast<fp_Line *>(pBlockInDoc->getFirstContainer()); UT_sint32 kk = 0; bool b_goodLine = false; while (pLine && !b_goodLine) { for (kk = 0; kk < pLine->getNumRunsInLine(); kk++) { if(pLine->getRunFromIndex(kk)->getType() == FPRUN_TEXT) { b_goodLine = true; break; } } if (!b_goodLine) { pLine = static_cast<fp_Line *>(pLine->getNext()); } } if(pLine == NULL) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } fp_Page * pPage = pLine->getPage(); UT_sint32 iPage = pPage->getFieldPageNumber(); bool b_hasSetFieldPageNumber = false; if(iPage < 0) { pPage->resetFieldPageNumber(); iPage = pPage->getFieldPageNumber(); b_hasSetFieldPageNumber = true; if (iPage < 0) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } } UT_String sVal(""); FootnoteType iType = getBlock()->getTOCNumType(); pLayout->getStringFromFootnoteVal(sVal,iPage,iType); const char * psz = sVal.c_str(); if (b_hasSetFieldPageNumber) { // We need to set the field page number value to -1 so that we // recalculate the page number next time we enter this function pPage->setFieldPageNumber(-1); } bool bStop = false; UT_sint32 i = 0; sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); for(i=1; (i<FPFIELD_MAX_LENGTH) && !bStop; i++) { sz_ucs_FieldValue[i] = static_cast<UT_UCSChar>(*psz); if(*psz == 0) { bStop = true; } else { psz++; } } return _setValue(sz_ucs_FieldValue); }
//----------------------------------------------------------------------------- // The application object //----------------------------------------------------------------------------- int CDmxEditApp::Main() { // This bit of hackery allows us to access files on the harddrive g_pFullFileSystem->AddSearchPath( "", "LOCAL", PATH_ADD_TO_HEAD ); if ( CommandLine()->CheckParm( "-h" ) || CommandLine()->CheckParm( "-help" ) ) { PrintHelp(); return 0; } if ( CommandLine()->CheckParm( "-wiki" ) ) { PrintHelp( true ); return 0; } CUtlStringMap< CUtlString > setVars; CUtlString sGame; const int nParamCount = CommandLine()->ParmCount(); for ( int i = 0; i < nParamCount - 1; ++i ) { const char *pCmd = CommandLine()->GetParm( i ); const char *pArg = CommandLine()->GetParm( i + 1 ); if ( StringHasPrefix( pCmd, "-s" ) ) { const char *const pEquals = strchr( pArg, '=' ); if ( !pEquals ) { Warning( "Warning: Invalid command line args, no ='s in -set argument: %s %s\n", pCmd, pArg ); } char buf[ BUFSIZ ]; Q_strncpy( buf, pArg, pEquals - pArg + 1 ); const CUtlString sKey( buf ); CUtlString sVal( pEquals + 1 ); if ( !isdigit( *sVal.Get() ) && *sVal.Get() != '-' && *sVal.Get() != '"' ) { CUtlString sqVal( "\"" ); sqVal += sVal; sqVal += "\""; sVal = sqVal; } setVars[ sKey ] = sVal; if ( !Q_stricmp( sKey.Get(), "game" ) && sGame.IsEmpty() ) { sGame = sKey; } ++i; } else if ( StringHasPrefix( pCmd, "-g" ) ) { if ( *pArg == '"' ) { sGame = pArg; } else { sGame = ( "\"" ); sGame += pArg; sGame += "\""; } } else if ( StringHasPrefix( pCmd, "-nop4" ) ) { // Don't issue warning on -nop4 } else if ( StringHasPrefix( pCmd, "-" ) ) { Warning( "Warning: Unknown command line argument: %s\n", pCmd ); } } // Do Perforce Stuff if ( CommandLine()->FindParm( "-nop4" ) ) g_p4factory->SetDummyMode( true ); g_p4factory->SetOpenFileChangeList( "dmxedit" ); for ( int i = CommandLine()->ParmCount() - 1; i >= 1; --i ) { const char *pParam = CommandLine()->GetParm( i ); if ( _access( pParam, 04 ) == 0 ) { CDmxEditLua dmxEditLua; for ( int i = 0; i < setVars.GetNumStrings(); ++i ) { dmxEditLua.SetVar( setVars.String( i ), setVars[ i ] ); } if ( !sGame.IsEmpty() ) { dmxEditLua.SetGame( sGame ); } return dmxEditLua.DoIt( pParam ); } } Error( "Cannot find any file to execute from passed command line arguments\n\n" ); PrintHelp(); return -1; }
void DeckLibraryTab::OnCardInputChanged (wxCommandEvent& WXUNUSED (event)) { bool bSearchLower = TRUE, bSearchUpper = TRUE; int iIndex = 0, iStringLength; wxString CardName; if (m_bNoEvents || !m_pCardInput || !m_pCardPicker) return; m_lAmount = 1; CardName = m_pCardInput->GetValue (); iStringLength = CardName.Len (); if (iStringLength <= 0) { return; } m_iCycleLowerValue = -1; m_iCycleUpperValue = -1; // search for the first card that meets the description while (bSearchLower) { // Here we search card names bSearchLower = CardName.CmpNoCase (m_pCardPicker->GetString (iIndex).Left (iStringLength).c_str ()) != 0; if (!bSearchLower) { m_iCycleLowerValue = iIndex; } iIndex++; if (iIndex >= m_pCardPicker->GetCount ()) { bSearchLower = FALSE; } } if (m_iCycleLowerValue >= 0) { // search for the last card that meets the description while (bSearchUpper) { // Here we search card names bSearchUpper = CardName.CmpNoCase (m_pCardPicker->GetString (iIndex).Left (iStringLength).c_str ()) == 0; if (!bSearchUpper) { m_iCycleUpperValue = iIndex; } iIndex++; if (iIndex >= m_pCardPicker->GetCount ()) { bSearchUpper = FALSE; m_iCycleUpperValue = iIndex; } } } // If we have found something if (m_iCycleLowerValue != -1) { m_iCycleCounter = 0; m_pCardPicker->SetSelection (m_iCycleLowerValue); m_pCardPicker->SetFirstItem (m_iCycleLowerValue); } else // Use our phat speling powaz { int iRet; wxString sVal (CardName); if ((iRet = check_speling (sVal, m_oArrayOfNames)) >= 0) { m_iCycleCounter = 0; m_iCycleLowerValue = iRet; m_iCycleUpperValue = iRet; m_pCardPicker->SetSelection (iRet); m_pCardPicker->SetFirstItem (iRet); } } // Force a call here since the selection event doesn't seem to be triggered wxCommandEvent oEvt; OnCardPickerSelection (oEvt); }
BOOL CXmlFile::ParseItem(CXmlItem& xi, CXmlNodeWrapper* pNode) { CStringArray aNames, aValues; int nNumAttrib = pNode->GetAttributes(aNames, aValues); for (int nAttrib = 0; nAttrib < nNumAttrib; nAttrib++) { const CString& sName = aNames[nAttrib]; const CString& sVal = aValues[nAttrib]; xi.AddItem(sName, sVal); if (!ContinueParsing(sName, sVal)) return TRUE; } CXmlNodeWrapper nodeChild(pNode->GetFirstChildNode()); //for (int nNode = 0; nNode < nNumNodes; nNode++) while (nodeChild.IsValid()) { CString sName(nodeChild.Name()); CString sVal(nodeChild.GetText()); // Valik - Fully qualify NODE_CDATA_SECTION to prevent an ambiguous symbol error (C2872) in VC 7.1 int nNodeType = nodeChild.NodeTypeVal(); XI_TYPE nType = XIT_ELEMENT; if (nNodeType == MSXML2::NODE_CDATA_SECTION) nType = XIT_CDATA; else if (nNodeType == MSXML2::NODE_ATTRIBUTE) nType = XIT_ATTRIB; // if sName is empty then sVal relates to pNode if (!sName.IsEmpty()) { CXmlItem* pXI = xi.AddItem(sName, sVal, nType); if (!ContinueParsing(sName, sVal)) return TRUE; ParseItem(*pXI, &nodeChild); } // need to take care here not to overwrite a node's value by carriage returns // which can result if we load the XML preserving whitespace else { //BOOL bHasValue = (xi.GetValueLen() != 0); //BOOL bValueIsCR = (sVal == "\n"); //if (nodeChild.IsPreservingWhiteSpace() && bHasValue && bValueIsCR) if (nodeChild.IsPreservingWhiteSpace() && (xi.GetValueLen() != 0) && (sVal == "\n")) { // ignore ASSERT(1); // for debugging } else { xi.SetValue(sVal); xi.SetType(nType); } } nodeChild = nodeChild.GetNextSibling(); } return TRUE; }