using System; using System.IO; namespace HtmlHelp.ChmDecoding { /// /// The class UrlTableEntry stores data for an URL-Table entry /// internal sealed class UrlTableEntry { /// /// Internal member storing the offset of this entry /// private int _entryOffset = 0; /// /// Internal member storing a unique id /// private uint _uniqueID = 0; /// /// Internal member storing the topics index /// private int _topicsIndex = 0; /// /// Internal member storing the offset in the urlstr table /// private int _urlStrOffset = 0; /// /// Internal member storing the associated chmfile object /// private CHMFile _associatedFile = null; /// /// Constructor of the class /// /// unique id /// offset of the entry /// topic index /// urlstr offset for filename public UrlTableEntry(uint uniqueID, int entryOffset, int topicIndex, int urlstrOffset) : this(uniqueID, entryOffset, topicIndex, urlstrOffset, null) { } /// /// Constructor of the class /// /// unique id /// offset of the entry /// topic index /// urlstr offset for filename /// associated chm file internal UrlTableEntry(uint uniqueID, int entryOffset, int topicIndex, int urlstrOffset, CHMFile associatedFile) { _uniqueID = uniqueID; _entryOffset = entryOffset; _topicsIndex = topicIndex; _urlStrOffset = urlstrOffset; _associatedFile = associatedFile; } /// /// Standard constructor /// internal UrlTableEntry() { } #region Data dumping /// /// Dump the class data to a binary writer /// /// writer to write the data internal void Dump(ref BinaryWriter writer) { writer.Write( _urlStrOffset ); writer.Write( _entryOffset ); writer.Write( _topicsIndex ); writer.Write( _urlStrOffset ); } /// /// Reads the object data from a dump store /// /// reader to read the data internal void ReadDump(ref BinaryReader reader) { _urlStrOffset = reader.ReadInt32(); _entryOffset = reader.ReadInt32(); _topicsIndex = reader.ReadInt32(); _urlStrOffset = reader.ReadInt32(); } /// /// Sets the associated CHMFile instance /// /// instance to set internal void SetCHMFile(CHMFile associatedFile) { _associatedFile = associatedFile; } #endregion /// /// Gets the unique id of the entry /// internal uint UniqueID { get {return _uniqueID; } } /// /// Gets the offset of the entry /// internal int EntryOffset { get {return _entryOffset; } } /// /// Gets the topics index /// internal int TopicIndex { get {return _topicsIndex; } } /// /// Gets the urlstr offset /// internal int UrlstrOffset { get { return _urlStrOffset; } } /// /// Gets the url of the entry /// public string URL { get { if(_associatedFile == null) return String.Empty; if(_associatedFile.UrlstrFile == null) return String.Empty; string sTemp = (string)_associatedFile.UrlstrFile.GetURLatOffset( _urlStrOffset ); if( sTemp == null) return String.Empty; return sTemp; } } /// /// Gets the associated topic for this url entry /// internal TopicEntry Topic { get { if(_associatedFile == null) return null; if(_associatedFile.TopicsFile == null) return null; TopicEntry tentry = _associatedFile.TopicsFile[ _topicsIndex*16 ]; return tentry; } } } }