コード例 #1
0
logical OSyntaxHighlighter :: FindElements (QString qsText, int32 &riStart )
{
  logical                 term = NO;
  int                     iEnd = 0
                         ,iStart = riStart
                         ,iLength = 0;
  std::vector<SyntaxElement>::iterator it;
BEGINSEQ
  if(qsText.isEmpty())                               ERROR
  
  for ( it = elements.begin(); it != elements.end() && !term; ++it ){
    iStart = riStart;
    while ( iStart >= 0 )
      if(FindElement(qsText,iStart,(*it).rxStart)){
        iLength = (*it).rxStart.cap(0).length();
        iEnd = iStart+iLength;
        if((*it).isBlock)
          if(FindElement(qsText,iEnd,(*it).rxEnd)){ //highlight the block to the end of line
            iLength = (iEnd + (*it).rxStart.cap(0).length()) - iStart;
          }else{ // remember that the block doesnt end here
            iLength = qsText.length() - iStart;
            setCurrentBlockState(GetSyntaxElementIndex((*it)));
          }
        AddFormatRange((*it).syntaxclass,iStart,iLength);
        iStart+=iLength;
      }
  }


RECOVER
  term = YES;
ENDSEQ
  return term;
}
コード例 #2
0
/*--------------------------------------------------------------------------------*/
bool TinyXMLADMData::TranslateXML(const std::string& data)
{
  TiXmlDocument doc;
  const TiXmlNode *node;
  bool success = false;

  DEBUG3(("XML: %s", data.c_str()));

  // dig to correct location of audioFormatExtended section
  doc.Parse(data.c_str());
  if ((node = FindElement(&doc, "ebuCoreMain")) != NULL)
  {
    if ((node = FindElement(node, "coreMetadata")) != NULL)
    {
      if ((node = FindElement(node, "format")) != NULL)
      {
        if ((node = FindElement(node, "audioFormatExtended")) != NULL)
        {
          CollectObjects(node);
                    
          success = true;
        }
        else ERROR("Failed to find audioFormatExtended element");
      }
      else ERROR("Failed to find format element");
    }
    else ERROR("Failed to find coreMetadata element");
  }
  else ERROR("Failed to find ebuCoreMain element");

  return success;
}
コード例 #3
0
ファイル: Trie.cpp プロジェクト: darrellzook/zedit
/*----------------------------------------------------------------------------------------------
	Parameters:
		pszw: 16-bit key word to be added to the trie
----------------------------------------------------------------------------------------------*/
bool CTrieLevel::AddWord(wchar * pszw, COLORREF cr, BOOL fCaseMatters)
{
	AssertPtr(pszw);
	Assert(*pszw);

	int ite;
	wchar ch = fCaseMatters ? *pszw : towlower(*pszw);
	if (!(FindElement(ch, &ite)))
	{
		CTrieElement ** ppte = (CTrieElement **)realloc(m_ppte, sizeof(CTrieElement *) * ++m_cte);
		if (!ppte)
			return false;
		m_ppte = ppte;
		if (ite == -1)
			ite = 0;
		else
			memmove(&m_ppte[ite + 1], &m_ppte[ite], sizeof(CTrieElement *) * (m_cte - ite - 1));
		m_ppte[ite] = new CTrieElement(ch);
		if (!m_ppte[ite])
			return false;
		if (!m_ppte[ite]->CreateSubLevel())
			return false;
	}
	if (pszw[1] && !iswspace(pszw[1]))
		return m_ppte[ite]->m_ptlSub->AddWord(pszw + 1, cr, fCaseMatters);
	else
		m_ppte[ite]->m_ptlSub->m_cr = cr;
	return true;
}
コード例 #4
0
ファイル: CXMLUtils.cpp プロジェクト: AzureAD/rms-sdk-for-cpp
void CXMLUtils::ExtractElementAll(const char     *szXML,
                                  const string  & strElementName,
                                  vector<string>& vOccurrences,
                                  bool            includeTag)
{
  while (1)
  {
    const char *szStartOuter = NULL, *szEndOuter = NULL, *szStartInner = NULL,
               *szEndInner   = NULL;

    if (!FindElement(szXML, strElementName, szStartOuter, szEndOuter,
                     szStartInner, szEndInner))
    {
      break;
    }

    if (includeTag)
    {
      vOccurrences.push_back(string(szStartOuter, szEndOuter - szStartOuter));
    }
    else
    {
      vOccurrences.push_back(string(szStartInner, szEndInner - szStartInner));
    }

    szXML = szEndOuter;
  }
}
コード例 #5
0
string ControlFile::GetVirtualFilePath(const char *hardchipnr)
{
	errno_t err;
	FILE    * inFile;

	string  result = "";

	err = fopen_s(&inFile, (char *) filePath, "r");
	if (err != 0)
	{
		logError("Could not open file \"%s\" for reading (err = %d)", filePath, err);
		return result;
	}

	char content[MAX_CONTENT + 1];

	if (!seekToContentElement(inFile, "hardchipnr", hardchipnr))
	{
		fclose(inFile);
		return result;
	}

	FindElement(inFile, "file", content, MAX_CONTENT);
	result = content;

	fclose(inFile);

	return result;
}
コード例 #6
0
ファイル: FGXMLElement.cpp プロジェクト: airware/jsbsim
double Element::FindElementValueAsNumberConvertFromTo( const string& el,
                                                       const string& supplied_units,
                                                       const string& target_units)
{
  Element* element = FindElement(el);

  if (!element) {
    cerr << "Attempting to get non-existent element " << el << endl;
    exit(-1);
  }

  if (!supplied_units.empty()) {
    if (convert.find(supplied_units) == convert.end()) {
      cerr << element->ReadFrom() << "Supplied unit: \""
           << supplied_units << "\" does not exist (typo?)." << endl;
      exit(-1);
    }
    if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
      cerr << element->ReadFrom() << "Supplied unit: \""
           << supplied_units << "\" cannot be converted to " << target_units
           << endl;
      exit(-1);
    }
  }

  double value = element->GetDataAsNumber();
  if (!supplied_units.empty()) {
    value *= convert[supplied_units][target_units];
  }

  value = DisperseValue(element, value, supplied_units, target_units);

  return value;
}
コード例 #7
0
BOOL CCfgFile::RemoveElement(LPCTSTR pGroup, LPCTSTR pElement)
{_STTEX();
	HGROUP hGroup = FindGroup( pGroup );
	LPCFGELEMENTINFO pcei = FindElement( hGroup, pElement );

	return RemoveElement( hGroup, pcei );
}
コード例 #8
0
double Element::FindElementValueAsNumberConvertFromTo( string el,
                                                       string supplied_units,
                                                       string target_units)
{
  Element* element = FindElement(el);

  if (!element) {
    cerr << "Attempting to get non-existent element " << el << endl;
    exit(0);
  }

  if (!supplied_units.empty()) {
    if (convert.find(supplied_units) == convert.end()) {
      cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit"
           << " conversion in FGXMLElement.cpp." << endl;
      exit(-1);
    }
    if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
      cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to "
                   << target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl;
      exit(-1);
    }
  }

  double value = element->GetDataAsNumber();
  if (!supplied_units.empty()) {
    value *= convert[supplied_units][target_units];
  }

  return value;
}
コード例 #9
0
showType ControlFile::GetShowType()
{
	errno_t err;
	FILE    * inFile;

	err = fopen_s(&inFile, (char *) filePath, "r");
	if (err != 0)
	{
		logError("Could not open file \"%s\" for reading (err = %d)", filePath, err);
		return NON_SHOW_TYPE;
	}

	char content[MAX_ELEMENT + 1];

	bool result = FindElement(inFile, "show", content, MAX_ELEMENT);

	fclose(inFile);
	if (result)
	{
		string s = content;     //easier to use!
		if (s == "HIDE_VIRTUAL") return HIDE_VIRTUAL;
		else if (s == "HIDEREAL") return HIDEREAL;
		else if (s == "REAL_FIRST") return REAL_FIRST;
		else return REAL_LAST;
	}
	else
	{
		logError("Element <show> not found in control file \"%s\"", filePath);
		return REAL_LAST;
	}
}
コード例 #10
0
// For cutting, collapse the crack if opened enough
// cods are hard coded and should be greater than traction law max cod
// Also won't collapse if this segment or a neighbor has traction law
// return tru unless collapsed position is out of the grid
bool CrackSegment::CollapseSurfaces(void)
{
	// make sure no traction on this segment or its neighbors
	if(MatID()>=0) return true;
	if(nextSeg!=NULL)
	{	if(nextSeg->MatID()>=0) return true;
	}
	if(prevSeg!=NULL)
	{	if(prevSeg->MatID()>=0) return true;
	}
	
	// check x and y opening
	double codx=fabs(surfx[0]-surfx[1]);
	double cody=fabs(surfy[0]-surfy[1]);
	if(codx>1.02 || cody>1.02)
	{	// OK to collapse
		x=(surfx[0]+surfx[1])/2.;
		y=(surfy[0]+surfy[1])/2.;
		if(!FindElement()) return false;
		surfx[0]=surfx[1]=x;
		surfy[0]=surfy[1]=y;
		surfInElem[0]=surfInElem[1]=planeInElem;
		SetMatID(-1);								// marks as collapsed
	}
	return true;
}
コード例 #11
0
ファイル: Failover.cpp プロジェクト: ashu1402/NASRepository
void Failover::CreateXMLForUser( DataBaseAccess *dBA,const char *DIDInfo ,char * xmlData){
	vector<string> DID,UID,UName,UserName, Password,UserRole,Email, Mobile,Status;
	dBA->GetAllUserForDID(DIDInfo,&UID,&UName,&UserName,&Password,&UserRole,&Email,&Mobile,&Status);
	xml = new CMarkup();
		xml->OutOfElem();
					if ( !FindElement(xml->GetDoc(),"XMLDakshaImaging") )
						xml->AddElem( "XMLDakshaImaging" );
	for ( int i = 0 ; i < (int)UID.size() ; i++ ){
		CheckForXMLHeader("AddUser");
		xml->AddElem("UName",UName[i].c_str());
		xml->AddElem("UserName",UserName[i].c_str());
		xml->AddElem("Password",Password[i].c_str());
		xml->AddElem("UserRole",UserRole[i].c_str());
		xml->AddElem("Email",Email[i].c_str());
		xml->AddElem("ContactNo",Mobile[i].c_str());
		xml->AddElem("Status",Status[i].c_str());
		xml->OutOfElem();
	}

	for ( int i = 0 ; i < UID.size() ; i++ ){
			dBA->DeleteTableEntry("userugrouprelation","UID",atoi(UID[i].c_str()));
		}

	dBA->DeleteTableEntryForDID("userinfo", DIDInfo);
	string xml_Data = xml->GetDoc();
		sprintf ( xmlData,"%s",xml_Data.c_str());
}
コード例 #12
0
ファイル: FGXMLElement.cpp プロジェクト: MCBama/jsbsim
double Element::FindElementValueAsNumberConvertTo(const string& el, const string& target_units)
{
  Element* element = FindElement(el);

  if (!element) {
      std::stringstream error;
    error << ReadFrom() << "Attempting to get non-existent element " << el
         << endl;
    throw std::runtime_error(error.str());
  }

  string supplied_units = element->GetAttributeValue("unit");

  if (!supplied_units.empty()) {
    if (convert.find(supplied_units) == convert.end()) {
        std::stringstream error;
      error << element->ReadFrom() << "Supplied unit: \""
           << supplied_units << "\" does not exist (typo?)." << endl;
      throw std::runtime_error(error.str());
    }
    if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
        std::stringstream error;
      error << element->ReadFrom() << "Supplied unit: \""
           << supplied_units << "\" cannot be converted to " << target_units
           << endl;
      throw std::runtime_error(error.str());
    }
  }

  double value = element->GetDataAsNumber();

  // Sanity check for angular values
  if ((supplied_units == "RAD") && (fabs(value) > 2 * M_PI)) {
      cerr << element->ReadFrom() << "The value " << value
           << " RAD is outside the range [ -2*M_PI RAD ; +2*M_PI RAD ]" << endl;
  }
  if ((supplied_units == "DEG") && (fabs(value) > 360.0)) {
      cerr << element->ReadFrom() << "The value " << value
           << " DEG is outside the range [ -360 DEG ; +360 DEG ]" << endl;
  }
  
  
  if (!supplied_units.empty()) {
    value *= convert[supplied_units][target_units];
  }

  if ((target_units == "RAD") && (fabs(value) > 2 * M_PI)) {
      cerr << element->ReadFrom() << "The value " << value
           << " RAD is outside the range [ -2*M_PI RAD ; +2*M_PI RAD ]" << endl;
  }
  if ((target_units == "DEG") && (fabs(value) > 360.0)) {
      cerr << element->ReadFrom() << "The value " << value
           << " DEG is outside the range [ -360 DEG ; +360 DEG ]" << endl;
  }

  value = DisperseValue(element, value, supplied_units, target_units);

  return value;
}
コード例 #13
0
ファイル: XmlStorage.cpp プロジェクト: skyformat99/Far-NetBox
void TXmlStorage::RemoveIfExists(const UnicodeString & Name)
{
  tinyxml2::XMLElement * Element = FindElement(Name);
  if (Element != nullptr)
  {
    FCurrentElement->DeleteChild(Element);
  }
}
コード例 #14
0
string Element::FindElementValue(string el)
{
  Element* element = FindElement(el);
  if (element) {
    return element->GetDataLine();
  } else {
    return "";
  }
}
コード例 #15
0
void CGraphicsContainer::AddElement(IElementPtr pElement)
{	
	if(FindElement(pElement)>-1)
		return ;

	m_vecElements.push_back(pElement);

	ContainerChangedEvent(pElement);
}
コード例 #16
0
HRESULT CVectorEx<TYPE>::RemoveElement(TYPE *pEl)
{
	LONG	lIndex = FindElement(pEl);

	if (0 > lIndex)
		return E_FAIL;
	
	return RemoveAt((DBORDINAL)lIndex);
} //CVectorEx<TYPE>::RemoveElement
コード例 #17
0
int DeleteElement (SeqList *L, eleType e) {
	int position = FindElement(L, e);
	for (int i = position; i <= L->listLength - 1; i++) {
		L->data[i-1] = L->data[i];
	}
	L->data[L->listLength-1] = -1;
	L->listLength--;
	return 1;
}
コード例 #18
0
double Element::FindElementValueAsNumber(string el)
{
  Element* element = FindElement(el);
  if (element) {
    return element->GetDataAsNumber();
  } else {
    cerr << "Attempting to get single data value from multiple lines" << endl;
    return 0;
  }
}
コード例 #19
0
unsigned int Element::GetNumElements(string element_name)
{
  unsigned int number_of_elements=0;
  Element* el=FindElement(element_name);
  while (el) {
    number_of_elements++;
    el=FindNextElement(element_name);
  }
  return number_of_elements;
}
コード例 #20
0
ファイル: XmlStorage.cpp プロジェクト: skyformat99/Far-NetBox
bool TXmlStorage::ValueExists(const UnicodeString & Value) const
{
  bool Result = false;
  tinyxml2::XMLElement * Element = FindElement(Value);
  if (Element != nullptr)
  {
    Result = true;
  }
  return Result;
}
コード例 #21
0
ファイル: XmlStorage.cpp プロジェクト: skyformat99/Far-NetBox
bool TXmlStorage::DeleteValue(const UnicodeString & Name)
{
  bool Result = false;
  tinyxml2::XMLElement * Element = FindElement(Name);
  if (Element != nullptr)
  {
    FCurrentElement->DeleteChild(Element);
    Result = true;
  }
  return Result;
}
コード例 #22
0
ファイル: Failover.cpp プロジェクト: ashu1402/NASRepository
void Failover::CheckForXMLHeader( const char * actionName ){

		xml->OutOfElem();
			if ( !FindElement(xml->GetDoc(),"XMLDakshaImaging") )
				xml->AddElem( "XMLDakshaImaging" );
			xml->IntoElem();
			xml->AddElem( "Action" );
			xml->AddAttrib("Name", actionName);
			xml->IntoElem();

}
コード例 #23
0
int main()
{
    int M[NROWS][NCOLS] = {
        {0, 3, 7}, 
        {1, 4, 8}, 
        {5, 6, 9}, 
        {6, 8, 10}};
    
    PrintMatrix(M);

    int elem = 5;
    std::pair<int, int> p = FindElement(M, elem);
    std::cout << "Element " << elem << " is at [" << p.first << "," << 
        p.second << "]\n";    
    
    int elem2 = 2;
    std::pair<int, int> p2 = FindElement(M, elem2);
    std::cout << "Element " << elem2 << " is at [" << p2.first << "," << 
        p2.second << "]\n";    
}
コード例 #24
0
ファイル: FGXMLElement.cpp プロジェクト: airware/jsbsim
double Element::FindElementValueAsNumber(const string& el)
{
  Element* element = FindElement(el);
  if (element) {
    double value = element->GetDataAsNumber();
    value = DisperseValue(element, value);
    return value;
  } else {
    cerr << ReadFrom() << "Attempting to get non-existent element " << el
         << endl;
    exit(-1);
  }
}
コード例 #25
0
ファイル: FGXMLElement.cpp プロジェクト: MCBama/jsbsim
double Element::FindElementValueAsNumber(const string& el)
{
  Element* element = FindElement(el);
  if (element) {
    double value = element->GetDataAsNumber();
    value = DisperseValue(element, value);
    return value;
  } else {
      std::stringstream error;
    error << ReadFrom() << "Attempting to get non-existent element " << el
         << endl;
    throw std::runtime_error(error.str());
  }
}
コード例 #26
0
ファイル: SgmlParser.cpp プロジェクト: identity0815/os45
HRESULT SgmlElement::SetElementParameter(CString csNodeName, CString csParameter) {   
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    HRESULT hr = S_OK;

    SgmlElement *pElement = FindElement(csNodeName);
    if (pElement == NULL)
        hr = E_FAIL;

    if (SUCCEEDED(hr))
        pElement->SetParameter(csParameter);

    return hr;
}
コード例 #27
0
ファイル: FGXMLElement.cpp プロジェクト: MCBama/jsbsim
FGColumnVector3 Element::FindElementTripletConvertTo( const string& target_units)
{
  FGColumnVector3 triplet;
  Element* item;
  double value=0.0;
  string supplied_units = GetAttributeValue("unit");

  if (!supplied_units.empty()) {
    if (convert.find(supplied_units) == convert.end()) {
        std::stringstream error;
      error << ReadFrom() << "Supplied unit: \""
           << supplied_units << "\" does not exist (typo?)." << endl;
      throw std::runtime_error(error.str());
    }
    if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
        std::stringstream error;
      error << ReadFrom() << "Supplied unit: \""
           << supplied_units << "\" cannot be converted to " << target_units
           << endl;
      throw std::runtime_error(error.str());
    }
  }

  item = FindElement("x");
  if (!item) item = FindElement("roll");
  if (item) {
    value = item->GetDataAsNumber();
    if (!supplied_units.empty()) value *= convert[supplied_units][target_units];
    triplet(1) = DisperseValue(item, value, supplied_units, target_units);
  } else {
    triplet(1) = 0.0;
  }
  

  item = FindElement("y");
  if (!item) item = FindElement("pitch");
  if (item) {
    value = item->GetDataAsNumber();
    if (!supplied_units.empty()) value *= convert[supplied_units][target_units];
    triplet(2) = DisperseValue(item, value, supplied_units, target_units);
  } else {
    triplet(2) = 0.0;
  }

  item = FindElement("z");
  if (!item) item = FindElement("yaw");
  if (item) {
    value = item->GetDataAsNumber();
    if (!supplied_units.empty()) value *= convert[supplied_units][target_units];
    triplet(3) = DisperseValue(item, value, supplied_units, target_units);
  } else {
    triplet(3) = 0.0;
  }

  return triplet;
}
コード例 #28
0
ファイル: Trie.cpp プロジェクト: darrellzook/zedit
/*----------------------------------------------------------------------------------------------
	Parameters:
		prgwch: 16-bit key string to find
		cchLim: Length of prgwch
		pcch:   Will contain the length of the matched word if there is one.
			This can be NULL if the length is not needed. If it is not
			NULL, it should be initialized to 0 before the call.
----------------------------------------------------------------------------------------------*/
bool CTrieLevel::FindWord(wchar * prgwch, int cchLim, const char * pszDelim, COLORREF * pcr,
	int * pcch, BOOL fCaseMatters)
{
	AssertArray(prgwch, cchLim);
	AssertPtr(pcr);
	AssertPtr(pszDelim);
	int ite;

	*pcr = m_cr;
	if (!cchLim || !FindElement(fCaseMatters ? *prgwch : towlower(*prgwch), &ite))
		return m_cr != (COLORREF)-1;
	if (pcch)
		(*pcch)++;
	return m_ppte[ite]->m_ptlSub->FindWord(prgwch + 1, cchLim - 1, pszDelim, pcr, pcch, fCaseMatters);
}
コード例 #29
0
ファイル: xml.cpp プロジェクト: Fedict/eid-test-cards
bool Xml::seekToContentElement(FILE * file, const char *element, const char *content) const
{
	if (file == NULL || element == NULL || content == NULL)
		return false;

	bool result;

	char content2[MAX_CONTENT + 1];

	do
	{
		result = FindElement(file, element, content2, MAX_CONTENT);
	} while (result && strcmp(content, content2) != 0);

	return result;
}
コード例 #30
0
FGColumnVector3 Element::FindElementTripletConvertTo( string target_units)
{
  FGColumnVector3 triplet;
  Element* item;
  double value=0.0;
  string supplied_units = GetAttributeValue("unit");

  if (!supplied_units.empty()) {
    if (convert.find(supplied_units) == convert.end()) {
      cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit"
           << " conversion in FGXMLElement.cpp." << endl;
      exit(-1);
    }
    if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
      cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to "
                   << target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl;
      exit(-1);
    }
  }

  item = FindElement("x");
  if (!item) item = FindElement("roll");
  if (item) {
    value = item->GetDataAsNumber();
    if (!supplied_units.empty()) value *= convert[supplied_units][target_units];
  } else {
    value = 0.0;
    cerr << "Could not find an X triplet item for this column vector." << endl;
  }
  triplet(1) = value;

  item = FindElement("y");
  if (!item) item = FindElement("pitch");
  if (item) {
    value = item->GetDataAsNumber();
    if (!supplied_units.empty()) value *= convert[supplied_units][target_units];
  } else {
    value = 0.0;
    cerr << "Could not find a Y triplet item for this column vector." << endl;
  }
  triplet(2) = value;

  item = FindElement("z");
  if (!item) item = FindElement("yaw");
  if (item) {
    value = item->GetDataAsNumber();
    if (!supplied_units.empty()) value *= convert[supplied_units][target_units];
  } else {
    value = 0.0;
    cerr << "Could not find a Z triplet item for this column vector." << endl;
  }
  triplet(3) = value;

  return triplet;
}