-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make entries configurable and printable (#8)
* make entries configurable and printable * fix config * fix * fix * fix
- Loading branch information
1 parent
799d061
commit eb5d71e
Showing
6 changed files
with
125 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package datastreamer | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"unsafe" | ||
) | ||
|
||
type EntityDefinition struct { | ||
Name string | ||
StreamType StreamType | ||
EntryType EntryType | ||
Definition reflect.Type | ||
} | ||
|
||
func (e EntityDefinition) toString(entity []byte) string { | ||
obj := reflect.NewAt(e.Definition, unsafe.Pointer(&entity[0])) | ||
val := obj.Elem() | ||
stringValue := "" | ||
|
||
for i := 0; i < val.NumField(); i++ { | ||
stringValue += fmt.Sprintf(val.Type().Field(i).Name + ": " + fmt.Sprintf("%v", val.Field(i).Interface())) | ||
if i < val.NumField()-1 { | ||
stringValue += ", " | ||
} | ||
} | ||
return stringValue | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.