Пример #1
0
class UnionTest(rdf_structs.RDFProtoStruct):
  union_field = "struct_flavor"

  type_description = type_info.TypeDescriptorSet(
      rdf_structs.ProtoEnum(
          name="struct_flavor",
          field_number=1,
          enum_name="Type",
          enum={
              "FIRST": 1,
              "SECOND": 2,
              "THIRD": 3
          },
          default=3,
          description="An union enum field"),
      rdf_structs.ProtoFloat(
          name="first",
          field_number=2,
          description="A float number",
          default=1.1),
      rdf_structs.ProtoString(
          name="second",
          field_number=3,
          default="string",
          description="A string value"),
      rdf_structs.ProtoUnsignedInteger(
          name="third",
          field_number=4,
          default=5,
          description="An integer value"),
  )
Пример #2
0
class SqliteTestStruct(rdf_structs.RDFProtoStruct):
    """Custom struct for testing schema generation."""

    type_description = type_info.TypeDescriptorSet(
        rdf_structs.ProtoString(name="string_field", field_number=1),
        rdf_structs.ProtoBinary(name="bytes_field", field_number=2),
        rdf_structs.ProtoUnsignedInteger(name="uint_field", field_number=3),
        rdf_structs.ProtoSignedInteger(name="int_field", field_number=4),
        rdf_structs.ProtoFloat(name="float_field", field_number=5),
        rdf_structs.ProtoDouble(name="double_field", field_number=6),
        rdf_structs.ProtoEnum(name="enum_field",
                              field_number=7,
                              enum_name="EnumField",
                              enum={
                                  "FIRST": 1,
                                  "SECOND": 2
                              }),
        rdf_structs.ProtoBoolean(name="bool_field", field_number=8),
        rdf_structs.ProtoRDFValue(name="urn_field",
                                  field_number=9,
                                  rdf_type="RDFURN"),
        rdf_structs.ProtoRDFValue(name="time_field",
                                  field_number=10,
                                  rdf_type="RDFDatetime"),
        rdf_structs.ProtoRDFValue(name="time_field_seconds",
                                  field_number=11,
                                  rdf_type="RDFDatetimeSeconds"),
        rdf_structs.ProtoRDFValue(name="duration_field",
                                  field_number=12,
                                  rdf_type="Duration"),
        rdf_structs.ProtoEmbedded(name="embedded_field",
                                  field_number=13,
                                  nested=TestEmbeddedStruct))
Пример #3
0
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),
  )