converter

package
v0.0.0-...-8e17a21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2020 License: GPL-2.0 Imports: 17 Imported by: 72

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSliceSize = errors.New("Slice size larger than buffer size")
View Source
var FirstEcosystemTables = map[string]bool{
	`keys`:               false,
	`menu`:               true,
	`pages`:              true,
	`blocks`:             true,
	`languages`:          true,
	`contracts`:          true,
	`tables`:             true,
	`parameters`:         true,
	`history`:            true,
	`sections`:           true,
	`members`:            false,
	`roles`:              true,
	`roles_participants`: true,
	`notifications`:      true,
	`applications`:       true,
	`binaries`:           true,
	`buffer_data`:        true,
	`app_params`:         true,
}

Functions

func AddressToString

func AddressToString(address int64) (ret string)

AddressToString converts int64 address to apla address as XXXX-...-XXXX.

func BinMarshal

func BinMarshal(out *[]byte, v interface{}) (*[]byte, error)

BinMarshal converts v parameter to []byte slice.

func BinToDec

func BinToDec(bin []byte) int64

BinToDec converts input binary []byte to int64

func BinToDecBytesShift

func BinToDecBytesShift(bin *[]byte, num int64) int64

BinToDecBytesShift converts the input binary []byte to int64 and shifts the input bin

func BinToHex

func BinToHex(v interface{}) []byte

BinToHex converts interface to hex []byte

func BinUnmarshal

func BinUnmarshal(out *[]byte, v interface{}) error

BinUnmarshal converts []byte slice which has been made with BinMarshal to v

func BinUnmarshalBuff

func BinUnmarshalBuff(buf *bytes.Buffer, v interface{}) error

func BytesShift

func BytesShift(str *[]byte, index int64) (ret []byte)

BytesShift returns the index bytes of the input []byte and shift str pointer

func BytesShiftReverse

func BytesShiftReverse(str *[]byte, v interface{}) []byte

BytesShiftReverse gets []byte from the end of the input and cut the input pointer to []byte

func BytesToFloat64

func BytesToFloat64(s []byte) float64

BytesToFloat64 converts []byte to float64

func BytesToInt

func BytesToInt(s []byte) int

BytesToInt converts []byte to integer

func BytesToInt64

func BytesToInt64(s []byte) int64

BytesToInt64 converts []bytes to int64

func DecToBin

func DecToBin(v interface{}, sizeBytes int64) []byte

DecToBin converts interface to []byte

func DecodeBytesBuf

func DecodeBytesBuf(buf *bytes.Buffer) ([]byte, error)

func DecodeLenInt64

func DecodeLenInt64(data *[]byte) (int64, error)

DecodeLenInt64 gets int64 from []byte and shift the slice. The []byte should be encoded with EncodeLengthPlusInt64.

func DecodeLenInt64Buf

func DecodeLenInt64Buf(buf *bytes.Buffer) (int64, error)

func DecodeLength

func DecodeLength(buf *[]byte) (ret int64, err error)

DecodeLength decodes []byte to int64 and shifts buf. Bytes must be encoded with EncodeLength function.

0x43 => 67
0x820400 => 1024
0x830f4240 => 1000000

func DecodeLengthBuf

func DecodeLengthBuf(buf *bytes.Buffer) (int, error)

func EGSMoney

func EGSMoney(money string) string

EGSMoney converts qEGS to EGS. For example, 123455000000000000000 => 123.455

func EncodeLenByte

func EncodeLenByte(out *[]byte, buf []byte) *[]byte

func EncodeLenInt64

func EncodeLenInt64(data *[]byte, x int64) *[]byte

func EncodeLenInt64InPlace

func EncodeLenInt64InPlace(x int64) []byte

func EncodeLength

func EncodeLength(length int64) []byte

EncodeLength encodes int64 number to []byte. If it is less than 128 then it returns []byte{length}. Otherwise, it returns (0x80 | len of int64) + int64 as BigEndian []byte

67 => 0x43
1024 => 0x820400
1000000 => 0x830f4240

func EncodeLengthPlusData

func EncodeLengthPlusData(idata interface{}) []byte

EncodeLengthPlusData encoding interface into []byte

func Escape

func Escape(data string) string

Escape deletes unaccessable characters

func EscapeForJSON

func EscapeForJSON(data string) string

EscapeForJSON replaces quote to slash and quote

