1LaTeXML::Core::KeyVals(U3s)er Contributed Perl DocumentatLiaoTneXML::Core::KeyVals(3)
2
3
4
6 "LaTeXML::Core::KeyVals" - Key-Value Pairs in LaTeXML
7
9 Provides a parser and representation of keyval pairs
10 "LaTeXML::Core::KeyVals" represents parameters handled by LaTeX's
11 keyval package. It extends LaTeXML::Common::Object.
12
13 Accessors
14 "GetKeyVal($arg,$key)"
15 Access the value associated with a given key. This is useful
16 within constructors to access the value associated with $key in the
17 argument $arg. Example usage in a copnstructor:
18
19 <foo attrib='&GetKeyVal(#1,'key')'>
20
21 "GetKeyVals($arg)"
22 Access the entire hash. Can be used in a constructor like: Can use
23 in constructor: <foo %&GetKeyVals(#1)/>
24
25 Constructors
26 "<LaTeXML::Core::KeyVals-"new(prefix, keysets, options)); >>
27 Creates a new KeyVals object with the given parameters. All
28 arguments are optional and the simples way of calling this method
29 is "my $keyvals = LaTeXML::Core::KeyVals->new()".
30
31 prefix is the given prefix all key-value pairs operate in and
32 defaults to 'KV'. If given, prefix should be a string.
33
34 keysets should be a list of keysets to find keys inside of. If
35 given, it should either be reference to a list of strings or a
36 comma-seperated string. This argument defaults to '_anonymous_'.
37
38 Furthermore, the KeyVals constructor accepts a variety of options
39 that can be used to customize its behaviour. These are setAll,
40 setInternals, skip, skipMissing, hookMissing, open, close.
41
42 setAll is a flag that, if set, ensures that keys will be set in all
43 existing keysets, instad of only in the first one.
44
45 setInternals is a flag that, if set, ensures that certain 'xkeyval'
46 package internals are set during key digestion.
47
48 skip should be a list of keys to be skipped when digesting the keys
49 of this object.
50
51 skipMissing allows one way of handling keys during key digestion
52 that have not been explictilty declared using "DefKey" or related
53 functionality. If set to "undef" or 0, an error is thrown upon
54 trying to set such a key, if set to 1 they are ignored.
55 Alternatively, this can be set to a key macro which is then
56 extended to contain a comman-separated list of the undefined keys.
57
58 hookMissing allows to call a specific macro if a single key is
59 unknown during key digestion.
60
61 KeyVals Accessors (intended for internal usage)
62 "$keyvals->setTuples(@tuples)"
63 Sets the tuples which should be a list of five-tuples (array
64 references) representing the key-value pairs this KeyVals object is
65 seeded with. See the getTuples function on details of the structure
66 of this list. rebuild is called automatically to populate the
67 other caches. Typically, the tuples is set by readFrom.
68
69 Resolution to KeySets
70 "my @keysets = $keyvals->resolveKeyValFor($key)"
71 Finds all keysets that should be used for interacting with the
72 given key. May return "undef" if no matching keysets are found. Use
73 the parameters
74 keysets, setAll and skipMissing to customize the exact behaviour
75 of this function.
76
77 "my $canResolveKeyVal = $keyvals->canResolveKeyValFor($key)"
78 Checks if this KeyVals object can resolve a KeyVal for key. Ignores
79 setAll and skipMissing parameters.
80
81 "my $keyval = $keyvals->getPrimaryKeyValOf($key, @keysets)"
82 Gets the primary keyset to be used for interacting a a single key,
83 given that it resolves to keysets. Defaults to first keyset in
84 KeyVals, if none given.
85
86 Changing contained values
87 "$keyvals->addValue($key, $value, $useDefault, $noRebuild)"
88 Adds the given value for key at the end of the given list of values
89 and rebuilds all internal caches. If the useDefault flag is set,
90 the specific value is ignored, and the default is set instead.
91
92 If this function is called multiple times the noRebuild option
93 should be given to prevent constant rebuilding and the rebuild
94 function should be called manually called.
95
96 "$keyvals->setValue($key, $value, $useDefault)"
97 Sets the value of key to value, optionally using the default if
98 useDefault is set. Note that if value is a reference to an array,
99 the key is inserted multiple times. If value is "undef", the values
100 is deleted.
101
102 "$keyvals->rebuild($skip)"
103 Rebuilds the internal caches of key-value mapping and list of pairs
104 from from main list of tuples. If skip is given, all values for the
105 given key are omitted, and the given key is deleted.
106
107 Parsing values from a gullet
108 "$keyvals->readFrom($gullet, $until, %options)"
109 Reads a set of KeyVals from gullet, up until the until token, and
110 updates the state of this KeyVals object accordingly.
111
112 Furthermore, this methods supports several options.
113
114 When the silenceMissing option is set, missing keys will be
115 completely ignored when reading keys, that is they do not get
116 recorded into the KeyVals object and no warnings or errors will be
117 thrown.
118
119 "$keyvals->readKeyWordFrom($gullet, $until)"
120 Reads a single keyword from gullet. Intended for internal use only.
121
122 KeyVals Accessors
123 "my $value = $keyvals->getValue($key);"
124 Return a value associated with $key.
125
126 "@values = $keyvals->getValues($key);"
127 Return the list of all values associated with $key.
128
129 "%keyvals = $keyvals->getKeyVals;"
130 Return the hash reference containing the keys and values bound in
131 the $keyval. Each value in the hash may be a single value or a
132 list if the key is repeated.
133
134 "@keyvals = $keyvals->getPairs;"
135 Return the alternating keys and values bound in the $keyval. Note
136 that this may contain multiple entries for a given key, if they
137 were repeated.
138
139 "%hash = $keyvals->getHash;"
140 Return the hash reference containing the keys and values bound in
141 the $keyval. Note that will only contain the last value for a
142 given key, if they were repeated.
143
144 "$haskey = $keyvals->hasKey($key);"
145 Checks if the KeyVals object contains a value for $key.
146
147 Value Related Reversion
148 "$expansion = $keyvals->setKeysExpansion;"
149 Expand this KeyVals into a set of tokens for digesting keys.
150
151 "$keyvals = $keyvals->beDigested($stomach);"
152 Return a new "LaTeXML::Core::KeyVals" object with both keys and
153 values digested.
154
155 "$reversion = $keyvals->revert();"
156 Revert this object into a set of tokens representing the original
157 sequence of Tokens that was used to be read it from the gullet.
158
159 "$str = $keyvals->toString();"
160 Turns this object into a key=value comma seperated string.
161
163 Bruce Miller <bruce.miller@nist.gov> Tom Wiesing
164 <tom.wiesing@gmail.com>
165
167 Public domain software, produced as part of work done by the United
168 States Government & not subject to copyright in the US.
169
170
171
172perl v5.34.0 2021-11-24 LaTeXML::Core::KeyVals(3)