WriteXmlOutcome CRTF_SectionMarker::WriteRedlineMLStart(CComPtr<IXmlWriter>& xmlWriter, RedlineMLWriterContext& context)
{
	if (m_bDeletion && m_bMatched) // synthetic section break for something like redline summary - not wanted in redlineML
		return  (WriteXmlOutcome) (WroteNothing + ProcessedChildren);

	CHECKHREX(xmlWriter->WriteStartElement(NULL, L"sectionMarker", NULL));
	if (!GetBridge())
		WriteInsertedOrDeletedRedlineML(xmlWriter);

	if (!m_bDeletion)
	{
	for (int i=0; i<GetHdrFtrCount(); i++)
	{
		if (theHdrFtrs[i] == NULL)
			continue;

		int iType = GetHdrFtrType(i);
		if (IsFooter(iType) && context.m_pOptions->m_pOverrideFooter)
			continue;

			CHECKHREX(xmlWriter->WriteStartElement(NULL, GetElementName(iType), NULL));
			CHECKHREX(xmlWriter->WriteAttributeString(NULL, L"type", NULL, GetHdrFtrTypeAttrVal(iType)));
			
			bool isDummy = theDummyFlags[i];
			bool otherIsDummy = false;
			if (GetBridge())
			{
				CRTF_SectionMarker* pBridge = (CRTF_SectionMarker*) GetBridge();
				for (int i=0; i<pBridge->GetHdrFtrCount(); i++)
				{
					if (pBridge->GetHdrFtrType(i) == iType)
					{
						otherIsDummy = pBridge->theDummyFlags[i];
						break;
					}
				}
			}

			if (isDummy && !otherIsDummy)
				CHECKHREX(xmlWriter->WriteAttributeString(NULL, L"isDeleted", NULL, L"true"));
			if (otherIsDummy && ! isDummy)
				CHECKHREX(xmlWriter->WriteAttributeString(NULL, L"isInserted", NULL, L"true"));

		GetHdrFtrAt(i)->WriteRedlineMLChain(xmlWriter, context);
			CHECKHREX(xmlWriter->WriteEndElement());
	}

	if (context.m_pOptions->m_pOverrideFooter)
	{
			CHECKHREX(xmlWriter->WriteStartElement(NULL, GetElementName(RTFhdrftr::foot), NULL));
			CHECKHREX(xmlWriter->WriteAttributeString(NULL, L"type", NULL, GetHdrFtrTypeAttrVal(RTFhdrftr::foot)));
		context.m_pOptions->m_pOverrideFooter->WriteRedlineMLChain(xmlWriter, context);
			CHECKHREX(xmlWriter->WriteEndElement());
	}
	}

	CHECKHREX(xmlWriter->WriteEndElement());
	return (WriteXmlOutcome) (WroteStartTag + WroteEndTag + ProcessedChildren);
}
Example #2
0
AAFRESULT ImplAAFTypeDefExtEnum::LookupValByName(aafUID_t *pVal, const aafCharacter *pName)
{
	aafUInt32 i=0;
	aafUInt32 count=0;
	aafBoolean_t  bFound = kAAFFalse;
	aafCharacter Name_buf[256]; 
	aafUInt32 bufSize = 256;
	
	check_hr ( CountElements(&count) );
	while ( (i<count) && !bFound)
	{
		check_hr ( GetElementName (i, Name_buf, bufSize) );
		if ( wcscmp (Name_buf, pName) == 0 ) //matched
		{
			bFound = kAAFTrue;
			
			check_hr (GetElementValue(i, pVal));
			break;
			
		}//if
		i++;
	}//while

	if (!bFound)
		return AAFRESULT_INVALID_PARAM;

	return AAFRESULT_SUCCESS;
}
Example #3
0
LONG CXmlHelper::GetDbObjectClass(IXMLDOMElement *lpElem, LONG nType2Check)
{
  CNktComBStr bStr;

  if (FAILED(GetElementName(lpElem, &bStr)))
    return -1;
  switch (nType2Check)
  {
    case 1:
      if (_wcsicmp((LPWSTR)bStr, L"FundamentalType") == 0)
        return NKT_DBOBJCLASS_Fundamental;
      if (_wcsicmp((LPWSTR)bStr, L"Struct") == 0 ||
          _wcsicmp((LPWSTR)bStr, L"Class") == 0)
        return NKT_DBOBJCLASS_Struct;
      if (_wcsicmp((LPWSTR)bStr, L"Union") == 0)
        return NKT_DBOBJCLASS_Union;
      if (_wcsicmp((LPWSTR)bStr, L"Typedef") == 0)
        return NKT_DBOBJCLASS_Typedef;
      if (_wcsicmp((LPWSTR)bStr, L"ArrayType") == 0)
        return NKT_DBOBJCLASS_Array;
      if (_wcsicmp((LPWSTR)bStr, L"PointerType") == 0)
        return NKT_DBOBJCLASS_Pointer;
      if (_wcsicmp((LPWSTR)bStr, L"ReferenceType") == 0)
        return NKT_DBOBJCLASS_Reference;
      if (_wcsicmp((LPWSTR)bStr, L"Enumeration") == 0)
        return NKT_DBOBJCLASS_Enumeration;
      if (_wcsicmp((LPWSTR)bStr, L"FunctionType") == 0)
        return NKT_DBOBJCLASS_FunctionType;
      break;
    case 2:
      if (_wcsicmp((LPWSTR)bStr, L"Field") == 0)
        return SPECIAL_DBOBJ_CLASS_Field;
      if (_wcsicmp((LPWSTR)bStr, L"Constructor") == 0)
        return NKT_DBOBJCLASS_ClassConstructor;
      if (_wcsicmp((LPWSTR)bStr, L"Destructor") == 0)
        return NKT_DBOBJCLASS_ClassDestructor;
      if (_wcsicmp((LPWSTR)bStr, L"OperatorMethod") == 0)
        return NKT_DBOBJCLASS_ClassOperatorMethod;
      if (_wcsicmp((LPWSTR)bStr, L"Method") == 0)
        return NKT_DBOBJCLASS_ClassMethod;
      if (_wcsicmp((LPWSTR)bStr, L"Converter") == 0)
        return NKT_DBOBJCLASS_ClassConverter;
      if (_wcsicmp((LPWSTR)bStr, L"Variable") == 0)
        return SPECIAL_DBOBJ_CLASS_Variable;
      if (_wcsicmp((LPWSTR)bStr, L"Struct") == 0 ||
          _wcsicmp((LPWSTR)bStr, L"Class") == 0)
        return NKT_DBOBJCLASS_Struct;
      if (_wcsicmp((LPWSTR)bStr, L"Union") == 0)
        return NKT_DBOBJCLASS_Union;
      if (_wcsicmp((LPWSTR)bStr, L"Typedef") == 0)
        return NKT_DBOBJCLASS_Typedef;
      if (_wcsicmp((LPWSTR)bStr, L"Enumeration") == 0)
        return NKT_DBOBJCLASS_Enumeration;
      if (_wcsicmp((LPWSTR)bStr, L"FunctionType") == 0)
        return NKT_DBOBJCLASS_FunctionType;
      break;
  }
  return -2;
}
Example #4
0
	//--------------------------------------------------------------------------------
	std::string Serializer::ReadLevel()
	{
		LoadFirstItem();
		
		std::string levelscript;

		do {
			if(CheckAttribute("type", "gameobject") || CheckAttribute("type", "archetype"))
				g_FACTORY->Create(*this, GetElementName());
			else if(CheckAttribute("type", "script"))
				levelscript = GetAttributeString("name");
		} while(NextNode());

		return levelscript;
	}
