bool ProjectFileParser::ReadItemGroup(rapidxml::xml_node<>* node)
{
    std::string label = GetAttributeValue(node,"Label");
    if (label == "ProjectConfigurations")
        return ReadProjectConfigurations(node);

    rapidxml::xml_node<>* child = node->first_node();
    while (child)
    {
        switch (GetNodeType(child))
        {
            case eClCompile:
                AddSourceFile(child);
                break;
            case eClInclude:
                AddIncludeFile(child);
                break;
            case eResourceCompile:
                AddResourceFile(child);
                break;
            case eCustomBuild:
                AddCustomBuildFile(child);
                break;
            case eNone:
                break;
            case eProjectReference:
                AddProjectReference(child);
                break;
            default:
                break;
        }
        child = child->next_sibling();
    }
    return true;
}
bool ProjectFileParser::ReadPropertyGroup(rapidxml::xml_node<>* node)
{
    std::string label = GetAttributeValue(node,"Label");

    if (label == "Globals")
        return ReadGlobalProperties(node);

    if (label == "Configuration")
        return ReadConfigurationProperties(node);

    std::string configuration = GetConfigurationFromNode(node);
    rapidxml::xml_node<>* child = node->first_node();
    while (child)
    {
        std::string nodeName = child->name();

        if (nodeName == "OutDir")
            ReadOutDir(child);
        else if (nodeName == "IntDir")
            ReadIntDir(child);
        else
            m_project->SetConfigurationOption(configuration, child->name(), child->value());

        child = child->next_sibling();
    }

    return true;
}
Esempio n. 3
0
double Element::GetAttributeValueAsNumber(string attr)
{
  string attribute = GetAttributeValue(attr);

  if (attribute.empty()) return HUGE_VAL;
  else return (atof(attribute.c_str()));
}
Esempio n. 4
0
BOOL CaNodeAttribute::Matched (CaNodeAttribute* pObj, MatchObjectFlag nFlag)
{
    if (nFlag == MATCHED_NAME)
    {
        return (pObj->GetAttributeName().CompareNoCase (GetAttributeName()) == 0);
    }
    else
    {
        BOOL bOk = FALSE;
        if (pObj->GetNodeName().CompareNoCase (GetNodeName()) != 0)
            return FALSE;
        if (pObj->GetAttributeName().CompareNoCase (GetAttributeName()) != 0)
            return FALSE;
        if (pObj->GetAttributeValue().CompareNoCase (GetAttributeValue()) != 0)
            return FALSE;
        if (pObj->IsAttributePrivate() != IsAttributePrivate())
            return FALSE;

        return TRUE;
    }
    //
    // Need the implementation ?
    ASSERT (FALSE);
    return FALSE;
}
Esempio n. 5
0
long CXmlConfig::GetAttributeLong(const TCHAR* attributeName,long defValue,bool* pResult){
	bool bRet=false;
	CString strDefaultValve;
	strDefaultValve.Format(_T("%d"),defValue);
	_tstring textValue=GetAttributeValue(attributeName,strDefaultValve,&bRet);
	if(pResult) (*pResult)=bRet;
	return bRet?_ttol(textValue.c_str()):defValue;
}
Esempio n. 6
0
double CXmlConfig::GetAttributeDouble(const TCHAR* attributeName,double defValue,bool* pResult){
	bool bRet=false;
	CString strDefaultValve;
	strDefaultValve.Format(_T("%f"),defValue);
	_tstring textValue=GetAttributeValue(attributeName,strDefaultValve,&bRet);
	if(pResult) (*pResult)=bRet;
	return bRet?_tcstod(textValue.c_str(),NULL):defValue;
}
std::auto_ptr<ProjectConfigurationOptions> ProjectFileParser::ReadImport(rapidxml::xml_node<>* node)
{
    std::string project = GetAttributeValue(node,"Project");
    StringHelper::replace(project, '\\', '/');
    StringHelper::subst(project, "$(VCTargetsPath)", "." );

    return std::auto_ptr<ProjectConfigurationOptions>(NULL);
}
Esempio n. 8
0
CString CXmlConfig::GetProfileString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszDefault /*=NULL*/)
{
	bool bResult = false;
	CString strVal = GetAttributeValue(CString(lpszSection) + _T("\\") + lpszEntry,lpszDefault,&bResult).c_str();
	if (bResult)
		return strVal;

	return CString(lpszDefault);
}
//---------------------------------------------------------------------------
// Возвращает значение атрибута,
// если атрибут отсутствует, то возвращает значение DefaultValue
AnsiString __fastcall MSXMLWorks::GetAttributeValue(Variant Node, AnsiString AttributeName, String DefaultValue)
{
    AnsiString attribute = Trim(GetAttributeValue(Node, AttributeName));
    if (attribute != "") {
        return attribute;
    } else {
        return DefaultValue;
    }
}
Esempio n. 10
0
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;
}
Esempio n. 11
0
CString
CDataNode::GetAttributeValueOrChildValueByName( const CString& name ) const
{
    CString value = GetAttributeValue( name );
    if ( 0 == value.Length() )
    {
        value = GetChildValueByName( name );
    }
    return value;
}
Esempio n. 12
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;
}
Esempio n. 13
0
OGRErr GMLHandler::startElementBoundedBy(const char *pszName, int nLenName, void* attr )
{
    if ( m_nDepth == 2 && strcmp(pszName, "Envelope") == 0 )
    {
        char* pszGlobalSRSName = GetAttributeValue(attr, "srsName");
        m_poReader->SetGlobalSRSName(pszGlobalSRSName);
        CPLFree(pszGlobalSRSName);
    }

    return OGRERR_NONE;
}
Esempio n. 14
0
//---------------------------------------------------------------------------
// Возвращает значение атрибута,
// если атрибут отсутствует, то возвращает значение DefaultValue
bool __fastcall MSXMLWorks::GetAttributeValue(Variant Node, AnsiString AttributeName, bool DefaultValue)
{
    AnsiString attribute = LowerCase(Trim(GetAttributeValue(Node, AttributeName)));  // Ширина столбца

    if (attribute == "true")
        return true;
    else if (attribute == "false")
        return false;
    else
        return DefaultValue;
}
Esempio n. 15
0
//---------------------------------------------------------------------------
// Возвращает значение атрибута,
// если атрибут отсутствует, то возвращает значение DefaultValue
int __fastcall MSXMLWorks::GetAttributeValue(Variant Node, AnsiString AttributeName, int DefaultValue)
{
    AnsiString attribute = Trim(GetAttributeValue(Node, AttributeName));  // Ширина столбца
    if (attribute != "") {
        try {
            return StrToInt(attribute);
        } catch (...) {
            return DefaultValue;
        }
    } else
        return DefaultValue;
}
Esempio n. 16
0
std::string ProjectFileParser::GetConfigurationFromNode(rapidxml::xml_node<>* node)
{
    std::string condition = GetAttributeValue(node,"Condition");
    if (condition.empty()) return std::string();

    std::vector<std::string> parts = StringHelper::split(condition,"==");
    if (parts.size() != 2) return std::string();
    std::string config = parts[1];

    StringHelper::trim(config, '\'');

    return config;
}
Esempio n. 17
0
void ProjectFileParser::AddSourceFile(rapidxml::xml_node<>* node)
{
    std::string src = GetAttributeValue(node,"Include");
    StringHelper::subst(src,"\\","/");
    m_project->AddSourceFile(src);
    rapidxml::xml_node<>* child = node->first_node();
    while (child)
    {
        std::string configuration = GetConfigurationFromNode(child);
        m_project->SetFileConfigurationOption(src, configuration, child->name(), child->value());
        child = child->next_sibling();
    }
}
Esempio n. 18
0
bool CXmlConfig::GetAttributeBool(const TCHAR* attributeName,bool defValue,bool* pResult){
	bool bRet=false;
	CString strDefaultValve = defValue? _T("true"):_T("false");
	_tstring textValue=GetAttributeValue(attributeName,strDefaultValve,&bRet);
	if(pResult) (*pResult)=bRet;
	if(!bRet) return defValue;

	transform(textValue.begin(),textValue.end(),textValue.begin(),_ttolower);
	if(textValue.find(_T("true"))!=_tstring::npos) return true;
	if(textValue.find(_T("false"))!=_tstring::npos) return false;
	if(textValue==_T("1")) return true;
	if(textValue==_T("0")) return false;

	if(pResult) (*pResult)=false;
	return defValue;
}
Esempio n. 19
0
/**************************************************************************
* name       : ModifyAttributeValue
* description: 修改元素属性值
* input      : pszAttriName 待修改的属性名
               pszAttriValue 对应的属性值
* output     : NA
* return     : NA
* remark     : NA
**************************************************************************/
void CXml::ModifyAttributeValue(const char *pszAttriName, const char *pszAttriValue)
{
    if ((NULL == pszAttriName) || (NULL == pszAttriValue))
    {
        return;
    }

    if (NULL == m_pXmlElem)
    {
        return;
    }

    if (NULL != GetAttributeValue(pszAttriName))
    {
        m_pXmlElem->SetAttribute(pszAttriName, pszAttriValue);
    }
}
Esempio n. 20
0
BOOL NodeAttribute::HasEquivalentDefaultValue(BOOL bAppearance)
{
	AttributeValue* pDefaultAttrVal = NULL;
//	CCRuntimeClass* AttrType = GetAttributeType();

	// Look for the default attr directly
	// (But this doesn't work for those attrs which are grouped together
	//	and share a common default value - e.g. fills)
	AttrIndex attrid = GetAttributeIndex();
	if (attrid!=ATTR_BAD_ID && attrid<ATTR_FIRST_FREE_ID)
		pDefaultAttrVal = AttributeManager::GetDefaultAttributeVal(attrid);

	if (pDefaultAttrVal && !GetAttributeValue()->IsDifferent(pDefaultAttrVal))
	{
		// Just allow the node to be hidden
		return TRUE;
	}

	return FALSE;
}
Esempio n. 21
0
void ProjectFileParser::AddProjectReference(rapidxml::xml_node<>* node)
{
    ProjectReference pr;

    pr.projectFile = GetAttributeValue(node,"Include");
    rapidxml::xml_node<>* child = node->first_node();
    while (child)
    {
        std::string nodeName = child->name();

        if (nodeName == "Project")
            pr.projectGUID = child->value();

        if (nodeName == "ReferenceOutputAssembly")
            pr.refOutputAssembly = std::string(child->value()) != "false";

        child = child->next_sibling();
    }
    m_project->AddReferenceProject(pr);
}
Esempio n. 22
0
bool ProjectFileParser::ReadProjectConfiguration(rapidxml::xml_node<>* node)
{
    std::string configName = GetAttributeValue(node,"Include");
    std::string configuration;
    std::string platform;

    rapidxml::xml_node<>* child = node->first_node();
    while (child)
    {
        std::string nodeName = child->name();

        if (nodeName == "Configuration")
            configuration = child->value();

        if (nodeName == "Platform")
            platform = child->value();

        m_project->AddConfiguration(configName);
        child = child->next_sibling();
    }
    return true;
}
Esempio n. 23
0
double Element::GetAttributeValueAsNumber(const string& attr)
{
  string attribute = GetAttributeValue(attr);

  if (attribute.empty()) {
    cerr << ReadFrom() << "Expecting numeric attribute value, but got no data"
         << endl;
    exit(-1);
  }
  else {
    double number=0;
    if (is_number(trim(attribute)))
      number = atof(attribute.c_str());
    else {
      cerr << ReadFrom() << "Expecting numeric attribute value, but got: "
           << attribute << endl;
      exit(-1);
    }
    
    return (number);
  }
}
Esempio n. 24
0
void ProjectFileParser::AddCustomBuildFile(rapidxml::xml_node<>* node)
{
    std::string src = GetAttributeValue(node,"Include");
    StringHelper::subst(src,"\\","/");

    CustomBuildFile cbf;
    cbf.SetFileName(src);

    rapidxml::xml_node<>* child = node->first_node();
    while (child)
    {
        std::string configuration = GetConfigurationFromNode(child);
        std::string option = child->name();

        if (option == std::string("Command"))
            cbf.SetConfigurationCommandLine(configuration, child->value());

        if (option == std::string("Outputs"))
            cbf.SetConfigurationOutput(configuration, child->value());

        child = child->next_sibling();
    }
    m_project->AddCustomBuildFile(cbf);
}
Esempio n. 25
0
double Element::GetAttributeValueAsNumber(const string& attr)
{
  string attribute = GetAttributeValue(attr);

  if (attribute.empty()) {
      std::stringstream error;
    error << ReadFrom() << "Expecting numeric attribute value, but got no data"
         << endl;
    throw std::runtime_error(error.str());
  }
  else {
    double number=0;
    if (is_number(trim(attribute)))
      number = atof(attribute.c_str());
    else {
        std::stringstream error;
      error << ReadFrom() << "Expecting numeric attribute value, but got: "
           << attribute << endl;
      throw std::runtime_error(error.str());
    }
    
    return (number);
  }
}
Esempio n. 26
0
HRESULT ParseDnaHeader(std::wstring header, std::wstring& addInName, std::wstring& runtimeVersion, bool& shadowCopyFiles, std::wstring& createSandboxedAppDomain)
{
	HRESULT hr;

	size_t rootTagStart = header.find(L"<DnaLibrary");
	if (rootTagStart == -1)
	{
		// Parse error
		return E_FAIL;
	}

	size_t rootTagEnd = header.find(L">", rootTagStart);
	if (rootTagEnd == -1)
	{
		// Parse error
		return E_FAIL;
	}

	std::wstring rootTag = header.substr(rootTagStart, rootTagEnd - rootTagStart + 1);

	// CONSIDER: Some checks, e.g. "v.X..."
	hr = GetAttributeValue(rootTag, L"RuntimeVersion", runtimeVersion);
	if (FAILED(hr))
	{
		// Parse error
		return E_FAIL;
	}
	if (hr == S_FALSE)
	{
		runtimeVersion = CLR_VERSION_20;
		hr = S_OK;
	}

	std::wstring shadowCopyFilesValue;
	hr = GetAttributeValue(rootTag, L"ShadowCopyFiles", shadowCopyFilesValue);
	if (FAILED(hr))
	{
		// Parse error
		return E_FAIL;
	}
	if (hr == S_FALSE)
	{
		shadowCopyFiles = false;
		hr = S_OK;
	}
	else // attribute read OK
	{
		if (CompareNoCase(shadowCopyFilesValue, L"true") == 0)
			shadowCopyFiles = true;
		else
			shadowCopyFiles = false;
	}

	hr = GetAttributeValue(rootTag, L"CreateSandboxedAppDomain", createSandboxedAppDomain);
	if (FAILED(hr))
	{
		// Parse error
		return E_FAIL;
	}
	if (hr == S_FALSE)
	{
		createSandboxedAppDomain = L"";
		hr = S_OK;
	}

	hr = GetAttributeValue(rootTag, L"Name", addInName);
	if (FAILED(hr))
	{
		// Parse error
		return E_FAIL;
	}
	if (hr == S_FALSE)
	{
		addInName = L"";
		hr = S_OK;
	}
	return hr;
}
Esempio n. 27
0
void ProjectFileParser::AddResourceFile(rapidxml::xml_node<>* node)
{
    std::string resource = GetAttributeValue(node,"Include");
    m_project->AddResourceFile(resource);
}
Esempio n. 28
0
HRESULT CXmlHelper::Initialize(IXMLDOMElement *lpRootElem)
{
  TNktComPtr<IXMLDOMElement> cCurrElem, cNextElem;
  CNktComBStr cElemAttrIdBStr, cNameBstr;
  HRESULT hRes;
  SIZE_T i;
  LONG k;

  nktMemSet(aFundTypesIndexes, 0, sizeof(aFundTypesIndexes));
  hRes = GetFirstChildElement(lpRootElem, &cCurrElem);
  if (FAILED(hRes))
    return hRes;
  while (cCurrElem != NULL)
  {
    cElemAttrIdBStr.Reset();
    hRes = GetAttributeValue(cCurrElem, L"id", &cElemAttrIdBStr);
    if (FAILED(hRes))
    {
init_on_error:
      Reset();
      return hRes;
    }
    if (cElemAttrIdBStr[0] != 0)
    {
      //add this element
      if (nIdElemMapEntriesCount >= nIdElemMapEntriesSize)
      {
        ID_ELEM_MAP_ENTRY *lpNew;

        lpNew = (ID_ELEM_MAP_ENTRY*)nktMemMalloc((nIdElemMapEntriesSize+10240)*sizeof(ID_ELEM_MAP_ENTRY));
        if (lpNew == NULL) {
          hRes = E_OUTOFMEMORY;
          goto init_on_error;
        }
        nIdElemMapEntriesSize += 10240;
        if (lpIdElemMapEntries != NULL)
        {
          nktMemCopy(lpNew, lpIdElemMapEntries, nIdElemMapEntriesCount*sizeof(ID_ELEM_MAP_ENTRY));
          nktMemFree(lpIdElemMapEntries);
        }
        lpIdElemMapEntries = lpNew;
      }
      wcsncpy_s(lpIdElemMapEntries[nIdElemMapEntriesCount].szIdW, cElemAttrIdBStr, 16);
      lpIdElemMapEntries[nIdElemMapEntriesCount].szIdW[15] = 0;
      k = GetDbObjectClass(cCurrElem, 1);
      if (k == -1)
      {
        hRes = E_OUTOFMEMORY;
        goto init_on_error;
      }
      if (k == NKT_DBOBJCLASS_Fundamental)
      {
        cNameBstr.Reset();
        hRes = GetAttributeValue(cCurrElem, L"name", &cNameBstr);
        if (FAILED(hRes))
          goto init_on_error;
        if (_wcsicmp((LPWSTR)cNameBstr, L"signed char") == 0)
          k = NKT_DBFUNDTYPE_SignedByte;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"char") == 0)
          k = NKT_DBFUNDTYPE_AnsiChar;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"unsigned char") == 0)
          k = NKT_DBFUNDTYPE_UnsignedByte;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"short int") == 0)
          k = NKT_DBFUNDTYPE_SignedWord;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"short unsigned int") == 0)
          k = NKT_DBFUNDTYPE_UnsignedWord;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"int") == 0 ||
                 _wcsicmp((LPWSTR)cNameBstr, L"long int") == 0 ||
                 _wcsicmp((LPWSTR)cNameBstr, L"bool") == 0)
          k = NKT_DBFUNDTYPE_SignedDoubleWord;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"unsigned int") == 0 ||
                 _wcsicmp((LPWSTR)cNameBstr, L"long unsigned int") == 0)
          k = NKT_DBFUNDTYPE_UnsignedDoubleWord;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"long long int") == 0)
          k = NKT_DBFUNDTYPE_SignedQuadWord;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"long long unsigned int") == 0)
          k = NKT_DBFUNDTYPE_UnsignedQuadWord;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"float") == 0)
          k = NKT_DBFUNDTYPE_Float;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"double") == 0)
          k = NKT_DBFUNDTYPE_Double;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"long double") == 0)
          k = NKT_DBFUNDTYPE_LongDouble;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"wchar_t") == 0)
          k = NKT_DBFUNDTYPE_WideChar;
        else if (_wcsicmp((LPWSTR)cNameBstr, L"void") == 0)
          k = NKT_DBFUNDTYPE_Void;
        else {
          hRes = E_FAIL;
          goto init_on_error;
        }
        aFundTypesIndexes[k-NKT_DBFUNDTYPE_MIN] = 1;
      }
      else
        k = 0;
      lpIdElemMapEntries[nIdElemMapEntriesCount].nFundamentalType = (ULONG)k;
      lpIdElemMapEntries[nIdElemMapEntriesCount].lpElem = cCurrElem;
      lpIdElemMapEntries[nIdElemMapEntriesCount].lpElem->AddRef();
      nIdElemMapEntriesCount++;
    }
    //get next element
    hRes = GetNextElement(cCurrElem, &cNextElem);
    if (FAILED(hRes))
      goto init_on_error;
    cCurrElem.Attach(cNextElem.Detach());
  }
  //fast fundamental quick check
  for (k=0; k<X_ARRAYLEN(aFundTypesIndexes); k++) {
    if (aFundTypesIndexes[k] == 0) {
      hRes = E_FAIL;
      goto init_on_error;
    }
  }
  //sort elements by id
  qsort_s(lpIdElemMapEntries, nIdElemMapEntriesCount, sizeof(ID_ELEM_MAP_ENTRY), IdElemMapEntry_Compare,
          NULL);
  //find each fundamental
  nktMemSet(aFundTypesIndexes, 0, sizeof(aFundTypesIndexes));
  for (i=0; i<nIdElemMapEntriesCount; i++)
  {
    if (lpIdElemMapEntries[i].nFundamentalType != 0)
      aFundTypesIndexes[lpIdElemMapEntries[i].nFundamentalType - NKT_DBFUNDTYPE_MIN] = i;
  }
  //fast fundamental quick check (should not happen)
  for (k=0; k<X_ARRAYLEN(aFundTypesIndexes); k++) {
    if (aFundTypesIndexes[k] == 0) {
      hRes = E_FAIL;
      goto init_on_error;
    }
  }
  return S_OK;
}
Esempio n. 29
0
_tstring CXmlConfig::GetAttributeText(const TCHAR* attributeName,_tstring defValue,bool* pResult){
	bool bRet=false;
	_tstring textValue=GetAttributeValue(attributeName,defValue.c_str(),&bRet);
	if(pResult) (*pResult)=bRet;
	return bRet?textValue:defValue;
}
Esempio n. 30
0
OGRErr GMLHandler::startElement(const char *pszName, void* attr )

