Exemple #1
0
func readValues(r io.Reader, fs queryFlagSet) ([][]byte, []string, error) {
	errResult := func(err error) ([][]byte, []string, error) {
		return [][]byte{}, []string{}, err
	}

	if !fs.Contains(qryValues) {
		return errResult(nil)
	}

	var numValues uint16
	if err := proto.ReadShort(r, &numValues); err != nil {
		return errResult(nil)
	}

	var err error
	names := make([]string, numValues)
	values := make([][]byte, numValues)

	for i := uint16(0); i < numValues; i++ {
		if fs.Contains(qryNames) {
			if names[i], err = proto.ReadString(r); err != nil {
				return errResult(err)
			}
		}

		if values[i], err = proto.ReadBytes(r); err != nil {
			return errResult(err)
		}
	}

	return values, names, nil
}
Exemple #2
0
func readPagingState(r io.Reader, fs queryFlagSet) ([]byte, error) {
	if !fs.Contains(qryPagingState) {
		return []byte{}, nil
	}
	return proto.ReadBytes(r)
}