blob: d34fe45b72784851dc82fadcaf05436f08fc8d9e [file] [log] [blame]
// Copyright (C) 2015 The Android Open Source Project
//
// 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.
package stringtable
import "android.googlesource.com/platform/tools/gpu/binary"
// Node is the interface implemented by all stringtable node types.
type Node interface {
binary.Object
}
// Block is a node that holds a sequential list of sub-nodes.
type Block struct {
binary.Generate
Children []Node
}
// Text is a node that holds a sequence of localized text.
type Text struct {
binary.Generate
Text string // The text string.
}
// LineBreak is a node that represents a vertical gap in layout.
// This is typically authored as a number of new lines (\n).
type LineBreak struct {
binary.Generate
Lines int // Size of the spacing in multiples of the regular-font glyph height.
}
// Whitespace is a node that represents a horizontal gap in text layout.
// This is typically authored as ' '.
type Whitespace struct {
binary.Generate
}
// Parameter is a node representing a dynamic value parameter.
type Parameter struct {
binary.Generate
Formatter Formatter // Optional custom formatter.
Key string // Parameter key.
}
// Link is a node representing a dynamic value parameter hyper-link.
type Link struct {
binary.Generate
Body Node // If nil, just display Target.
Target Node // Parameter or Text
}
// Formatter formats a parameter value to a string.
type Formatter interface {
binary.Object
Format(value interface{}) string
}
// NodeCast is automatically called by the generated decoders.
func NodeCast(obj binary.Object) Node {
if obj == nil {
return nil
}
return obj.(Node)
}
// FormatterCast is automatically called by the generated decoders.
func FormatterCast(obj binary.Object) Formatter {
if obj == nil {
return nil
}
return obj.(Formatter)
}