aboutsummaryrefslogtreecommitdiff
path: root/yamlesque/src/main/scala/yamlValues.scala
blob: 4432b9dd2744ffacb902f6a6a3a16429f22c8840 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package yamlesque

sealed trait YamlValue {
  def print: String = YamlValue.DefaultPrinter(this)
  def convertTo[A: YamlReader]: A = implicitly[YamlReader[A]].read(this)
}
object YamlValue {
  val DefaultPrinter = new YamlPrinter(compact = true)
}

case class YamlMapping(fields: Map[String, YamlValue]) extends YamlValue
object YamlMapping {
  def apply(items: (String, YamlValue)*) = new YamlMapping(Map(items: _*))
}

case class YamlSequence(items: Vector[YamlValue]) extends YamlValue
object YamlSequence {
  def apply(items: YamlValue*) = new YamlSequence(items.toVector)
}

case class YamlScalar(value: String) extends YamlValue

case object YamlEmpty extends YamlValue