MCPcopy Create free account
hub / github.com/google/gapid / Format

Method Format

core/stream/format.go:47–83  ·  view source on GitHub ↗

Format prints the Format to w.

(w fmt.State, r rune)

Source from the content-addressed store, hash-verified

45
46// Format prints the Format to w.
47func (f Format) Format(w fmt.State, r rune) {
48 buf := &bytes.Buffer{}
49 samplings, datatypes := unique{}, unique{}
50 for _, c := range f.Components {
51 fmt.Fprint(buf, c.Channel)
52 datatypes.check(c.DataType)
53 samplings.check(c.Sampling)
54 }
55 fmt.Fprint(buf, "_")
56
57 defaultSampling := Sampling{}
58
59 if !datatypes.unique || !samplings.unique {
60 for _, c := range f.Components {
61 if !samplings.unique && !c.Sampling.Is(defaultSampling) {
62 fmt.Fprintf(buf, "%c", c.Sampling)
63 }
64 fmt.Fprint(buf, c.DataType)
65 }
66 if samplings.unique && !proto.Equal(samplings.value, &defaultSampling) {
67 fmt.Fprint(buf, "_", *samplings.value.(*Sampling))
68 }
69 } else {
70 if datatypes.unique {
71 fmt.Fprint(buf, *datatypes.value.(*DataType))
72 }
73 if samplings.unique && !proto.Equal(samplings.value, &defaultSampling) {
74 fmt.Fprint(buf, "_", *samplings.value.(*Sampling))
75 }
76 }
77 name := buf.String()
78 if alias, ok := aliases[name]; ok {
79 w.Write([]byte(alias))
80 } else {
81 w.Write([]byte(name))
82 }
83}
84
85// Clone returns a copy of this format.
86func (f *Format) Clone() *Format {

Callers

nothing calls this directly

Calls 5

checkMethod · 0.95
StringMethod · 0.65
WriteMethod · 0.65
IsMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected