Class: Cabriolet::Models::HLPHeader
- Inherits:
-
Object
- Object
- Cabriolet::Models::HLPHeader
- Defined in:
- lib/cabriolet/models/hlp_header.rb
Overview
QuickHelp database header model
Represents the metadata of a QuickHelp help database (.HLP file). HLP files contain topics, context strings, and optional compression (keyword dictionary and Huffman coding).
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#context_count ⇒ Object
Returns the value of attribute context_count.
-
#context_map ⇒ Object
Topics and context data.
-
#context_map_offset ⇒ Object
Returns the value of attribute context_map_offset.
-
#context_strings_offset ⇒ Object
Returns the value of attribute context_strings_offset.
-
#contexts ⇒ Object
Topics and context data.
-
#control_character ⇒ Object
Returns the value of attribute control_character.
-
#database_name ⇒ Object
Returns the value of attribute database_name.
-
#database_size ⇒ Object
Returns the value of attribute database_size.
-
#display_width ⇒ Object
Returns the value of attribute display_width.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#huffman_tree ⇒ Object
Returns the value of attribute huffman_tree.
-
#huffman_tree_offset ⇒ Object
Returns the value of attribute huffman_tree_offset.
-
#keywords ⇒ Object
Returns the value of attribute keywords.
-
#keywords_offset ⇒ Object
Returns the value of attribute keywords_offset.
-
#magic ⇒ Object
Returns the value of attribute magic.
-
#predefined_ctx_count ⇒ Object
Returns the value of attribute predefined_ctx_count.
-
#topic_count ⇒ Object
Returns the value of attribute topic_count.
-
#topic_index_offset ⇒ Object
Returns the value of attribute topic_index_offset.
-
#topic_text_offset ⇒ Object
Returns the value of attribute topic_text_offset.
-
#topics ⇒ Object
Topics and context data.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#case_sensitive? ⇒ Boolean
Check if case-sensitive context strings.
-
#control_char ⇒ String
Get control character as string.
-
#db_name ⇒ String
Get database name without null padding.
-
#has_huffman? ⇒ Boolean
Check if Huffman compression is used.
-
#has_keywords? ⇒ Boolean
Check if keyword compression is used.
-
#initialize(magic: nil, version: 2, attributes: 0, control_character: 0x3A, topic_count: 0, context_count: 0, display_width: 80, predefined_ctx_count: 0, database_name: "", topic_index_offset: 0, context_strings_offset: 0, context_map_offset: 0, keywords_offset: 0, huffman_tree_offset: 0, topic_text_offset: 0, database_size: 0, filename: nil) ⇒ HLPHeader
constructor
Initialize QuickHelp database header.
-
#locked? ⇒ Boolean
Check if database is locked (cannot be decoded by HELPMAKE).
-
#valid? ⇒ Boolean
Check if header is valid.
Constructor Details
#initialize(magic: nil, version: 2, attributes: 0, control_character: 0x3A, topic_count: 0, context_count: 0, display_width: 80, predefined_ctx_count: 0, database_name: "", topic_index_offset: 0, context_strings_offset: 0, context_map_offset: 0, keywords_offset: 0, huffman_tree_offset: 0, topic_text_offset: 0, database_size: 0, filename: nil) ⇒ HLPHeader
Initialize QuickHelp database header
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cabriolet/models/hlp_header.rb', line 27 def initialize( magic: nil, version: 2, attributes: 0, control_character: 0x3A, topic_count: 0, context_count: 0, display_width: 80, predefined_ctx_count: 0, database_name: "", topic_index_offset: 0, context_strings_offset: 0, context_map_offset: 0, keywords_offset: 0, huffman_tree_offset: 0, topic_text_offset: 0, database_size: 0, filename: nil ) @magic = magic || Binary::HLPStructures::SIGNATURE @version = version @attributes = attributes @control_character = control_character @topic_count = topic_count @context_count = context_count @display_width = display_width @predefined_ctx_count = predefined_ctx_count @database_name = database_name @topic_index_offset = topic_index_offset @context_strings_offset = context_strings_offset @context_map_offset = context_map_offset @keywords_offset = keywords_offset @huffman_tree_offset = huffman_tree_offset @topic_text_offset = topic_text_offset @database_size = database_size @filename = filename # Collections @topics = [] @contexts = [] @context_map = [] @keywords = [] @huffman_tree = nil end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def attributes @attributes end |
#context_count ⇒ Object
Returns the value of attribute context_count.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def context_count @context_count end |
#context_map ⇒ Object
Topics and context data
15 16 17 |
# File 'lib/cabriolet/models/hlp_header.rb', line 15 def context_map @context_map end |
#context_map_offset ⇒ Object
Returns the value of attribute context_map_offset.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def context_map_offset @context_map_offset end |
#context_strings_offset ⇒ Object
Returns the value of attribute context_strings_offset.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def context_strings_offset @context_strings_offset end |
#contexts ⇒ Object
Topics and context data
15 16 17 |
# File 'lib/cabriolet/models/hlp_header.rb', line 15 def contexts @contexts end |
#control_character ⇒ Object
Returns the value of attribute control_character.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def control_character @control_character end |
#database_name ⇒ Object
Returns the value of attribute database_name.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def database_name @database_name end |
#database_size ⇒ Object
Returns the value of attribute database_size.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def database_size @database_size end |
#display_width ⇒ Object
Returns the value of attribute display_width.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def display_width @display_width end |
#filename ⇒ Object
Returns the value of attribute filename.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def filename @filename end |
#huffman_tree ⇒ Object
Returns the value of attribute huffman_tree.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def huffman_tree @huffman_tree end |
#huffman_tree_offset ⇒ Object
Returns the value of attribute huffman_tree_offset.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def huffman_tree_offset @huffman_tree_offset end |
#keywords ⇒ Object
Returns the value of attribute keywords.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def keywords @keywords end |
#keywords_offset ⇒ Object
Returns the value of attribute keywords_offset.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def keywords_offset @keywords_offset end |
#magic ⇒ Object
Returns the value of attribute magic.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def magic @magic end |
#predefined_ctx_count ⇒ Object
Returns the value of attribute predefined_ctx_count.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def predefined_ctx_count @predefined_ctx_count end |
#topic_count ⇒ Object
Returns the value of attribute topic_count.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def topic_count @topic_count end |
#topic_index_offset ⇒ Object
Returns the value of attribute topic_index_offset.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def topic_index_offset @topic_index_offset end |
#topic_text_offset ⇒ Object
Returns the value of attribute topic_text_offset.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def topic_text_offset @topic_text_offset end |
#topics ⇒ Object
Topics and context data
15 16 17 |
# File 'lib/cabriolet/models/hlp_header.rb', line 15 def topics @topics end |
#version ⇒ Object
Returns the value of attribute version.
11 12 13 |
# File 'lib/cabriolet/models/hlp_header.rb', line 11 def version @version end |
Instance Method Details
#case_sensitive? ⇒ Boolean
Check if case-sensitive context strings
85 86 87 |
# File 'lib/cabriolet/models/hlp_header.rb', line 85 def case_sensitive? @attributes.anybits?(Binary::HLPStructures::Attributes::CASE_SENSITIVE) end |
#control_char ⇒ String
Get control character as string
113 114 115 |
# File 'lib/cabriolet/models/hlp_header.rb', line 113 def control_char @control_character.chr(Encoding::ASCII) end |
#db_name ⇒ String
Get database name without null padding
120 121 122 |
# File 'lib/cabriolet/models/hlp_header.rb', line 120 def db_name @database_name.split("\x00").first || "" end |
#has_huffman? ⇒ Boolean
Check if Huffman compression is used
106 107 108 |
# File 'lib/cabriolet/models/hlp_header.rb', line 106 def has_huffman? @huffman_tree_offset.positive? && !@huffman_tree.nil? end |
#has_keywords? ⇒ Boolean
Check if keyword compression is used
99 100 101 |
# File 'lib/cabriolet/models/hlp_header.rb', line 99 def has_keywords? @keywords_offset.positive? && !@keywords.empty? end |
#locked? ⇒ Boolean
Check if database is locked (cannot be decoded by HELPMAKE)
92 93 94 |
# File 'lib/cabriolet/models/hlp_header.rb', line 92 def locked? @attributes.anybits?(Binary::HLPStructures::Attributes::LOCKED) end |
#valid? ⇒ Boolean
Check if header is valid
75 76 77 78 79 80 |
# File 'lib/cabriolet/models/hlp_header.rb', line 75 def valid? @magic == Binary::HLPStructures::SIGNATURE && @version == 2 && @topic_count >= 0 && @context_count >= 0 end |