mstr

package
v0.0.0-...-91c5940 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Charindex

func Charindex(s Mystr, rune_section_start int, findstr Mystr, findstr_rune_count_hint int, collator *collate.Collator) (pos_start int, pos_endx int, found_rune_index int)

Charindex return the rune index (returned found_rune_index is 1-based) of findstr. Returned values pos_start and pos_endx are 0-based. If findstr is not found, returns found_rune_index == 0, and pos_start == -1.

If you know the length in runes of findstr, pass it in findstr_rune_count_hint. Else, pass -1.

rune_section_start is 1-based. To start the search from the first character, pass 1 for this argument.

We could use package golang.org/x/text/search. TODO I must think about it.

func Compare

func Compare(a Mystr, b Mystr, collator *collate.Collator) int

Compare compares string a and b. The trailing blanks of a and b are skipped. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.

func Equal

func Equal(a Mystr, b Mystr, collator *collate.Collator) bool

Equal compares string a and b for equality.

It is the same code as Compare(), but with a quick path (byte comparison).
THIS FUNCTION IS NOT USED BECAUSE IN A SQL QUERY, MOST RESULT OF '=' RETURN FALSE, AND IN THIS CASE, THE SHORTCUT PATH IS JUST USELESS WORK.

The trailing blanks of a and b are skipped. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.

func Equal_strict

func Equal_strict(a Mystr, b Mystr) bool

Equal_strict compares two strings for equality, byte per byte. It is a strict comparison, because trailing blanks are not discarded.

func Starts_with

func Starts_with(s Mystr, prefix Mystr, prefix_rune_count_hint int, collator *collate.Collator) bool

Starts_with returns true if string starts with prefix.

If you know the rune count in prefix, pass it in prefix_rune_count_hint. Else, pass -1.

Types

type Mystr

type Mystr []byte

func Left

func Left(dest Mystr, s Mystr, rune_count int) (res Mystr)

Left writes rune_count runes from s, starting from left, into dest slice. If capacity of dest is not enough, a new storage array is allocated. The slice containing result is returned.

If not enough characters are available, a copy of s is returned.

func Map

func Map(dest Mystr, s Mystr, mapping func(r rune) rune) (res Mystr)

Map writes all runes of s, mapped with function 'mapping', into dest slice. If capacity of dest is not enough, a new storage array is allocated. The slice containing result is returned.

func Replace

func Replace(dest Mystr, s Mystr, findstr Mystr, replacement Mystr, collator *collate.Collator) (res Mystr)
func Right(dest Mystr, s Mystr, rune_count int) (res Mystr)

Right writes rune_count runes from s, starting from right, into dest slice. If capacity of dest is not enough, a new storage array is allocated. The slice containing result is returned.

If not enough characters are available, a copy of s is returned.

func Stuff

func Stuff(dest Mystr, s Mystr, rune_section_start int, rune_section_length int, replacement Mystr) (res_NULL_flag bool, res Mystr)

Stuff deletes section of string s which starts at rune_section_start (1-based) of length rune_section_length (in runes), and replaces it by replacement. If argument invalid, returned res_NULL_flag is true, meaning that the SQL result of the function must be NULL.

func Substring

func Substring(dest Mystr, s Mystr, rune_section_start int, rune_section_length int) (res Mystr)

func (*Mystr) Fit_to_precision_no_truncate

func (mystr *Mystr) Fit_to_precision_no_truncate(precision uint16) *rsql.Error

Fit_to_precision_no_truncate removes trailing spaces in excess, if rune count in mystr is larger than precision. If trailing characters in excess are not all spaces, an error is returned. Else, the function just returns.

func (*Mystr) Pad_or_truncate_to_precision

func (mystr *Mystr) Pad_or_truncate_to_precision(precision uint16)

func (*Mystr) Truncate_to_precision

func (mystr *Mystr) Truncate_to_precision(precision uint16)

Jump to

Keyboard shortcuts

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