// Copyright 2016 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto2";


package xml;

option java_package = "com.google.devtools.build.android.proto";

// A header message describing information about the rest of the message stream,
// It will be the first message in a buffer that contain these messages.
// See com.google.devtools.build.android.AndroidDataSerializer for details on
// how these messages are used.
message Header {
  // The number of entries stored in a serialized buffer.
  optional uint32 entry_count = 1;
  // The number of ProtoSource entries.
  optional uint32 source_count = 2;
}

// The serialized format for a DataKey.
message DataKey {
  // Used for both the FullyQualifiedName name and RelativeAssetPath path
  optional string key_value = 2;
  // The resource type for FullyQualifiedNames
  optional string resource_type = 3;
  optional string key_package = 4;
  repeated string qualifiers = 5;
  // The size of the associated value. Useful for calculating an offset.
  // Required
  optional int32 value_size = 6;
  // Whether this DataKey is a reference to another DataKey.
  optional bool reference = 7;
}

// The serialized format for a DataValue.
message DataValue {
  // The index of the ProtoSource in the source table section.
  // Required
  optional uint32 source_id = 1;

  // If xml_value is defined it's an xml value, otherwise, it's a file value.
  optional DataValueXml xml_value= 2;
}

// A container for all the source information to be persisted.
message ProtoSource {
  // Required
  optional string filename = 1;
}

// The container for a serialized xml value.
message DataValueXml {
  enum XmlType {
    ARRAY = 0;
    ATTR = 1;
    ID = 2;
    PLURAL = 3;
    PUBLIC = 4;
    SIMPLE = 5;
    STYLEABLE = 6;
    STYLE = 7;
  }

  optional XmlType type = 1;
  map<string, string> mapped_string_value = 2;
  map<string, DataValueXml> mapped_xml_value = 3;
  repeated string list_value = 4;
  optional string value = 5;
  optional string value_type = 6;
  repeated DataKey references = 7;
  map<string, string> attribute = 8;
  map<string, string> namespace = 9;
}