{
    GMLReadState *poState = m_poReader->GetState();

    if (m_bIgnoreFeature && m_nDepth >= m_nDepthFeature)
    {
        m_nDepth ++;
        return CE_None;
    }

    if ( m_nDepth == 0 )
    {
        if (strcmp(pszName, "CityModel") == 0 )
        {
            m_bIsCityGML = TRUE;
        }
        else if (strcmp(pszName, "AIXMBasicMessage") == 0)
        {
            m_bIsAIXM = m_bReportHref = TRUE;
        }
    }
    else if ( m_nDepth == 2 && m_bInBoundedBy )
    {
        if ( strcmp(pszName, "Envelope") == 0 )
        {
            char* pszGlobalSRSName = GetAttributeValue(attr, "srsName");
            if (pszGlobalSRSName != NULL &&
                strncmp(pszGlobalSRSName, "EPSG:", 5) == 0 &&
                CSLTestBoolean(CPLGetConfigOption("GML_CONSIDER_EPSG_AS_URN", "NO")))
            {
                char* pszNew = CPLStrdup(CPLSPrintf("urn:ogc:def:crs:EPSG::%s", pszGlobalSRSName+5));
                CPLFree(pszGlobalSRSName);
                pszGlobalSRSName = pszNew;
            }
            m_poReader->SetGlobalSRSName(pszGlobalSRSName);
            CPLFree(pszGlobalSRSName);
        }
    }

/* -------------------------------------------------------------------- */
/*      If we are in the midst of collecting a feature attribute        */
/*      value, then this must be a complex attribute which we don't     */
/*      try to collect for now, so just terminate the field             */
/*      collection.                                                     */
/* -------------------------------------------------------------------- */
    if( m_pszCurField != NULL )
    {
        CPLFree( m_pszCurField );
        m_pszCurField = NULL;
    }

    if ( m_bInCityGMLGenericAttr )
    {
        if( strcmp(pszName, "value") == 0 )
        {
            CPLFree( m_pszCurField );
            m_pszCurField = CPLStrdup("");
        }
    }

/* -------------------------------------------------------------------- */
/*      If we are collecting geometry, or if we determine this is a     */
/*      geometry element then append to the geometry info.              */
/* -------------------------------------------------------------------- */
    else if( poState->m_poFeature != NULL &&
             (m_pszGeometry != NULL
              || IsGeometryElement( pszName )
              || (m_bIsAIXM && strcmp( pszName, "ElevatedPoint") == 0)) )
    {
        int bReadGeometry;

        if( m_pszGeometry == NULL )
        {
            /* If the <GeometryElementPath> is defined in the .gfs, use it */
            /* to read the appropriate geometry element */
            const char* pszGeometryElement = (poState->m_poFeature) ?
                    poState->m_poFeature->GetClass()->GetGeometryElement() : NULL;
            if (pszGeometryElement != NULL)
                bReadGeometry = strcmp(poState->m_pszPath, pszGeometryElement) == 0;
            else
            {
                /* AIXM special case: for RouteSegment, we only want to read Curve geometries */
                /* not 'start' and 'end' geometries */
                if (m_bIsAIXM &&
                    strcmp(poState->m_poFeature->GetClass()->GetName(), "RouteSegment") == 0)
                    bReadGeometry = strcmp( pszName, "Curve") == 0;
                else
                    bReadGeometry = TRUE;
            }
            CPLAssert(m_nGeometryDepth == 0);
            m_nGeometryDepth = m_nDepth;
        }
        else
            bReadGeometry = TRUE;

        if (bReadGeometry)
        {
            char* pszAttributes = GetAttributes(attr);
            size_t nLNLenBytes = strlen(pszName);

            /* Some CityGML lack a srsDimension="3" in posList, such as in */
            /* http://www.citygml.org/fileadmin/count.php?f=fileadmin%2Fcitygml%2Fdocs%2FFrankfurt_Street_Setting_LOD3.zip */
            /* So we have to add it manually */
            if (m_bIsCityGML && strcmp(pszName, "posList") == 0 &&
                strstr(pszAttributes, "srsDimension") == NULL)
            {
                CPLFree(pszAttributes);
                pszAttributes = CPLStrdup(" srsDimension=\"3\"");
            }

            if( m_nGeomLen + nLNLenBytes + 4 + strlen( pszAttributes ) >
                m_nGeomAlloc )
            {
                m_nGeomAlloc = (size_t) (m_nGeomAlloc * 1.3 + nLNLenBytes + 1000 +
                                    strlen( pszAttributes ));
                char* pszNewGeometry = (char *)
                    VSIRealloc( m_pszGeometry, m_nGeomAlloc);
                if (pszNewGeometry == NULL)
                {
                    CPLFree(pszAttributes);
                    return CE_Failure;
                }
                m_pszGeometry = pszNewGeometry;
            }

            strcpy( m_pszGeometry+m_nGeomLen++, "<" );
            strcpy( m_pszGeometry+m_nGeomLen, pszName );
            m_nGeomLen += nLNLenBytes;
            /* saving attributes */
            strcat( m_pszGeometry + m_nGeomLen, pszAttributes );
            m_nGeomLen += strlen( pszAttributes );
            CPLFree(pszAttributes);
            strcat( m_pszGeometry + (m_nGeomLen++), ">" );
        }
    }

    else if (m_nGeometryDepth != 0 && m_nDepth > m_nGeometryDepth)
    {
        ;
    }

    else if( m_bInBoundedBy)
    {
        ;
    }

/* -------------------------------------------------------------------- */
/*      Is it a feature?  If so push a whole new state, and return.     */
/* -------------------------------------------------------------------- */
    else if( m_nDepthFeature == 0 &&
             m_poReader->IsFeatureElement( pszName ) )
    {
        const char* pszFilteredClassName = m_poReader->GetFilteredClassName();
        if ( pszFilteredClassName != NULL &&
             strcmp(pszName, pszFilteredClassName) != 0 )
        {
            m_bIgnoreFeature = TRUE;
            m_nDepthFeature = m_nDepth;
            m_nDepth ++;

            return CE_None;
        }

        m_bIgnoreFeature = FALSE;

        char* pszFID = GetFID(attr);

        m_poReader->PushFeature( pszName, pszFID);

        CPLFree(pszFID);

        m_nDepthFeature = m_nDepth;
        m_nDepth ++;

        return CE_None;
    }

    else if( strcmp(pszName, "boundedBy") == 0 )
    {
        m_bInBoundedBy = TRUE;
        m_inBoundedByDepth = m_nDepth;
    }

/* -------------------------------------------------------------------- */
/*      Is it a CityGML generic attribute ?                             */
/* -------------------------------------------------------------------- */
    else if( m_poReader->IsCityGMLGenericAttributeElement( pszName, attr ) )
    {
        m_bInCityGMLGenericAttr = TRUE;
        CPLFree(m_pszCityGMLGenericAttrName);
        m_pszCityGMLGenericAttrName = GetAttributeValue(attr, "name");
        m_inCityGMLGenericAttrDepth = m_nDepth;
    }

/* -------------------------------------------------------------------- */
/*      If it is (or at least potentially is) a simple attribute,       */
/*      then start collecting it.                                       */
/* -------------------------------------------------------------------- */
    else if( m_poReader->IsAttributeElement( pszName ) )
    {
        CPLFree( m_pszCurField );
        m_pszCurField = CPLStrdup("");
        if (m_bReportHref)
        {
            CPLFree(m_pszHref);
            m_pszHref = GetAttributeValue(attr, "xlink:href");
        }
        CPLFree(m_pszUom);
        m_pszUom = GetAttributeValue(attr, "uom");
        CPLFree(m_pszValue);
        m_pszValue = GetAttributeValue(attr, "value");
    }
    else if( m_bReportHref && m_poReader->IsAttributeElement( CPLSPrintf("%s_href", pszName ) ) )
    {
        CPLFree( m_pszCurField );
        m_pszCurField = CPLStrdup("");
        CPLFree(m_pszHref);
        m_pszHref = GetAttributeValue(attr, "xlink:href");
    }

/* -------------------------------------------------------------------- */
/*      Push the element onto the current state's path.                 */
/* -------------------------------------------------------------------- */
    poState->PushPath( pszName );

    m_nDepth ++;

    return CE_None;
}