Example #5
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefExtEnum::GetNameFromAUID (
										const aafUID_t & value,
										wchar_t * pName,
										aafUInt32 bufSize)
{
	if (! pName)
		return AAFRESULT_NULL_PARAM;
	
	AAFRESULT hr;
	aafUInt32 len;
	// following call may return AAFRESULT_ILLEGAL_VALUE if value isn't
	// recognized
	hr = GetNameBufLenFromAUID (value, &len);
	if (AAFRESULT_FAILED(hr))
		return hr;
	
	// len includes space for trailing null
	if (bufSize < len)
		return AAFRESULT_SMALLBUF;
	
	aafUInt32 i;
	aafUInt32 count;
	hr = CountElements(&count);
	if (AAFRESULT_FAILED(hr))
		return hr;
	for (i = 0; i < count; i++)
	{
		aafUID_t val;
		hr = GetElementValue (i, &val);
		if (AAFRESULT_FAILED(hr))
			return hr;
		if (EqualAUID (&val, &value))
		{
			// given integer value matches value of "i"th element.
			hr = GetElementName(i, pName, bufSize);
			if (AAFRESULT_FAILED(hr))
				return hr;
			return AAFRESULT_SUCCESS;
		}
	}
	// fell out of for() loop, so we didn't find it.
	// redundant, since GetNameBufLenFromInteger() should have already
	// found it.
	return AAFRESULT_ILLEGAL_VALUE;
}
Example #6
0
CPLXMLNode *GMLFeatureClass::SerializeToXML()

