Documentation ¶
Index ¶
- Constants
- func CreateImplementations(f fs.FS) error
- func Execute(f fs.FS, t *template.Template, args interface{}) error
- type ArrayWriter
- type AssetDecl
- type CMakeLists
- type CloserCloser
- type Creator
- type DoneCloser
- type ID
- type MapperHdr
- type Mappings
- type Resource
- type ResourceManager
- type Resources
- type Target
- type TemplateID
Constants ¶
const ( PageSize = 4096 MaxWidth = 72 )
Size constants.
Variables ¶
This section is empty.
Functions ¶
func CreateImplementations ¶
CreateImplementations creates the files that don't rely on variable state.
Types ¶
type ArrayWriter ¶
type ArrayWriter struct { Into io.WriteCloser // contains filtered or unexported fields }
ArrayWriter consumes bytes and formats them as a C++ array literal.
TODO: Set an unrecoverable error state to indicate that internal state may be unusable.
TODO: Support chunked write / partial lines from Write, etc. without weird line breaks.
TODO: Support Windows-style newline + carriage return?
TODO: Optimize for space? (Base64 / other solutions?)
TODO: Add benchmark tests.
func NewArrayWriter ¶
func NewArrayWriter(over io.WriteCloser) ArrayWriter
NewArrayWriter constructs a new ArrayWriter over the given writer.
func (ArrayWriter) Close ¶
func (a ArrayWriter) Close() error
Close calls Flush and then closes the underlying WriteCloser if successful. It may not be used after this.
func (ArrayWriter) Flush ¶
func (a ArrayWriter) Flush() error
Flush flushes any remaining buffered contents to a.Into.
type CMakeLists ¶
type CMakeLists Resources
type CloserCloser ¶
type CloserCloser struct {
// contains filtered or unexported fields
}
func (CloserCloser) Close ¶
func (c CloserCloser) Close() error
type DoneCloser ¶
type DoneCloser struct { io.WriteCloser // contains filtered or unexported fields }
func (DoneCloser) Close ¶
func (d DoneCloser) Close() error
func (DoneCloser) Count ¶
func (d DoneCloser) Count() int64
type Resource ¶
type Resource struct { // Name is the original filename of the resource. This is // needed for encoding the actual variable name in the var // declaration. Name string // TODO: // ID is a numeric ID assigned to the resource in case of a name // collision. ID int // Size is the full uncompressed size of the resource. Size int64 // Into is the writer which the static asset will be written to. // Decl is the writer which will encode the variable declaration // referring to the asset. Into, Decl io.WriteCloser // CompCount is set in the Close method if the underlying "Into" // implements compress.Counter. CompCount int64 // This handles closing the compressor / array writer first, and // then the file underlying it. CloserCloser }
Resource represents a static asset or resource generated from a file.
type ResourceManager ¶
type ResourceManager struct {
Resources
}
type Target ¶
Target is a complete C++ static asset class.
TODO: cpp.Target is just a wrapper for a handful of C helpers.
type TemplateID ¶
type TemplateID int
const ( TmpDecl TemplateID = iota TmpID TmpMapperHdr TmpMapperImpl TmpMappings TmpResourceHdr TmpResourceImpl TmpCMakeLists TmpGitignore TmpClangFormat )
Template ID constants.