Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSegmentIdentifierExpected is returned when a segment identifier is expected but not found. ErrSegmentIdentifierExpected = errors.New("segment identifier expected") // ErrElementExpected is returned when an element is expected but not found. ErrElementExpected = errors.New("element expected") )
var DefaultDelimiters = Delimiters{
Segment: '~',
Element: '*',
SubElement: '>',
}
DefaultDelimiters defines the default Delimiters used in EDI files.
var ( // ErrInvalidISALength represents an error for invalid ISA segment length. ErrInvalidISALength = errors.New("invalid ISA length") )
Functions ¶
This section is empty.
Types ¶
type Delimiters ¶
Delimiters contains the delimiters used for splitting segments, elements, and sub-elements in EDI files.
type Element ¶
Element represents an individual EDI element, containing a value and optional sub-elements.
func (*Element) AddSubElement ¶
AddSubElement appends a sub-element value to the Element's SubElements slice. Initializes SubElements if it is nil.
func (Element) DString ¶
func (e Element) DString(delimiters Delimiters) string
DString returns a delimited string representation of the Element. It formats the Element's value and sub-elements using the provided Delimiters.
type Elements ¶
type Elements []Element
Elements is a slice of Element structs, often representing a list of elements in an EDI segment.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer wraps an io.Reader for lexing EDI files.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser encapsulates the parsing logic for EDI files.
type Segment ¶
Segment represents an EDI segment, which consists of an ID and a list of Elements.
func NewSegment ¶
NewSegment constructs a new Segment with the given ID.
func (*Segment) AddElement ¶
AddElement appends an Element to the end of the Segment.
func (Segment) DString ¶
func (s Segment) DString(delimiters Delimiters) string
DString converts the Segment to its EDI string representation using the provided delimiters.
func (Segment) GetElement ¶
GetElement retrieves the Element at the specified index within the Segment. Returns the Element and a boolean indicating whether the Element was found.
func (*Segment) SetElement ¶
SetElement replaces or appends an Element at the specified index in the Segment. If the index exceeds the current size, the Elements slice is expanded.
type Segments ¶
type Segments []Segment
Segments is a slice of Segment types.
func (*Segments) DString ¶
func (s *Segments) DString(delimiters Delimiters) string
DString constructs a string representation of Segments using provided delimiters.
func (*Segments) DWriteTo ¶
DWriteTo writes the Segments to an io.Writer w, formatted with specified delimiters. Returns the number of bytes written and any error encountered.
func (*Segments) Last ¶
Last returns a pointer to the last segment in the list, or nil if the list is empty. The boolean return value indicates the presence of a last segment.
type TokenType ¶
type TokenType string
TokenType represents the type of token in the parser.
const ( // SegmentIdentifier represents the type of token that identifies a segment. SegmentIdentifier TokenType = "segment_identifier" // SegmentTerminator represents the type of token that terminates a segment. SegmentTerminator TokenType = "segment_terminator" // ElementValue represents the type of token that holds the value of an element. ElementValue TokenType = "element_value" // ElementDelimiter represents the type of token that delimits elements. ElementDelimiter TokenType = "element_delimiter" // SubElementValue represents the type of token that holds the value of a sub-element. SubElementValue TokenType = "sub_element_value" // SubElementDelimiter represents the type of token that delimits sub-elements. SubElementDelimiter TokenType = "sub_element_delimiter" )
Enumerated TokenTypes for various elements in the segment structure.