{
    CPLXMLNode  *psRoot;
    int         iProperty;

/* -------------------------------------------------------------------- */
/*      Set feature class and core information.                         */
/* -------------------------------------------------------------------- */
    psRoot = CPLCreateXMLNode( NULL, CXT_Element, "GMLFeatureClass" );

    CPLCreateXMLElementAndValue( psRoot, "Name", GetName() );
    CPLCreateXMLElementAndValue( psRoot, "ElementPath", GetElementName() );
    if( GetGeometryElement() != NULL && strlen(GetGeometryElement()) > 0 )
        CPLCreateXMLElementAndValue( psRoot, "GeometryElementPath", 
                                     GetGeometryElement() );
    
    if( GetGeometryType() != 0 /* wkbUnknown */ )
    {
        char szValue[128];

        sprintf( szValue, "%d", GetGeometryType() );
        CPLCreateXMLElementAndValue( psRoot, "GeometryType", szValue );
    }

/* -------------------------------------------------------------------- */
/*      Write out dataset specific information.                         */
/* -------------------------------------------------------------------- */
    CPLXMLNode *psDSI;

    if( m_bHaveExtents || m_nFeatureCount != -1 || m_pszExtraInfo != NULL )
    {
        psDSI = CPLCreateXMLNode( psRoot, CXT_Element, "DatasetSpecificInfo" );

        if( m_nFeatureCount != -1 )
        {
            char szValue[128];

            sprintf( szValue, "%d", m_nFeatureCount );
            CPLCreateXMLElementAndValue( psDSI, "FeatureCount", szValue );
        }

        if( m_bHaveExtents )
        {
            char szValue[128];

            sprintf( szValue, "%.5f", m_dfXMin );
            CPLCreateXMLElementAndValue( psDSI, "ExtentXMin", szValue );

            sprintf( szValue, "%.5f", m_dfXMax );
            CPLCreateXMLElementAndValue( psDSI, "ExtentXMax", szValue );

            sprintf( szValue, "%.5f", m_dfYMin );
            CPLCreateXMLElementAndValue( psDSI, "ExtentYMin", szValue );

            sprintf( szValue, "%.5f", m_dfYMax );
            CPLCreateXMLElementAndValue( psDSI, "ExtentYMax", szValue );
        }

        if( m_pszExtraInfo )
            CPLCreateXMLElementAndValue( psDSI, "ExtraInfo", m_pszExtraInfo );
    }
    
/* -------------------------------------------------------------------- */
/*      emit property information.                                      */
/* -------------------------------------------------------------------- */
    for( iProperty = 0; iProperty < GetPropertyCount(); iProperty++ )
    {
        GMLPropertyDefn *poPDefn = GetProperty( iProperty );
        CPLXMLNode *psPDefnNode;
        const char *pszTypeName = "Unknown";

        psPDefnNode = CPLCreateXMLNode( psRoot, CXT_Element, "PropertyDefn" );
        CPLCreateXMLElementAndValue( psPDefnNode, "Name", 
                                     poPDefn->GetName() );
        CPLCreateXMLElementAndValue( psPDefnNode, "ElementPath", 
                                     poPDefn->GetSrcElement() );
        switch( poPDefn->GetType() )
        {
          case GMLPT_Untyped:
            pszTypeName = "Untyped";
            break;
            
          case GMLPT_String:
            pszTypeName = "String";
            break;
            
          case GMLPT_Integer:
            pszTypeName = "Integer";
            break;
            
          case GMLPT_Real:
            pszTypeName = "Real";
            break;
            
          case GMLPT_Complex:
            pszTypeName = "Complex";
            break;

          case GMLPT_IntegerList:
            pszTypeName = "IntegerList";
            break;

          case GMLPT_RealList:
            pszTypeName = "RealList";
            break;

          case GMLPT_StringList:
            pszTypeName = "StringList";
            break;
        }
        CPLCreateXMLElementAndValue( psPDefnNode, "Type", pszTypeName );

        if( EQUAL(pszTypeName,"String") )
        {
            char szMaxLength[48];
            sprintf(szMaxLength, "%d", poPDefn->GetWidth());
            CPLCreateXMLElementAndValue ( psPDefnNode, "Width", szMaxLength );
        }
        if( poPDefn->GetWidth() > 0 && EQUAL(pszTypeName,"Integer") )
        {
            char szLength[48];
            sprintf(szLength, "%d", poPDefn->GetWidth());
            CPLCreateXMLElementAndValue ( psPDefnNode, "Width", szLength );
        }
        if( poPDefn->GetWidth() > 0 && EQUAL(pszTypeName,"Real") )
        {
            char szLength[48];
            sprintf(szLength, "%d", poPDefn->GetWidth());
            CPLCreateXMLElementAndValue ( psPDefnNode, "Width", szLength );
            char szPrecision[48];
            sprintf(szPrecision, "%d", poPDefn->GetPrecision());
            CPLCreateXMLElementAndValue ( psPDefnNode, "Precision", szPrecision );
        }
    }

    return psRoot;
}
Example #7
0
CPLXMLNode *GMLFeatureClass::SerializeToXML()

