Class: Cabriolet::HLP::QuickHelp::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/hlp/quickhelp/parser.rb

Overview

Parser for QuickHelp (.HLP) files

Parses the QuickHelp binary format as specified in the DosHelp project. Structure:

  • Signature (2 bytes)

  • File Header (68 bytes)

  • Topic Index (variable)

  • Context Strings (variable)

  • Context Map (variable)

  • Keywords (optional)

  • Huffman Tree (optional)

  • Topic Texts (compressed)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io_system = nil) ⇒ Parser

Initialize parser

Parameters:

  • io_system (System::IOSystem, nil) (defaults to: nil)

    Custom I/O system or nil for default



27
28
29
# File 'lib/cabriolet/hlp/quickhelp/parser.rb', line 27

def initialize(io_system = nil)
  @io_system = io_system || System::IOSystem.new
end

Instance Attribute Details

#io_systemObject (readonly)

Returns the value of attribute io_system.



22
23
24
# File 'lib/cabriolet/hlp/quickhelp/parser.rb', line 22

def io_system
  @io_system
end

Instance Method Details

#parse(filename) ⇒ Models::HLPHeader

Parse a QuickHelp file

Parameters:

  • filename (String)

    Path to HLP file

Returns:

Raises:



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cabriolet/hlp/quickhelp/parser.rb', line 36

def parse(filename)
  handle = @io_system.open(filename, Constants::MODE_READ)

  begin
    header = parse_file(handle)
    header.filename = filename
    header
  ensure
    @io_system.close(handle)
  end
end