1 Star 1 Fork 0

bigbase / pg

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
hstore_parser.go 723 Bytes
Copy Edit Raw Blame History
package parser
import "fmt"
type HstoreParser struct {
*Parser
}
func NewHstoreParser(b []byte) *HstoreParser {
return &HstoreParser{
Parser: New(b),
}
}
func (p *HstoreParser) NextKey() ([]byte, error) {
if p.Skip(',') {
p.Skip(' ')
}
if !p.Skip('"') {
return nil, fmt.Errorf("pg: can't parse hstore key: %q", p.Bytes())
}
key := p.readSubstring()
if !(p.Skip('=') && p.Skip('>')) {
return nil, fmt.Errorf("pg: can't parse hstore key: %q", p.Bytes())
}
return key, nil
}
func (p *HstoreParser) NextValue() ([]byte, error) {
if !p.Skip('"') {
return nil, fmt.Errorf("pg: can't parse hstore value: %q", p.Bytes())
}
value := p.readSubstring()
p.SkipBytes([]byte(", "))
return value, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/bigbase/pg.git
git@gitee.com:bigbase/pg.git
bigbase
pg
pg
v6.14.0

Search

344bd9b3 5694891 D2dac590 5694891