using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SCJMapper_V2.CryXMLlib
{
///
/// Derived work from CryEngine: IXml.h:
///
/// Crytek Engine Source File.
/// Copyright (C), Crytek Studios, 2002.
/// -------------------------------------------------------------------------
/// File name: ixml.h
/// Version: v1.00
/// Created: 16/7/2002 by Timur.
/// Compilers: Visual Studio.NET
/// Description:
// -------------------------------------------------------------------------
///
///
/// kind of typedef (curtesy http://www.codeproject.com/Questions/141385/typedef-in-C)
// Summary:
// Special string wrapper for xml nodes.
///
public struct XmlString
{
// A struct's fields should not be exposed
private string value;
// As we are using implicit conversions we can keep the constructor private
private XmlString( string value )
{
this.value = value;
}
///
/// Implicitly converts a XmlString to a .
///
/// The to convert.
/// A new XmlString with the specified value.
public static implicit operator XmlString( string value )
{
return new XmlString( value );
}
///
/// Implicitly converts a XmlString to a .
///
/// The XmlString to convert.
///
/// A that is the specified XmlString's value.
///
public static implicit operator string( XmlString record )
{
return record.value;
}
public static XmlString c_str( byte[] sz, uint len = 999 )
{
return Conversions.ToString( sz, len );
}
}
///
/// Abstract IXmlNode class
/// Notes:
/// Never use IXmlNode directly instead use reference counted XmlNodeRef.
/// See also:
/// XmlNodeRef
///
public abstract class IXmlNode
{
///
/// Gets XML node tag.
///
///
public abstract string getTag( );
///
/// Returns true if a given tag equal to node tag.
///
/// The tag
/// True if it is the tag of the node
public abstract bool isTag( string tag );
///
/// Checks if attributes with specified key exist.
///
/// The attribute key
/// True if this attribute exists
public abstract bool haveAttr( string key );
//
///
/// Gets XML Node attributes count
///
/// The number of attributes of this node
public abstract int getNumAttributes( );
///
/// Returns attribute key and value by attribute index.
///
/// The attribute index 0..
/// Out: the attribute key
/// Out: the attribute value
/// True if returned key and value are valid
public abstract bool getAttributeByIndex( int index, out string key, out string value );
///
/// Gets XML Node attribute for specified key.
///
/// The attribute key
/// The attribute value or an empty string if it does not exist
public abstract string getAttr( string key );
///
/// Gets XML Node attribute for specified key.
///
/// The attribute key
/// Out: the attribute value
/// True if the attribute with key exists and the returned value is valid
public abstract bool getAttr( string key, out string value );
///
/// Gets attribute value of node.
///
/// The attribute key
/// Out: the attribute value as XmlString
/// True if the attribute with key exists and the returned value is valid
public abstract bool getAttr( string key, out XmlString value );
///
/// Gets number of child XML nodes.
///
/// The number of child nodes of this node
public abstract int getChildCount( );
///
/// Gets XML Node child nodes.
///
/// The child index of the node to return
/// A valid nodeRef or null if the element does not exist
public abstract CryXmlNodeRef getChild( int i );
///
/// Finds node with specified tag.
///
/// The node tag of the child node to return
/// A valid nodeRef or null if the element does not exist
public abstract CryXmlNodeRef findChild( string tag );
///
/// Gets parent XML node.
///
/// A valid nodeRef or null if the element does not exist
public abstract CryXmlNodeRef getParent( );
///
/// Returns content of this node.
///
/// The node content as string
public abstract string getContent( );
}
}