LaTeXML::Core::KeyVals(3)

NAME
"LaTeXML::Core::KeyVals" - Key-Value Pairs in LaTeXML

DESCRIPTION
Provides a parser and representation of keyval pairs "LaTeXML::Core::KeyVals" represents parameters handled by LaTeX's keyval package. It extends LaTeXML::Common::Object.

  Accessors

"GetKeyVal($arg,$key)"
    Access the value associated with a given key. This is useful within constructors to access the value associated with $key in the argument $arg. Example usage in a copnstructor:

    <foo attrib='&GetKeyVal(#1,'key')'>

"GetKeyVals($arg)"
    Access the entire hash. Can be used in a constructor like: Can use in constructor: <foo %&GetKeyVals(#1)/>

  Constructors

"<LaTeXML::Core::KeyVals-"new(prefix, keysets, options)); >>
    Creates a new KeyVals object with the given parameters. All arguments are optional and the simples way of calling this method is "my $keyvals = LaTeXML::Core::KeyVals->new()".

    prefix is the given prefix all key-value pairs operate in and defaults to 'KV'. If given, prefix should be a string.

    keysets should be a list of keysets to find keys inside of. If given, it should either be reference to a list of strings or a comma-seperated string. This argument defaults to '_anonymous_'.

    Furthermore, the KeyVals constructor accepts a variety of options that can be used to customize its behaviour. These are setAll, setInternals, skip, skipMissing, hookMissing, open, close.

    setAll is a flag that, if set, ensures that keys will be set in all existing keysets, instad of only in the first one.

    setInternals is a flag that, if set, ensures that certain 'xkeyval' package internals are set during key digestion.

    skip should be a list of keys to be skipped when digesting the keys of this object.

    skipMissing allows one way of handling keys during key digestion that have not been explictilty declared using "DefKey" or related functionality. If set to "undef" or 0, an error is thrown upon trying to set such a key, if set to 1 they are ignored. Alternatively, this can be set to a key macro which is then extended to contain a comman-separated list of the undefined keys.

    hookMissing allows to call a specific macro if a single key is unknown during key digestion.

  KeyVals Accessors (intended for internal usage)

"$keyvals->setTuples(@tuples)"
    Sets the tuples which should be a list of five-tuples (array references) representing the key-value pairs this KeyVals object is seeded with. See the getTuples function on details of the structure of this list. rebuild is called automatically to populate the other caches. Typically, the tuples is set by readFrom.

  Resolution to KeySets

"my @keysets = $keyvals->resolveKeyValFor($key)"
    Finds all keysets that should be used for interacting with the given key. May return "undef" if no matching keysets are found. Use the parameters
     keysets, setAll and skipMissing to customize the exact behaviour of this function.

"my $canResolveKeyVal = $keyvals->canResolveKeyValFor($key)"
    Checks if this KeyVals object can resolve a KeyVal for key. Ignores setAll and skipMissing parameters.

"my $keyval = $keyvals->getPrimaryKeyValOf($key, @keysets)"
    Gets the primary keyset to be used for interacting a a single key, given that it resolves to keysets. Defaults to first keyset in KeyVals, if none given.

  Changing contained values

"$keyvals->addValue($key, $value, $useDefault, $noRebuild)"
    Adds the given value for key at the end of the given list of values and rebuilds all internal caches. If the useDefault flag is set, the specific value is ignored, and the default is set instead.

    If this function is called multiple times the noRebuild option should be given to prevent constant rebuilding and the rebuild function should be called manually called.

"$keyvals->setValue($key, $value, $useDefault)"
    Sets the value of key to value, optionally using the default if useDefault is set. Note that if value is a reference to an array, the key is inserted multiple times. If value is "undef", the values is deleted.

"$keyvals->rebuild($skip)"
    Rebuilds the internal caches of key-value mapping and list of pairs from from main list of tuples. If skip is given, all values for the given key are omitted, and the given key is deleted.

  Parsing values from a gullet

"$keyvals->readFrom($gullet, $until, %options)"
    Reads a set of KeyVals from gullet, up until the until token, and updates the state of this KeyVals object accordingly.

    Furthermore, this methods supports several options.

    When the silenceMissing option is set, missing keys will be completely ignored when reading keys, that is they do not get recorded into the KeyVals object and no warnings or errors will be thrown.

"$keyvals->readKeyWordFrom($gullet, $until)"
    Reads a single keyword from gullet. Intended for internal use only.

  KeyVals Accessors

"my $value = $keyvals->getValue($key);"
    Return a value associated with $key.

"@values = $keyvals->getValues($key);"
    Return the list of all values associated with $key.

"%keyvals = $keyvals->getKeyVals;"
    Return the hash reference containing the keys and values bound in the $keyval. Each value in the hash may be a single value or a list if the key is repeated.

"@keyvals = $keyvals->getPairs;"
    Return the alternating keys and values bound in the $keyval. Note that this may contain multiple entries for a given key, if they were repeated.

"%hash = $keyvals->getHash;"
    Return the hash reference containing the keys and values bound in the $keyval. Note that will only contain the last value for a given key, if they were repeated.

"$haskey = $keyvals->hasKey($key);"
    Checks if the KeyVals object contains a value for $key.

  Value Related Reversion

"$expansion = $keyvals->setKeysExpansion;"
    Expand this KeyVals into a set of tokens for digesting keys.

"$keyvals = $keyvals->beDigested($stomach);"
    Return a new "LaTeXML::Core::KeyVals" object with both keys and values digested.

"$reversion = $keyvals->revert();"
    Revert this object into a set of tokens representing the original sequence of Tokens that was used to be read it from the gullet.

"$str = $keyvals->toString();"
    Turns this object into a key=value comma seperated string.

AUTHOR
Bruce Miller <bruce.miller@nist.gov> Tom Wiesing <tom.wiesing@gmail.com>

COPYRIGHT
Public domain software, produced as part of work done by the United States Government & not subject to copyright in the US.