Notes added by 'git notes append'
This commit is contained in:
parent
549f9e3a02
commit
ac1dba73a5
|
@ -1004,3 +1004,451 @@ func file_file_proto_init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// `autogen:file.sort.pb.go`
|
// `autogen:file.sort.pb.go`
|
||||||
|
|
||||||
|
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
|
||||||
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the GPL 3.0
|
||||||
|
|
||||||
|
// This file was autogenerated with autogenpb v0.0.49-1-gcfedee7 2025.02.01_0658
|
||||||
|
// go install go.wit.com/apps/autogenpb@latest
|
||||||
|
//
|
||||||
|
// define which structs (messages) you want to use in the .proto file
|
||||||
|
// Then sort.pb.go and marshal.pb.go files are autogenerated
|
||||||
|
//
|
||||||
|
// autogenpb uses it and has an example .proto file with instructions
|
||||||
|
//
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
// a simple global lock
|
||||||
|
var fileMu sync.RWMutex
|
||||||
|
|
||||||
|
func (x *Files) fixUuid() {
|
||||||
|
if x == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if x.Uuid == "6c9ae4dd-648d-4b51-9738-bd59fb8fafd5" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
x.Uuid = "6c9ae4dd-648d-4b51-9738-bd59fb8fafd5"
|
||||||
|
x.Version = "v0.0.38 "
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFiles() *Files {
|
||||||
|
x := new(Files)
|
||||||
|
x.Uuid = "6c9ae4dd-648d-4b51-9738-bd59fb8fafd5"
|
||||||
|
x.Version = "v0.0.38 "
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
|
||||||
|
// START SORT
|
||||||
|
|
||||||
|
// DEFINE THE Files ITERATOR.
|
||||||
|
// itializes a new iterator.
|
||||||
|
func newFilesIterator(things []*Files) *FilesIterator {
|
||||||
|
return &FilesIterator{things: things}
|
||||||
|
}
|
||||||
|
|
||||||
|
type FilesIterator struct {
|
||||||
|
sync.RWMutex // this isn't getting used properly yet?
|
||||||
|
|
||||||
|
things []*Files
|
||||||
|
index int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (it *FilesIterator) Scan() bool {
|
||||||
|
if it.index >= len(it.things) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
it.index++
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next() returns the next thing in the array
|
||||||
|
func (it *FilesIterator) Next() *Files {
|
||||||
|
if it.things[it.index-1] == nil {
|
||||||
|
fmt.Println("Next() error in FilesIterator", it.index)
|
||||||
|
}
|
||||||
|
return it.things[it.index-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// END DEFINE THE ITERATOR
|
||||||
|
|
||||||
|
// DEFINE THE File ITERATOR.
|
||||||
|
// itializes a new iterator.
|
||||||
|
func newFileIterator(things []*File) *FileIterator {
|
||||||
|
return &FileIterator{things: things}
|
||||||
|
}
|
||||||
|
|
||||||
|
type FileIterator struct {
|
||||||
|
sync.RWMutex // this isn't getting used properly yet?
|
||||||
|
|
||||||
|
things []*File
|
||||||
|
index int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (it *FileIterator) Scan() bool {
|
||||||
|
if it.index >= len(it.things) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
it.index++
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next() returns the next thing in the array
|
||||||
|
func (it *FileIterator) Next() *File {
|
||||||
|
if it.things[it.index-1] == nil {
|
||||||
|
fmt.Println("Next() error in FileIterator", it.index)
|
||||||
|
}
|
||||||
|
return it.things[it.index-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// END DEFINE THE ITERATOR
|
||||||
|
|
||||||
|
// DEFINE THE MsgVar ITERATOR.
|
||||||
|
// itializes a new iterator.
|
||||||
|
func newMsgVarIterator(things []*MsgVar) *MsgVarIterator {
|
||||||
|
return &MsgVarIterator{things: things}
|
||||||
|
}
|
||||||
|
|
||||||
|
type MsgVarIterator struct {
|
||||||
|
sync.RWMutex // this isn't getting used properly yet?
|
||||||
|
|
||||||
|
things []*MsgVar
|
||||||
|
index int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (it *MsgVarIterator) Scan() bool {
|
||||||
|
if it.index >= len(it.things) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
it.index++
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next() returns the next thing in the array
|
||||||
|
func (it *MsgVarIterator) Next() *MsgVar {
|
||||||
|
if it.things[it.index-1] == nil {
|
||||||
|
fmt.Println("Next() error in MsgVarIterator", it.index)
|
||||||
|
}
|
||||||
|
return it.things[it.index-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// END DEFINE THE ITERATOR
|
||||||
|
|
||||||
|
// DEFINE THE MsgName ITERATOR.
|
||||||
|
// itializes a new iterator.
|
||||||
|
func newMsgNameIterator(things []*MsgName) *MsgNameIterator {
|
||||||
|
return &MsgNameIterator{things: things}
|
||||||
|
}
|
||||||
|
|
||||||
|
type MsgNameIterator struct {
|
||||||
|
sync.RWMutex // this isn't getting used properly yet?
|
||||||
|
|
||||||
|
things []*MsgName
|
||||||
|
index int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (it *MsgNameIterator) Scan() bool {
|
||||||
|
if it.index >= len(it.things) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
it.index++
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next() returns the next thing in the array
|
||||||
|
func (it *MsgNameIterator) Next() *MsgName {
|
||||||
|
if it.things[it.index-1] == nil {
|
||||||
|
fmt.Println("Next() error in MsgNameIterator", it.index)
|
||||||
|
}
|
||||||
|
return it.things[it.index-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// END DEFINE THE ITERATOR
|
||||||
|
|
||||||
|
// DEFINE THE Sort ITERATOR.
|
||||||
|
// itializes a new iterator.
|
||||||
|
func newSortIterator(things []*Sort) *SortIterator {
|
||||||
|
return &SortIterator{things: things}
|
||||||
|
}
|
||||||
|
|
||||||
|
type SortIterator struct {
|
||||||
|
sync.RWMutex // this isn't getting used properly yet?
|
||||||
|
|
||||||
|
things []*Sort
|
||||||
|
index int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (it *SortIterator) Scan() bool {
|
||||||
|
if it.index >= len(it.things) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
it.index++
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next() returns the next thing in the array
|
||||||
|
func (it *SortIterator) Next() *Sort {
|
||||||
|
if it.things[it.index-1] == nil {
|
||||||
|
fmt.Println("Next() error in SortIterator", it.index)
|
||||||
|
}
|
||||||
|
return it.things[it.index-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// END DEFINE THE ITERATOR
|
||||||
|
|
||||||
|
// DEFINE THE Find ITERATOR.
|
||||||
|
// itializes a new iterator.
|
||||||
|
func newFindIterator(things []*Find) *FindIterator {
|
||||||
|
return &FindIterator{things: things}
|
||||||
|
}
|
||||||
|
|
||||||
|
type FindIterator struct {
|
||||||
|
sync.RWMutex // this isn't getting used properly yet?
|
||||||
|
|
||||||
|
things []*Find
|
||||||
|
index int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (it *FindIterator) Scan() bool {
|
||||||
|
if it.index >= len(it.things) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
it.index++
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next() returns the next thing in the array
|
||||||
|
func (it *FindIterator) Next() *Find {
|
||||||
|
if it.things[it.index-1] == nil {
|
||||||
|
fmt.Println("Next() error in FindIterator", it.index)
|
||||||
|
}
|
||||||
|
return it.things[it.index-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// END DEFINE THE ITERATOR
|
||||||
|
|
||||||
|
// DEFINE THE Identify ITERATOR.
|
||||||
|
// itializes a new iterator.
|
||||||
|
func newIdentifyIterator(things []*Identify) *IdentifyIterator {
|
||||||
|
return &IdentifyIterator{things: things}
|
||||||
|
}
|
||||||
|
|
||||||
|
type IdentifyIterator struct {
|
||||||
|
sync.RWMutex // this isn't getting used properly yet?
|
||||||
|
|
||||||
|
things []*Identify
|
||||||
|
index int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (it *IdentifyIterator) Scan() bool {
|
||||||
|
if it.index >= len(it.things) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
it.index++
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next() returns the next thing in the array
|
||||||
|
func (it *IdentifyIterator) Next() *Identify {
|
||||||
|
if it.things[it.index-1] == nil {
|
||||||
|
fmt.Println("Next() error in IdentifyIterator", it.index)
|
||||||
|
}
|
||||||
|
return it.things[it.index-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// END DEFINE THE ITERATOR
|
||||||
|
|
||||||
|
// safely returns a slice of pointers to the FRUIT protobufs
|
||||||
|
func (x *Files) allFiles() []*File {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
// Create a new slice to hold pointers to each FRUIT
|
||||||
|
var tmp []*File
|
||||||
|
tmp = make([]*File, len(x.Files))
|
||||||
|
for i, p := range x.Files {
|
||||||
|
tmp[i] = p // Copy pointers for safe iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
// safely returns a slice of pointers to the FRUIT protobufs
|
||||||
|
func (x *File) allMsgNames() []*MsgName {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
// Create a new slice to hold pointers to each FRUIT
|
||||||
|
var tmp []*MsgName
|
||||||
|
tmp = make([]*MsgName, len(x.MsgNames))
|
||||||
|
for i, p := range x.MsgNames {
|
||||||
|
tmp[i] = p // Copy pointers for safe iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
// safely returns a slice of pointers to the FRUIT protobufs
|
||||||
|
func (x *File) allSortNames() []*MsgName {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
// Create a new slice to hold pointers to each FRUIT
|
||||||
|
var tmp []*MsgName
|
||||||
|
tmp = make([]*MsgName, len(x.SortNames))
|
||||||
|
for i, p := range x.SortNames {
|
||||||
|
tmp[i] = p // Copy pointers for safe iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
// safely returns a slice of pointers to the FRUIT protobufs
|
||||||
|
func (x *File) allToSort() []*Sort {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
// Create a new slice to hold pointers to each FRUIT
|
||||||
|
var tmp []*Sort
|
||||||
|
tmp = make([]*Sort, len(x.ToSort))
|
||||||
|
for i, p := range x.ToSort {
|
||||||
|
tmp[i] = p // Copy pointers for safe iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
// safely returns a slice of pointers to the FRUIT protobufs
|
||||||
|
func (x *MsgName) allVars() []*MsgVar {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
// Create a new slice to hold pointers to each FRUIT
|
||||||
|
var tmp []*MsgVar
|
||||||
|
tmp = make([]*MsgVar, len(x.Vars))
|
||||||
|
for i, p := range x.Vars {
|
||||||
|
tmp[i] = p // Copy pointers for safe iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
// safely returns a slice of pointers to the File protobufs
|
||||||
|
func (x *Files) selectAllFiles() []*File {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
// Create a new slice to hold pointers to each File
|
||||||
|
var tmp []*File
|
||||||
|
tmp = make([]*File, len(x.Files))
|
||||||
|
for i, p := range x.Files {
|
||||||
|
tmp[i] = p // Copy pointers for safe iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
// safely returns a slice of pointers to the MsgName protobufs
|
||||||
|
func (x *File) selectAllMsgNames() []*MsgName {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
// Create a new slice to hold pointers to each MsgName
|
||||||
|
var tmp []*MsgName
|
||||||
|
tmp = make([]*MsgName, len(x.MsgNames))
|
||||||
|
for i, p := range x.MsgNames {
|
||||||
|
tmp[i] = p // Copy pointers for safe iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
// safely returns a slice of pointers to the MsgName protobufs
|
||||||
|
func (x *File) selectAllSortNames() []*MsgName {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
// Create a new slice to hold pointers to each MsgName
|
||||||
|
var tmp []*MsgName
|
||||||
|
tmp = make([]*MsgName, len(x.SortNames))
|
||||||
|
for i, p := range x.SortNames {
|
||||||
|
tmp[i] = p // Copy pointers for safe iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
// safely returns a slice of pointers to the Sort protobufs
|
||||||
|
func (x *File) selectAllToSort() []*Sort {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
// Create a new slice to hold pointers to each Sort
|
||||||
|
var tmp []*Sort
|
||||||
|
tmp = make([]*Sort, len(x.ToSort))
|
||||||
|
for i, p := range x.ToSort {
|
||||||
|
tmp[i] = p // Copy pointers for safe iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
// safely returns a slice of pointers to the MsgVar protobufs
|
||||||
|
func (x *MsgName) selectAllVars() []*MsgVar {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
// Create a new slice to hold pointers to each MsgVar
|
||||||
|
var tmp []*MsgVar
|
||||||
|
tmp = make([]*MsgVar, len(x.Vars))
|
||||||
|
for i, p := range x.Vars {
|
||||||
|
tmp[i] = p // Copy pointers for safe iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
// END SORT
|
||||||
|
|
||||||
|
func (x *Files) Len() int {
|
||||||
|
fileMu.RLock()
|
||||||
|
defer fileMu.RUnlock()
|
||||||
|
|
||||||
|
return len(x.Files)
|
||||||
|
}
|
||||||
|
|
||||||
|
// just a simple Append() shortcut (but still uses the mutex lock)
|
||||||
|
func (x *Files) Append(y *File) {
|
||||||
|
fileMu.Lock()
|
||||||
|
defer fileMu.Unlock()
|
||||||
|
|
||||||
|
x.Files = append(x.Files, y)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Files) All() *FileIterator {
|
||||||
|
FilePointers := x.selectAllFiles()
|
||||||
|
|
||||||
|
iterator := newFileIterator(FilePointers)
|
||||||
|
return iterator
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Files) Delete(y *File) bool {
|
||||||
|
fileMu.Lock()
|
||||||
|
defer fileMu.Unlock()
|
||||||
|
|
||||||
|
for i, _ := range x.Files {
|
||||||
|
if x.Files[i] == y {
|
||||||
|
x.Files[i] = x.Files[len(x.Files)-1]
|
||||||
|
x.Files = x.Files[:len(x.Files)-1]
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue