class FastGrrMessageList(rdf_structs.RDFProtoStruct): """A Faster implementation of GrrMessageList.""" type_description = type_info.TypeDescriptorSet( rdf_structs.ProtoList( rdf_structs.ProtoEmbedded( name="job", field_number=1, nested=StructGrrMessage)))
class TestStruct(rdf_structs.RDFProtoStruct): """A test struct object.""" type_description = type_info.TypeDescriptorSet( rdf_structs.ProtoString( name="foobar", field_number=1, default="string", description="A string value", labels=[rdf_structs.SemanticDescriptor.Labels.HIDDEN]), rdf_structs.ProtoUnsignedInteger( name="int", field_number=2, default=5, description="An integer value"), rdf_structs.ProtoList( rdf_structs.ProtoString( name="repeated", field_number=3, description="A repeated string value")), # We can serialize an arbitrary RDFValue. This will be serialized into a # binary string and parsed on demand. rdf_structs.ProtoRDFValue( name="urn", field_number=6, default=rdfvalue.RDFURN("www.google.com"), rdf_type="RDFURN", description="An arbitrary RDFValue field."), rdf_structs.ProtoEnum( name="type", field_number=7, enum_name="Type", enum={ "FIRST": 1, "SECOND": 2, "THIRD": 3 }, default=3, description="An enum field"), rdf_structs.ProtoFloat( name="float", field_number=8, description="A float number", default=1.1), )
class LateBindingTest(rdf_structs.RDFProtoStruct): type_description = type_info.TypeDescriptorSet( # A nested protobuf referring to an undefined type. rdf_structs.ProtoEmbedded( name="nested", field_number=1, nested="UndefinedYet"), rdf_structs.ProtoRDFValue( name="rdfvalue", field_number=6, rdf_type="UndefinedRDFValue", description="An undefined RDFValue field."), # A repeated late bound field. rdf_structs.ProtoList( rdf_structs.ProtoRDFValue( name="repeated", field_number=7, rdf_type="UndefinedRDFValue2", description="An undefined RDFValue field.")), )
name="float", field_number=8, description="A float number", default=1.1), ) # In order to define a recursive structure we must add it manually after the # class definition. TestStruct.AddDescriptor( rdf_structs.ProtoEmbedded(name="nested", field_number=4, nested=TestStruct),) TestStruct.AddDescriptor( rdf_structs.ProtoList( rdf_structs.ProtoEmbedded( name="repeat_nested", field_number=5, nested=TestStruct)),) class TestStructWithBool(rdf_structs.RDFProtoStruct): """A test struct object.""" type_description = type_info.TypeDescriptorSet( rdf_structs.ProtoBoolean( name="foo", field_number=1, default=False, )) class TestStructWithEnum(rdf_structs.RDFProtoStruct):