{
    CPLXMLNode  *psRoot;
    int         iProperty;

/* -------------------------------------------------------------------- */
/*      Set feature class and core information.                         */
/* -------------------------------------------------------------------- */
    psRoot = CPLCreateXMLNode( NULL, CXT_Element, "GMLFeatureClass" );

    CPLCreateXMLElementAndValue( psRoot, "Name", GetName() );
    CPLCreateXMLElementAndValue( psRoot, "ElementPath", GetElementName() );
    
    if( m_nGeometryPropertyCount > 1 )
    {
        for(int i=0; i < m_nGeometryPropertyCount; i++)
        {
            GMLGeometryPropertyDefn* poGeomFDefn = m_papoGeometryProperty[i];

            CPLXMLNode *psPDefnNode;
            psPDefnNode = CPLCreateXMLNode( psRoot, CXT_Element, "GeomPropertyDefn" );
            if( strlen(poGeomFDefn->GetName()) > 0 )
                CPLCreateXMLElementAndValue( psPDefnNode, "Name", 
                                             poGeomFDefn->GetName() );
            if( poGeomFDefn->GetSrcElement() != NULL && strlen(poGeomFDefn->GetSrcElement()) > 0 )
                CPLCreateXMLElementAndValue( psPDefnNode, "ElementPath", 
                                             poGeomFDefn->GetSrcElement() );
            
            if( poGeomFDefn->GetType() != 0 /* wkbUnknown */ )
            {
                char szValue[128];

                OGRwkbGeometryType eType = (OGRwkbGeometryType)poGeomFDefn->GetType();

                CPLString osStr(OGRToOGCGeomType(eType));
                if( wkbHasZ(eType) ) osStr += "Z";
                CPLCreateXMLNode( psPDefnNode, CXT_Comment, osStr.c_str() );

                sprintf( szValue, "%d", eType );
                CPLCreateXMLElementAndValue( psPDefnNode, "Type", szValue );
            }
        }
    }
    else if( m_nGeometryPropertyCount == 1 )
    {
        GMLGeometryPropertyDefn* poGeomFDefn = m_papoGeometryProperty[0];
        
        if( strlen(poGeomFDefn->GetName()) > 0 )
            CPLCreateXMLElementAndValue( psRoot, "GeometryName", 
                                         poGeomFDefn->GetName() );

        if( poGeomFDefn->GetSrcElement() != NULL && strlen(poGeomFDefn->GetSrcElement()) > 0 )
            CPLCreateXMLElementAndValue( psRoot, "GeometryElementPath", 
                                         poGeomFDefn->GetSrcElement() );
        
        if( poGeomFDefn->GetType() != 0 /* wkbUnknown */ )
        {
            char szValue[128];

            OGRwkbGeometryType eType = (OGRwkbGeometryType)poGeomFDefn->GetType();

            CPLString osStr(OGRToOGCGeomType(eType));
            if( wkbHasZ(eType) ) osStr += "Z";
            CPLCreateXMLNode( psRoot, CXT_Comment, osStr.c_str() );

            sprintf( szValue, "%d", eType );
            CPLCreateXMLElementAndValue( psRoot, "GeometryType", szValue );
        }
    }
    else
    {
        CPLCreateXMLElementAndValue( psRoot, "GeometryType", "100" );
    }

    const char* pszSRSName = GetSRSName();
    if( pszSRSName )
    {
        CPLCreateXMLElementAndValue( psRoot, "SRSName", pszSRSName );
    }

/* -------------------------------------------------------------------- */
/*      Write out dataset specific information.                         */
/* -------------------------------------------------------------------- */
    CPLXMLNode *psDSI;

    if( m_bHaveExtents || m_nFeatureCount != -1 || m_pszExtraInfo != NULL )
    {
        psDSI = CPLCreateXMLNode( psRoot, CXT_Element, "DatasetSpecificInfo" );

        if( m_nFeatureCount != -1 )
        {
            char szValue[128];

            sprintf( szValue, CPL_FRMT_GIB, m_nFeatureCount );
            CPLCreateXMLElementAndValue( psDSI, "FeatureCount", szValue );
        }

        if( m_bHaveExtents &&
            fabs(m_dfXMin) < 1e100 &&
            fabs(m_dfXMax) < 1e100 &&
            fabs(m_dfYMin) < 1e100 &&
            fabs(m_dfYMax) < 1e100 )
        {
            char szValue[128];

            CPLsnprintf( szValue, sizeof(szValue), "%.5f", m_dfXMin );
            CPLCreateXMLElementAndValue( psDSI, "ExtentXMin", szValue );

            CPLsnprintf( szValue, sizeof(szValue), "%.5f", m_dfXMax );
            CPLCreateXMLElementAndValue( psDSI, "ExtentXMax", szValue );

            CPLsnprintf( szValue, sizeof(szValue), "%.5f", m_dfYMin );
            CPLCreateXMLElementAndValue( psDSI, "ExtentYMin", szValue );

            CPLsnprintf( szValue, sizeof(szValue), "%.5f", m_dfYMax );
            CPLCreateXMLElementAndValue( psDSI, "ExtentYMax", szValue );
        }

        if( m_pszExtraInfo )
            CPLCreateXMLElementAndValue( psDSI, "ExtraInfo", m_pszExtraInfo );
    }
    
/* -------------------------------------------------------------------- */
/*      emit property information.                                      */
/* -------------------------------------------------------------------- */
    for( iProperty = 0; iProperty < GetPropertyCount(); iProperty++ )
    {
        GMLPropertyDefn *poPDefn = GetProperty( iProperty );
        CPLXMLNode *psPDefnNode;
        const char *pszTypeName = "Unknown";

        psPDefnNode = CPLCreateXMLNode( psRoot, CXT_Element, "PropertyDefn" );
        CPLCreateXMLElementAndValue( psPDefnNode, "Name", 
                                     poPDefn->GetName() );
        CPLCreateXMLElementAndValue( psPDefnNode, "ElementPath", 
                                     poPDefn->GetSrcElement() );
        switch( poPDefn->GetType() )
        {
          case GMLPT_Untyped:
            pszTypeName = "Untyped";
            break;
            
          case GMLPT_String:
          case GMLPT_Boolean:
            pszTypeName = "String";
            break;
            
          case GMLPT_Integer:
          case GMLPT_Short:
          case GMLPT_Integer64:
            pszTypeName = "Integer";
            break;
            
          case GMLPT_Real:
          case GMLPT_Float:
            pszTypeName = "Real";
            break;
            
          case GMLPT_Complex:
            pszTypeName = "Complex";
            break;

          case GMLPT_IntegerList:
          case GMLPT_Integer64List:
            pszTypeName = "IntegerList";
            break;

          case GMLPT_RealList:
            pszTypeName = "RealList";
            break;

          case GMLPT_StringList:
          case GMLPT_BooleanList:
            pszTypeName = "StringList";
            break;

          /* should not happen in practise for now because this is not */
          /* autodetected */
          case GMLPT_FeatureProperty:
            pszTypeName = "FeatureProperty";
            break;

          /* should not happen in practise for now because this is not */
          /* autodetected */
          case GMLPT_FeaturePropertyList:
            pszTypeName = "FeaturePropertyList";
            break;
        }
        CPLCreateXMLElementAndValue( psPDefnNode, "Type", pszTypeName );
        if( poPDefn->GetType() == GMLPT_Boolean || poPDefn->GetType() == GMLPT_BooleanList )
            CPLCreateXMLElementAndValue( psPDefnNode, "Subtype", "Boolean" );
        else if( poPDefn->GetType() == GMLPT_Short )
            CPLCreateXMLElementAndValue( psPDefnNode, "Subtype", "Short" );
        else if( poPDefn->GetType() == GMLPT_Float )
            CPLCreateXMLElementAndValue( psPDefnNode, "Subtype", "Float" );
        else if( poPDefn->GetType() == GMLPT_Integer64 ||
                 poPDefn->GetType() == GMLPT_Integer64List )
            CPLCreateXMLElementAndValue( psPDefnNode, "Subtype", "Integer64" );

        if( EQUAL(pszTypeName,"String") )
        {
            char szMaxLength[48];
            sprintf(szMaxLength, "%d", poPDefn->GetWidth());
            CPLCreateXMLElementAndValue ( psPDefnNode, "Width", szMaxLength );
        }
        if( poPDefn->GetWidth() > 0 && EQUAL(pszTypeName,"Integer") )
        {
            char szLength[48];
            sprintf(szLength, "%d", poPDefn->GetWidth());
            CPLCreateXMLElementAndValue ( psPDefnNode, "Width", szLength );
        }
        if( poPDefn->GetWidth() > 0 && EQUAL(pszTypeName,"Real") )
        {
            char szLength[48];
            sprintf(szLength, "%d", poPDefn->GetWidth());
            CPLCreateXMLElementAndValue ( psPDefnNode, "Width", szLength );
            char szPrecision[48];
            sprintf(szPrecision, "%d", poPDefn->GetPrecision());
            CPLCreateXMLElementAndValue ( psPDefnNode, "Precision", szPrecision );
        }
    }

    return psRoot;
}
void
XDMFParser::PrintFile()
{
    int j;
    int indent = 0;

    //
    // Process the next 100000 elements. This is a precaution against
    // getting into an infinite loop. It could just as well be a while
    // true loop.
    //
    for (int i = 0; i < 100000; i++)
    {
        //
        // We are getting the element type at the beginning of the
        // loop so that we can handle the END_TAG now to get the
        // indentation correct.
        //
        ElementType elementType = GetNextElement();
        if (elementType == TYPE_END_TAG) indent--;

        for (int k = 0; k < indent ; k++)
            cerr << " ";

        switch (elementType)
        {
          case TYPE_PI:
            cerr << "Processing Information." << endl;
            break;
          case TYPE_COMMENT:
            cerr << "Comment." << endl;
            break;
          case TYPE_SPECIAL:
            cerr << "Special." << endl;
            break;
          case TYPE_START_TAG:
            indent++;
            cerr << "<" << GetElementName();
            j = 0;
            while (j < 100 && GetNextAttribute())
            {
                cerr << " " << GetAttributeName() << "=\""
                     << GetAttributeValue() << "\"";
                j++;
            }
            cerr << ">" << endl;
            break;
          case TYPE_END_TAG:
            cerr << "</" << GetElementName() << ">" << endl;
            break;
          case TYPE_CDATA:
            if (GetCDataLength() <= 1023)
                cerr << GetCDataValue() << endl;
            else
            {
                FILE *file = fopen(fname, "r");
                fseek(file, GetCDataOffset(), SEEK_SET);
                char *buf = new char[GetCDataLength()+1];
                fread(buf, 1, GetCDataLength(), file);
                buf[GetCDataLength()] = '\0';
                fclose(file);
                cerr << buf << endl;
                delete [] buf;
            }
            break;
          case TYPE_EOF:
            return;
            break;
          case TYPE_ERROR:
            cerr << "Error." << endl;
            break;
        }
    }
}