aboutsummaryrefslogtreecommitdiff
path: root/examples/addressbook/reader.nim
blob: aa0fd86837cc1cb9e2c772ec3b8147233fb3ecb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import streams
import strformat

import protobuf/protobuf

import addressbook_pb
import phonenumber_pb

let pbsi = newProtobufStream(newFileStream("addressbook.dat"))

let addressBook = readAddressBook(pbsi)

for person in addressBook.people:
    echo("---")
    echo(&"Id: {person.id}")
    echo(&"Name: {person.name}")
    echo(&"Email: {person.email}")
    echo("Phones:")
    for phone in person.phones:
        echo(&"  {phone.ftype} {phone.number}")