func EscapeName

func EscapeName(name string) string

EscapeName deletes unaccessable characters for input name(s)

func EscapeSQL

func EscapeSQL(name string) string

func FieldToBytes

func FieldToBytes(v interface{}, num int) []byte

FieldToBytes returns the value of n-th field of v as []byte

func FillLeft

func FillLeft(slice []byte) []byte

FillLeft is filling slice

func Float64ToStr

func Float64ToStr(f float64) string

Float64ToStr converts float64 to string

func HexToBin

func HexToBin(ihexdata interface{}) []byte

HexToBin converts hex interface to binary []byte

func InSliceString

func InSliceString(search string, slice []string) bool

InSliceString searches the string in the slice of strings

func Int64ToByte

func Int64ToByte(num int64) []byte

Int64ToByte converts int64 to []byte

func Int64ToDateStr

func Int64ToDateStr(date int64, format string) string

func Int64ToStr

func Int64ToStr(num int64) string

Int64ToStr converts int64 to string

func IntToStr

func IntToStr(num int) string

IntToStr converts integer to string

func InterfaceSliceToStr

func InterfaceSliceToStr(i []interface{}) (strs []string, err error)

InterfaceSliceToStr converts the slice of interfaces to the slice of strings

func InterfaceToFloat64

func InterfaceToFloat64(i interface{}) float64

InterfaceToFloat64 converts the interfaces to the float64

func InterfaceToStr

func InterfaceToStr(v interface{}) (string, error)

InterfaceToStr converts the interfaces to the string

func IsByteColumn

func IsByteColumn(table, column string) bool

func IsLatin

func IsLatin(name string) bool

IsLatin checks if the specified string contains only latin character, digits and '-', '_'.

func IsValidAddress

func IsValidAddress(address string) bool

IsValidAddress checks if the specified address is apla address.

func NumString

func NumString(in string) string

NumString insert spaces between each three digits. 7123456 => 7 123 456

func ParseName

func ParseName(in string) (id int64, name string)

ParseName gets a state identifier and the name of the contract or table from the full name like @[id]name

func ParseTable

func ParseTable(tblname string, defaultEcosystem int64) string

func RSortMap

func RSortMap(m map[int64]string) []map[int64]string

RSortMap sorts map to the reversed slice of maps

func Round

func Round(num float64) int64

func RoundWithPrecision

func RoundWithPrecision(num float64, precision int) float64

RoundWithPrecision rounds float64 value

func RoundWithoutPrecision

func RoundWithoutPrecision(num float64) int64

RoundWithoutPrecision is round float64 without precision

func Sanitize

func Sanitize(name string, available string) string

Sanitize deletes unaccessable characters from input string

func SanitizeName

func SanitizeName(input string) string

SanitizeName deletes unaccessable characters from name string

func SanitizeNumber

func SanitizeNumber(input string) string

SanitizeNumber deletes unaccessable characters from number or name string

func SanitizeScript

func SanitizeScript(input string) string

SanitizeScript deletes unaccessable characters from input string

func SliceReverse

func SliceReverse(s []int64) []int64

SliceReverse reverses the slice of int64

func SortMap

func SortMap(m map[int64]string) []map[int64]string

SortMap sorts map to the slice of maps

func StrToFloat64

func StrToFloat64(s string) float64

StrToFloat64 converts string to float64

func StrToInt

func StrToInt(s string) int

StrToInt converts string to integer

func StrToInt64

func StrToInt64(s string) int64

StrToInt64 converts string to int64

func StrToMoney

func StrToMoney(str string) float64

StrToMoney rounds money string to float64

func StrToUint64

func StrToUint64(s string) uint64

StrToUint64 converts string to the unsinged int64

func StringToAddress

func StringToAddress(address string) (result int64)

StringToAddress converts string apla address to int64 address. The input address can be a positive or negative number, or apla address in XXXX-...-XXXX format. Returns 0 when error occurs.

func StripTags

func StripTags(value string) string

StripTags replaces < and > to &lt; and &gt;

func UInt32ToStr

func UInt32ToStr(num uint32) string

UInt32ToStr converts uint32 to string

func ValidateEmail

func ValidateEmail(email string) bool

ValidateEmail validates email

func ValueToInt

func ValueToInt(v interface{}) (ret int64, err error)

ValueToInt converts interface (string or int64) to int64

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL