Formerly ianmackenzie/elm-step-file. Search finds this package by either name.
Represents an entire STEP file composed of a header and a list of entities. You can get the header from a file or extract data from it using entity decoders.
Attempt to find exactly one entity in a file that matches the given decoder. If there are no matching entities or more than one matching entity, an error message will be returned.
Find all entities in a file matching the given decoder.
Decode a single entity from a file by ID, using the given decoder. Usually
you will want to use single instead.
The simpleEntity* functions all attempt to decode a simple STEP entity with
the given number of attributes.
The complexEntity* functions all attempt to decode a complex STEP entity with
the given number of sub-entities.
The subEntity* functions all attempt to decode a sub-entity (of a complex STEP
entity) with the given number of attributes.
Construct an entity decoder that tries several other entity decoders in sequence.
Keep a particular attribute value to pass to the callback function for the entity being decoded.
Ignore a particular attribute so that it does not get passed to the callback function for the entity being decoded.
Decode a single attribute as a Bool (from the special STEP enum values
.T. and .F.).
Decode a single attribute as a Float. Note that unlike JSON, STEP has
different encodings for Int and Float values so you cannot use this
function to decode integer values; if you want to decode an integer value as a
Float you will need to use
Decode.map toFloat Decode.intDecode a single attribute as a string which must be empty (whitespace only).
Useful when used with ignore to check that the string being ignored
is in fact empty.
Decode a single attribute as a blob of binary data, using the given binary decoder.
Decode the special 'derived value' attribute (*) as the given value.
Decode an attribute that may be null, returning Nothing if it is.
Decode a single enum attribute, by passing a list of enum cases as their
STEP type name and corresponding Elm value. For example, given a STEP enum with
values RED, YELLOW and GREEN you might write:
type LightColor
= Red
| Yellow
| Green
lightColorDecoder : Decoder Attribute LightColor
lightColorDecoder =
Decode.enum
[ ( "RED", Red )
, ( "YELLOW", Yellow )
, ( "GREEN", Green )
](Note that the given strings will be normalized, so case does not matter.)
Decode an attribute as a list, passing the decoder to be used for each list item.
Decode a list of exactly two elements, passing the decoder to be used for the two elements.
Decode a list of exactly three elements, passing the decoder to be used for the two elements.
Decode an attribute which is a reference to another entity, by providing the decoder to use for that entity.
Decode just the ID from an entity reference attribute. This may be useful for deferred decoding/processing.
Decode an attribute which is a reference to another entity, and additionally
get the ID of that entity. You will need to pass a function that combines the
ID and decoded value into whatever you want; for example if you pass
Tuple.pair then you will get an ( Int, a ) value back.
Decode a 'typed attribute'; for example if someone's age was stored as an
integer, then it might be encoded directly as an integer like 38 or as a typed
integer like AGE(38) or YEARS(38) or similar.
Post-process the result of a decoder, either succeeding with a new value
(possibly of a different type) or failing with an error message. This is a
restricted form of andThen that does not have the same performance concerns,
so use validate instead of andThen wherever possible.
If a decoder produces a Result String a instead of simply a value of type
a (for example if the callback function can fail) then this can 'resolve' that
back into a regular decoder. It is equivalent to (and implemented as)
validate identity.
Based on the result of one entity decoder, produce a second decoder to run on the same entity.
WARNING: This is sometimes necessary but can be a major performance issue!
Wherever possible, ensure decoders are created once instead of on the fly
inside an andThen callback. For example, in some cases you may be able to
create a few static decoders and then have logic inside and andThen simply
choose which of those to use.
A trivial decoder that always succeeds with the given value. May be useful
in combination with andThen, but consider using validate instead.
A trivial decoder that always failes with the given error message. May be
useful in combination with andThen, but consider using validate instead.
Define a decoder lazily such that it is only constructed if needed. This is primarily used to break circular reference chains between decoders.
For efficiency reasons, you should make sure that the provided callback function simply returns an already-existing decoder value; it should not construct one on the fly.
A
Decoderdescribes how to attempt to decode some input of typei(an entity or an attribute) and produce some output of typea.