fixed-length
![license](https://camo.githubusercontent.com/635b4e47238e86a5fa9b5d9bb8291a31228f80863836d0359fcfe7f01236df40/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e7376673f7374796c653d666c6174)
A simple Scala library for parsing fixed-length format.
A graceful playground for Shapeless and Cats libraries.
Installation
You can find the fixed-length
library on Maven Central
Add the library to your dependencies:
libraryDependencies += "com.github.atais" %% "fixed-length" % "0.3"
Library is cross-compiled for Scala 2.10
, 2.11
and 2.12
.
Examples
Please find example test scenarios describing simple use cases:
Usage
Describe your class with an Encoder
, Decoder
or Codec
typeclass and Parse
away!
Parameters
start: Int
A fixed position in line, where the field begins
end: Int
A fixed position in line, where the field ends
align: Alignment
(default value is Alignment.Left
)
Alignment of the field's value in the given area of size end - start
Available options:
Alignment.Left
Alignment.Right
padding: Char
(default value is ' '
)
Fills the remaining space in the given area with the padding Char.
Warning! Wrong selection of padding char may cause decoding issues!
defaultValue: A (Decoder only)
(default value is null
)
The default value of a field, which will be used in case of any decoding error.
Warning! This will surpress any decoding errors!