mirror of
https://github.com/danog/parser.git
synced 2025-01-23 05:21:22 +01:00
36 lines
478 B
Go
36 lines
478 B
Go
package value
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
type String struct {
|
|
value string
|
|
}
|
|
|
|
func NewString(value string) *String {
|
|
return &String{value}
|
|
}
|
|
|
|
func (s *String) ToString() string {
|
|
return s.value
|
|
}
|
|
|
|
func (s *String) ToInt() int {
|
|
i, _ := strconv.Atoi(s.value)
|
|
return i
|
|
}
|
|
|
|
func (s *String) IsString() bool {
|
|
return true
|
|
}
|
|
|
|
func (s *String) IsInt() bool {
|
|
return false
|
|
}
|
|
|
|
func (s *String) Dump() string {
|
|
return fmt.Sprintf("string(%d) \"%s\"", len(s.value), s.value)
|
|
}
|