Debian Codegraph @

collation.go

raw symbols SCIP
1 package mssql
2
3 import (
4 "encoding/binary"
5 "io"
6 )
7
8 // http://msdn.microsoft.com/en-us/library/dd340437.aspx
9
10 type collation struct {
11 lcidAndFlags uint32
12 sortId uint8
13 }
14
15 func (c collation) getLcid() uint32 {
16 return c.lcidAndFlags & 0x000fffff
17 }
18
19 func (c collation) getFlags() uint32 {
20 return (c.lcidAndFlags & 0x0ff00000) >> 20
21 }
22
23 func (c collation) getVersion() uint32 {
24 return (c.lcidAndFlags & 0xf0000000) >> 28
25 }
26
27 func readCollation(r *tdsBuffer) (res collation) {
28 res.lcidAndFlags = r.uint32()
29 res.sortId = r.byte()
30 return
31 }
32
33 func writeCollation(w io.Writer, col collation) (err error) {
34 if err = binary.Write(w, binary.LittleEndian, col.lcidAndFlags); err != nil {
35 return
36 }
37 err = binary.Write(w, binary.LittleEndian, col.sortId)
38 return
39 }