util.go 562 B

12345678910111213141516171819202122232425
  1. package main
  2. import (
  3. "path/filepath"
  4. "strings"
  5. )
  6. func AddIncludeForType(t GeneratableType, gen *CppGenerator) {
  7. switch v := t.(type) {
  8. case *ClassType:
  9. gen.AddLocalInclude(v.ProtoName + ".h")
  10. case *EnumType:
  11. gen.AddLocalInclude(v.ProtoName + ".h")
  12. case *VectorType:
  13. gen.AddLibraryInclude("vector")
  14. AddIncludeForType(v.InnerType, gen)
  15. case *OptionalType:
  16. gen.AddLibraryInclude("optional")
  17. AddIncludeForType(v.InnerType, gen)
  18. }
  19. }
  20. func StripExtenstion(filename string) string {
  21. return strings.TrimSuffix(filename, filepath.Ext(filename))
  22. }