content: {-# LANGUAGE BangPatterns, DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses, TemplateHaskell #-}
  {-# OPTIONS_GHC -fno-warn-unused-imports #-}
  module Network.Riak.Protocol.Content (Content(..)) where
  import Prelude ((+), (/))
  import qualified Prelude as Prelude'
  import qualified Data.Typeable as Prelude'
  import qualified Data.Data as Prelude'
  import qualified Text.ProtocolBuffers.Header as P'
  import qualified Network.Riak.Protocol.Link as Protocol (Link)
  import qualified Network.Riak.Protocol.Pair as Protocol (Pair)
   
  data Content = Content{value :: !(P'.ByteString), content_type :: !(P'.Maybe P'.ByteString), charset :: !(P'.Maybe P'.ByteString),
                         content_encoding :: !(P'.Maybe P'.ByteString), vtag :: !(P'.Maybe P'.ByteString),
                         links :: !(P'.Seq Protocol.Link), last_mod :: !(P'.Maybe P'.Word32), last_mod_usecs :: !(P'.Maybe P'.Word32),
                         usermeta :: !(P'.Seq Protocol.Pair), indexes :: !(P'.Seq Protocol.Pair), deleted :: !(P'.Maybe P'.Bool)}
               deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data)
   
  instance P'.Mergeable Content where
    mergeAppend (Content x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9 x'10 x'11) (Content y'1 y'2 y'3 y'4 y'5 y'6 y'7 y'8 y'9 y'10 y'11)
     = Content (P'.mergeAppend x'1 y'1) (P'.mergeAppend x'2 y'2) (P'.mergeAppend x'3 y'3) (P'.mergeAppend x'4 y'4)
        (P'.mergeAppend x'5 y'5)
        (P'.mergeAppend x'6 y'6)
        (P'.mergeAppend x'7 y'7)
        (P'.mergeAppend x'8 y'8)
        (P'.mergeAppend x'9 y'9)
        (P'.mergeAppend x'10 y'10)
        (P'.mergeAppend x'11 y'11)
   
  instance P'.Default Content where
    defaultValue
     = Content P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue
        P'.defaultValue
        P'.defaultValue
        P'.defaultValue
        P'.defaultValue
   
  instance P'.Wire Content where
    wireSize ft' self'@(Content x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9 x'10 x'11)
     = case ft' of
         10 -> calc'Size
         11 -> P'.prependMessageSize calc'Size
         _ -> P'.wireSizeErr ft' self'
      where
          calc'Size
           = (P'.wireSizeReq 1 12 x'1 + P'.wireSizeOpt 1 12 x'2 + P'.wireSizeOpt 1 12 x'3 + P'.wireSizeOpt 1 12 x'4 +
               P'.wireSizeOpt 1 12 x'5
               + P'.wireSizeRep 1 11 x'6
               + P'.wireSizeOpt 1 13 x'7
               + P'.wireSizeOpt 1 13 x'8
               + P'.wireSizeRep 1 11 x'9
               + P'.wireSizeRep 1 11 x'10
               + P'.wireSizeOpt 1 8 x'11)
    wirePut ft' self'@(Content x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9 x'10 x'11)
     = case ft' of
         10 -> put'Fields
         11 -> do
                 P'.putSize (P'.wireSize 10 self')
                 put'Fields
         _ -> P'.wirePutErr ft' self'
      where
          put'Fields
           = do
               P'.wirePutReq 10 12 x'1
               P'.wirePutOpt 18 12 x'2
               P'.wirePutOpt 26 12 x'3
               P'.wirePutOpt 34 12 x'4
               P'.wirePutOpt 42 12 x'5
               P'.wirePutRep 50 11 x'6
               P'.wirePutOpt 56 13 x'7
               P'.wirePutOpt 64 13 x'8
               P'.wirePutRep 74 11 x'9
               P'.wirePutRep 82 11 x'10
               P'.wirePutOpt 88 8 x'11
    wireGet ft'
     = case ft' of
         10 -> P'.getBareMessageWith update'Self
         11 -> P'.getMessageWith update'Self
         _ -> P'.wireGetErr ft'
      where
          update'Self wire'Tag old'Self
           = case wire'Tag of
               10 -> Prelude'.fmap (\ !new'Field -> old'Self{value = new'Field}) (P'.wireGet 12)
               18 -> Prelude'.fmap (\ !new'Field -> old'Self{content_type = Prelude'.Just new'Field}) (P'.wireGet 12)
               26 -> Prelude'.fmap (\ !new'Field -> old'Self{charset = Prelude'.Just new'Field}) (P'.wireGet 12)
               34 -> Prelude'.fmap (\ !new'Field -> old'Self{content_encoding = Prelude'.Just new'Field}) (P'.wireGet 12)
               42 -> Prelude'.fmap (\ !new'Field -> old'Self{vtag = Prelude'.Just new'Field}) (P'.wireGet 12)
               50 -> Prelude'.fmap (\ !new'Field -> old'Self{links = P'.append (links old'Self) new'Field}) (P'.wireGet 11)
               56 -> Prelude'.fmap (\ !new'Field -> old'Self{last_mod = Prelude'.Just new'Field}) (P'.wireGet 13)
               64 -> Prelude'.fmap (\ !new'Field -> old'Self{last_mod_usecs = Prelude'.Just new'Field}) (P'.wireGet 13)
               74 -> Prelude'.fmap (\ !new'Field -> old'Self{usermeta = P'.append (usermeta old'Self) new'Field}) (P'.wireGet 11)
               82 -> Prelude'.fmap (\ !new'Field -> old'Self{indexes = P'.append (indexes old'Self) new'Field}) (P'.wireGet 11)
               88 -> Prelude'.fmap (\ !new'Field -> old'Self{deleted = Prelude'.Just new'Field}) (P'.wireGet 8)
               _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in P'.unknown field'Number wire'Type old'Self
   
  instance P'.MessageAPI msg' (msg' -> Content) Content where
    getVal m' f' = f' m'
   
  instance P'.GPB Content
   
  instance P'.ReflectDescriptor Content where
    getMessageInfo _
     = P'.GetMessageInfo (P'.fromDistinctAscList [10]) (P'.fromDistinctAscList [10, 18, 26, 34, 42, 50, 56, 64, 74, 82, 88])
    reflectDescriptorInfo _
     = Prelude'.read
        "DescriptorInfo {descName = ProtoName {protobufName = FIName \".Protocol.Content\", haskellPrefix = [MName \"Network\",MName \"Riak\"], parentModule = [MName \"Protocol\"], baseName = MName \"Content\"}, descFilePath = [\"Network\",\"Riak\",\"Protocol\",\"Content.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.value\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"value\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 12}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.content_type\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"content_type\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 18}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 12}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.charset\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"charset\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 3}, wireTag = WireTag {getWireTag = 26}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 12}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.content_encoding\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"content_encoding\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 4}, wireTag = WireTag {getWireTag = 34}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 12}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.vtag\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"vtag\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 5}, wireTag = WireTag {getWireTag = 42}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 12}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.links\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"links\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 6}, wireTag = WireTag {getWireTag = 50}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".Protocol.Link\", haskellPrefix = [MName \"Network\",MName \"Riak\"], parentModule = [MName \"Protocol\"], baseName = MName \"Link\"}), hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.last_mod\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"last_mod\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 7}, wireTag = WireTag {getWireTag = 56}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 13}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.last_mod_usecs\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"last_mod_usecs\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 8}, wireTag = WireTag {getWireTag = 64}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 13}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.usermeta\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"usermeta\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 9}, wireTag = WireTag {getWireTag = 74}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".Protocol.Pair\", haskellPrefix = [MName \"Network\",MName \"Riak\"], parentModule = [MName \"Protocol\"], baseName = MName \"Pair\"}), hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.indexes\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"indexes\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 10}, wireTag = WireTag {getWireTag = 82}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".Protocol.Pair\", haskellPrefix = [MName \"Network\",MName \"Riak\"], parentModule = [MName \"Protocol\"], baseName = MName \"Pair\"}), hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".Protocol.Content.deleted\", haskellPrefix' = [MName \"Network\",MName \"Riak\"], parentModule' = [MName \"Protocol\",MName \"Content\"], baseName' = FName \"deleted\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 11}, wireTag = WireTag {getWireTag = 88}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 8}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing}], keys = fromList [], extRanges = [], knownKeys = fromList [], storeUnknown = False, lazyFields = False, makeLenses = False}"
   
  instance P'.TextType Content where
    tellT = P'.tellSubMessage
    getT = P'.getSubMessage
   
  instance P'.TextMsg Content where
    textPut msg
     = do
         P'.tellT "value" (value msg)
         P'.tellT "content_type" (content_type msg)
         P'.tellT "charset" (charset msg)
         P'.tellT "content_encoding" (content_encoding msg)
         P'.tellT "vtag" (vtag msg)
         P'.tellT "links" (links msg)
         P'.tellT "last_mod" (last_mod msg)
         P'.tellT "last_mod_usecs" (last_mod_usecs msg)
         P'.tellT "usermeta" (usermeta msg)
         P'.tellT "indexes" (indexes msg)
         P'.tellT "deleted" (deleted msg)
    textGet
     = do
         mods <- P'.sepEndBy
                  (P'.choice
                    [parse'value, parse'content_type, parse'charset, parse'content_encoding, parse'vtag, parse'links, parse'last_mod,
                     parse'last_mod_usecs, parse'usermeta, parse'indexes, parse'deleted])
                  P'.spaces
         Prelude'.return (Prelude'.foldl (\ v f -> f v) P'.defaultValue mods)
      where
          parse'value
           = P'.try
              (do
                 v <- P'.getT "value"
                 Prelude'.return (\ o -> o{value = v}))
          parse'content_type
           = P'.try
              (do
                 v <- P'.getT "content_type"
                 Prelude'.return (\ o -> o{content_type = v}))
          parse'charset
           = P'.try
              (do
                 v <- P'.getT "charset"
                 Prelude'.return (\ o -> o{charset = v}))
          parse'content_encoding
           = P'.try
              (do
                 v <- P'.getT "content_encoding"
                 Prelude'.return (\ o -> o{content_encoding = v}))
          parse'vtag
           = P'.try
              (do
                 v <- P'.getT "vtag"
                 Prelude'.return (\ o -> o{vtag = v}))
          parse'links
           = P'.try
              (do
                 v <- P'.getT "links"
                 Prelude'.return (\ o -> o{links = P'.append (links o) v}))
          parse'last_mod
           = P'.try
              (do
                 v <- P'.getT "last_mod"
                 Prelude'.return (\ o -> o{last_mod = v}))
          parse'last_mod_usecs
           = P'.try
              (do
                 v <- P'.getT "last_mod_usecs"
                 Prelude'.return (\ o -> o{last_mod_usecs = v}))
          parse'usermeta
           = P'.try
              (do
                 v <- P'.getT "usermeta"
                 Prelude'.return (\ o -> o{usermeta = P'.append (usermeta o) v}))
          parse'indexes
           = P'.try
              (do
                 v <- P'.getT "indexes"
                 Prelude'.return (\ o -> o{indexes = P'.append (indexes o) v}))
          parse'deleted
           = P'.try
              (do
                 v <- P'.getT "deleted"
                 Prelude'.return (\ o -> o{deleted = v}))