{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings #-} {-# OPTIONS_GHC -w #-} module GTFS.Realtime.VehiclePosition.CarriageDetails (CarriageDetails(..)) where import Prelude ((+), (/), (++), (.), (==), (<=), (&&)) import qualified Prelude as Prelude' import qualified Data.List as Prelude' import qualified Data.Typeable as Prelude' import qualified GHC.Generics as Prelude' import qualified Data.Data as Prelude' import qualified Text.ProtocolBuffers.Header as P' import qualified GTFS.Realtime.VehiclePosition.OccupancyStatus as GTFS.Realtime.VehiclePosition data CarriageDetails = CarriageDetails{id :: !(P'.Maybe P'.Utf8), label :: !(P'.Maybe P'.Utf8), occupancy_status :: !(P'.Maybe GTFS.Realtime.VehiclePosition.OccupancyStatus), occupancy_percentage :: !(P'.Maybe P'.Int32), carriage_sequence :: !(P'.Maybe P'.Word32), ext'field :: !(P'.ExtField)} deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) instance P'.ExtendMessage CarriageDetails where getExtField = ext'field putExtField e'f msg = msg{ext'field = e'f} validExtRanges msg = P'.extRanges (P'.reflectDescriptorInfo msg) instance P'.Mergeable CarriageDetails where mergeAppend (CarriageDetails x'1 x'2 x'3 x'4 x'5 x'6) (CarriageDetails y'1 y'2 y'3 y'4 y'5 y'6) = let !z'1 = P'.mergeAppend x'1 y'1 !z'2 = P'.mergeAppend x'2 y'2 !z'3 = P'.mergeAppend x'3 y'3 !z'4 = P'.mergeAppend x'4 y'4 !z'5 = P'.mergeAppend x'5 y'5 !z'6 = P'.mergeAppend x'6 y'6 in CarriageDetails z'1 z'2 z'3 z'4 z'5 z'6 instance P'.Default CarriageDetails where defaultValue = CarriageDetails P'.defaultValue P'.defaultValue (Prelude'.Just (Prelude'.read "NO_DATA_AVAILABLE")) (Prelude'.Just (-1)) P'.defaultValue P'.defaultValue instance P'.Wire CarriageDetails where wireSize ft' self'@(CarriageDetails x'1 x'2 x'3 x'4 x'5 x'6) = case ft' of 10 -> calc'Size 11 -> P'.prependMessageSize calc'Size _ -> P'.wireSizeErr ft' self' where calc'Size = (P'.wireSizeOpt 1 9 x'1 + P'.wireSizeOpt 1 9 x'2 + P'.wireSizeOpt 1 14 x'3 + P'.wireSizeOpt 1 5 x'4 + P'.wireSizeOpt 1 13 x'5 + P'.wireSizeExtField x'6) wirePutWithSize ft' self'@(CarriageDetails x'1 x'2 x'3 x'4 x'5 x'6) = case ft' of 10 -> put'Fields 11 -> put'FieldsSized _ -> P'.wirePutErr ft' self' where put'Fields = P'.sequencePutWithSize [P'.wirePutOptWithSize 10 9 x'1, P'.wirePutOptWithSize 18 9 x'2, P'.wirePutOptWithSize 24 14 x'3, P'.wirePutOptWithSize 32 5 x'4, P'.wirePutOptWithSize 40 13 x'5, P'.wirePutExtFieldWithSize x'6] put'FieldsSized = let size' = Prelude'.fst (P'.runPutM put'Fields) put'Size = do P'.putSize size' Prelude'.return (P'.size'WireSize size') in P'.sequencePutWithSize [put'Size, put'Fields] wireGet ft' = case ft' of 10 -> P'.getBareMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) 11 -> P'.getMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) _ -> P'.wireGetErr ft' where update'Self wire'Tag old'Self = case wire'Tag of 10 -> Prelude'.fmap (\ !new'Field -> old'Self{id = Prelude'.Just new'Field}) (P'.wireGet 9) 18 -> Prelude'.fmap (\ !new'Field -> old'Self{label = Prelude'.Just new'Field}) (P'.wireGet 9) 24 -> Prelude'.fmap (\ !new'Field -> old'Self{occupancy_status = Prelude'.Just new'Field}) (P'.wireGet 14) 32 -> Prelude'.fmap (\ !new'Field -> old'Self{occupancy_percentage = Prelude'.Just new'Field}) (P'.wireGet 5) 40 -> Prelude'.fmap (\ !new'Field -> old'Self{carriage_sequence = Prelude'.Just new'Field}) (P'.wireGet 13) _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in if Prelude'.or [1000 <= field'Number && field'Number <= 1999, 9000 <= field'Number && field'Number <= 9999] then P'.loadExtension field'Number wire'Type old'Self else P'.unknown field'Number wire'Type old'Self instance P'.MessageAPI msg' (msg' -> CarriageDetails) CarriageDetails where getVal m' f' = f' m' instance P'.GPB CarriageDetails instance P'.ReflectDescriptor CarriageDetails where getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [10, 18, 24, 32, 40]) reflectDescriptorInfo _ = Prelude'.read "DescriptorInfo {descName = ProtoName {protobufName = FIName \".transit_realtime.VehiclePosition.CarriageDetails\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName = MName \"CarriageDetails\"}, descFilePath = [\"GTFS\",\"Realtime\",\"VehiclePosition\",\"CarriageDetails.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.CarriageDetails.id\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\",MName \"CarriageDetails\"], baseName' = FName \"id\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.CarriageDetails.label\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\",MName \"CarriageDetails\"], baseName' = FName \"label\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 18}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.CarriageDetails.occupancy_status\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\",MName \"CarriageDetails\"], baseName' = FName \"occupancy_status\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 3}, wireTag = WireTag {getWireTag = 24}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 14}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.VehiclePosition.OccupancyStatus\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName = MName \"OccupancyStatus\"}), hsRawDefault = Just \"NO_DATA_AVAILABLE\", hsDefault = Just (HsDef'Enum \"NO_DATA_AVAILABLE\"), isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.CarriageDetails.occupancy_percentage\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\",MName \"CarriageDetails\"], baseName' = FName \"occupancy_percentage\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 4}, wireTag = WireTag {getWireTag = 32}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 5}, typeName = Nothing, hsRawDefault = Just \"-1\", hsDefault = Just (HsDef'Integer (-1)), isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.CarriageDetails.carriage_sequence\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\",MName \"CarriageDetails\"], baseName' = FName \"carriage_sequence\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 5}, wireTag = WireTag {getWireTag = 40}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 13}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing}], descOneofs = fromList [], keys = fromList [], extRanges = [(FieldId {getFieldId = 1000},FieldId {getFieldId = 1999}),(FieldId {getFieldId = 9000},FieldId {getFieldId = 9999})], knownKeys = fromList [], storeUnknown = False, lazyFields = False, makeLenses = False, jsonInstances = False, mapEntry = False}" instance P'.TextType CarriageDetails where tellT = P'.tellSubMessage getT = P'.getSubMessage instance P'.TextMsg CarriageDetails where textPut msg = do P'.tellT "id" (id msg) P'.tellT "label" (label msg) P'.tellT "occupancy_status" (occupancy_status msg) P'.tellT "occupancy_percentage" (occupancy_percentage msg) P'.tellT "carriage_sequence" (carriage_sequence msg) textGet = do mods <- P'.sepEndBy (P'.choice [parse'id, parse'label, parse'occupancy_status, parse'occupancy_percentage, parse'carriage_sequence]) P'.spaces Prelude'.return (Prelude'.foldl' (\ v f -> f v) P'.defaultValue mods) where parse'id = Prelude'.fmap (\ v o -> o{id = v}) (P'.try (P'.getT "id")) parse'label = Prelude'.fmap (\ v o -> o{label = v}) (P'.try (P'.getT "label")) parse'occupancy_status = Prelude'.fmap (\ v o -> o{occupancy_status = v}) (P'.try (P'.getT "occupancy_status")) parse'occupancy_percentage = Prelude'.fmap (\ v o -> o{occupancy_percentage = v}) (P'.try (P'.getT "occupancy_percentage")) parse'carriage_sequence = Prelude'.fmap (\ v o -> o{carriage_sequence = v}) (P'.try (P'.getT "carriage_sequence"))