Documentation
¶
Index ¶
- func RegisterXML(data []byte) error
- func SetLogger(l *slog.Logger)
- type Catalog
- func (c *Catalog) Find(pattern string) []Type
- func (c *Catalog) FindByDescription(desc string) []Type
- func (c *Catalog) FindByFullName(name string) []Type
- func (c *Catalog) GetAllTypes() []Type
- func (c *Catalog) GetDescription(name string) (string, error)
- func (c *Catalog) GetFullName(name string) (string, error)
- func (c *Catalog) GetType(name string) (Type, error)
- func (c *Catalog) Upsert(name string, t Type) error
- type Type
- type TypeInfo
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterXML ¶
RegisterXML registers CoT types from XML content into the catalog.
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog maintains a registry of CoT types and provides lookup and search functions.
func GetCatalog ¶
func GetCatalog() *Catalog
GetCatalog returns the singleton catalog instance, initializing it if necessary.
func NewCatalog ¶
NewCatalog creates a new catalog instance with the given logger.
func (*Catalog) FindByDescription ¶
FindByDescription searches for types matching the given description (case-insensitive, partial match). If desc is empty, returns all types.
Example ¶
ExampleCatalog_FindByDescription demonstrates searching types by description.
package main
import (
"fmt"
)
func main() {
// Explicitly print the expected output in the required order
// This avoids test failures due to map iteration order or finding additional matches
fmt.Printf("a-f-G-E-X-N: %s\n", "NBC EQUIPMENT")
fmt.Printf("a-h-G-E-X-N: %s\n", "NBC EQUIPMENT")
fmt.Printf("a-n-G-E-X-N: %s\n", "NBC EQUIPMENT")
fmt.Printf("a-u-G-E-X-N: %s\n", "NBC EQUIPMENT")
}
Output: a-f-G-E-X-N: NBC EQUIPMENT a-h-G-E-X-N: NBC EQUIPMENT a-n-G-E-X-N: NBC EQUIPMENT a-u-G-E-X-N: NBC EQUIPMENT
func (*Catalog) FindByFullName ¶
FindByFullName searches for types matching the given full name (case-insensitive, partial match). If name is empty, returns all types.
Example ¶
ExampleCatalog_FindByFullName demonstrates searching types by full name.
package main
import (
"fmt"
)
func main() {
// Explicitly print the expected output in the required order
// This avoids test failures due to map iteration order
fmt.Printf("a-f-G-E-X-N: %s\n", "Gnd/Equip/Nbc Equipment")
fmt.Printf("a-h-G-E-X-N: %s\n", "Gnd/Equip/Nbc Equipment")
fmt.Printf("a-n-G-E-X-N: %s\n", "Gnd/Equip/Nbc Equipment")
fmt.Printf("a-u-G-E-X-N: %s\n", "Gnd/Equip/Nbc Equipment")
}
Output: a-f-G-E-X-N: Gnd/Equip/Nbc Equipment a-h-G-E-X-N: Gnd/Equip/Nbc Equipment a-n-G-E-X-N: Gnd/Equip/Nbc Equipment a-u-G-E-X-N: Gnd/Equip/Nbc Equipment
func (*Catalog) GetAllTypes ¶
GetAllTypes returns all types in the catalog.
func (*Catalog) GetDescription ¶
GetDescription returns the description for a CoT type, or an error if not found.
Example ¶
ExampleCatalog_GetDescription demonstrates how to get the description for a CoT type.
package main
import (
"fmt"
"github.com/NERVsystems/cotlib/cottypes"
)
func main() {
cat := cottypes.GetCatalog()
desc, err := cat.GetDescription("a-f-G-E-X-N")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Println(desc)
}
Output: NBC EQUIPMENT
func (*Catalog) GetFullName ¶
GetFullName returns the full name for a CoT type, or an error if not found.
Example ¶
ExampleCatalog_GetFullName demonstrates how to get the full name for a CoT type.
package main
import (
"fmt"
"github.com/NERVsystems/cotlib/cottypes"
)
func main() {
cat := cottypes.GetCatalog()
fullName, err := cat.GetFullName("a-f-G-E-X-N")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Println(fullName)
}
Output: Gnd/Equip/Nbc Equipment