| 1 | // Copyright 2018 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/ |
| 16 | |
| 17 | import ( |
| 18 | "fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/" |
| 19 | "reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/" |
| 20 | "regexpscip-go gomod github.com/golang/go/src go1.23.0 regexp/" |
| 21 | "strconvscip-go gomod github.com/golang/go/src go1.23.0 strconv/" |
| 22 | "stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/" |
| 23 | "timescip-go gomod github.com/golang/go/src go1.23.0 time/" |
| 24 | |
| 25 | "github.com/google/cel-go/common/overloadsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/overloads`/" |
| 26 | "github.com/google/cel-go/common/types/refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/" |
| 27 | |
| 28 | anypbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/anypb`/ "google.golang.org/protobuf/types/known/anypbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/anypb`/" |
| 29 | structpbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/structpb`/ "google.golang.org/protobuf/types/known/structpbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/structpb`/" |
| 30 | wrapperspbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/wrapperspb`/ "google.golang.org/protobuf/types/known/wrapperspbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/wrapperspb`/" |
| 31 | ) |
| 32 | |
| 33 | // String type implementation which supports addition, comparison, matching, |
| 34 | // and size functions. |
| 35 | type Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String# string |
| 36 | |
| 37 | var ( |
| 38 | stringOneArgOverloadsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/stringOneArgOverloads. = map[string]func(refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#, refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#{ |
| 39 | overloadsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/overloads`/.Containsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/overloads`/Contains.: StringContainsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/StringContains()., |
| 40 | overloadsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/overloads`/.EndsWithscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/overloads`/EndsWith.: StringEndsWithscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/StringEndsWith()., |
| 41 | overloadsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/overloads`/.StartsWithscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/overloads`/StartsWith.: StringStartsWithscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/StringStartsWith()., |
| 42 | } |
| 43 | |
| 44 | stringWrapperTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/stringWrapperType. = reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.23.0 reflect/TypeOf().(&wrapperspbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/wrapperspb`/.StringValuescip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/wrapperspb`/StringValue#{}) |
| 45 | ) |
| 46 | |
| 47 | // Add implements traits.Adder.Add. |
| 48 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) Addscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Add().(other refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 49 | otherString, ok := other.(Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) |
| 50 | if !ok { |
| 51 | return MaybeNoSuchOverloadErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MaybeNoSuchOverloadErr().(other) |
| 52 | } |
| 53 | return s + otherString |
| 54 | } |
| 55 | |
| 56 | // Compare implements traits.Comparer.Compare. |
| 57 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) Comparescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Compare().(other refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 58 | otherString, ok := other.(Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) |
| 59 | if !ok { |
| 60 | return MaybeNoSuchOverloadErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MaybeNoSuchOverloadErr().(other) |
| 61 | } |
| 62 | return Intscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Int#(stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/.Comparescip-go gomod github.com/golang/go/src go1.23.0 strings/Compare().(s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string), otherString.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string))) |
| 63 | } |
| 64 | |
| 65 | // ConvertToNative implements ref.Val.ConvertToNative. |
| 66 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) ConvertToNativescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#ConvertToNative().(typeDesc reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/.Typescip-go gomod github.com/golang/go/src go1.23.0 reflect/Type#) (any, error) { |
| 67 | switch typeDesc.Kindscip-go gomod github.com/golang/go/src go1.23.0 reflect/Type#Kind().() { |
| 68 | case reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/.Stringscip-go gomod github.com/golang/go/src go1.23.0 reflect/String.: |
| 69 | return reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.23.0 reflect/ValueOf().(s).Convertscip-go gomod github.com/golang/go/src go1.23.0 reflect/Value#Convert().(typeDesc).Interfacescip-go gomod github.com/golang/go/src go1.23.0 reflect/Value#Interface().(), nil |
| 70 | case reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.23.0 reflect/Ptr.: |
| 71 | switch typeDesc { |
| 72 | case anyValueTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/anyValueType.: |
| 73 | // Primitives must be wrapped before being set on an Any field. |
| 74 | return anypbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/anypb`/.Newscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/anypb`/New().(wrapperspbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/wrapperspb`/.Stringscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/wrapperspb`/String().(string(s))) |
| 75 | case JSONValueTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/JSONValueType.: |
| 76 | // Convert to a protobuf representation of a JSON String. |
| 77 | return structpbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/structpb`/.NewStringValuescip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/structpb`/NewStringValue().(string(s)), nil |
| 78 | case stringWrapperTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/stringWrapperType.: |
| 79 | // Convert to a wrapperspb.StringValue. |
| 80 | return wrapperspbscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/wrapperspb`/.Stringscip-go gomod google.golang.org/protobuf v1.36.10 `google.golang.org/protobuf/types/known/wrapperspb`/String().(string(s)), nil |
| 81 | } |
| 82 | if typeDesc.Elemscip-go gomod github.com/golang/go/src go1.23.0 reflect/Type#Elem().().Kindscip-go gomod github.com/golang/go/src go1.23.0 reflect/Type#Kind().() == reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/.Stringscip-go gomod github.com/golang/go/src go1.23.0 reflect/String. { |
| 83 | p := s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string) |
| 84 | return &p, nil |
| 85 | } |
| 86 | case reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/.Interfacescip-go gomod github.com/golang/go/src go1.23.0 reflect/Interface.: |
| 87 | sv := s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().() |
| 88 | if reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.23.0 reflect/TypeOf().(sv).Implementsscip-go gomod github.com/golang/go/src go1.23.0 reflect/Type#Implements().(typeDesc) { |
| 89 | return sv, nil |
| 90 | } |
| 91 | if reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.23.0 reflect/TypeOf().(s).Implementsscip-go gomod github.com/golang/go/src go1.23.0 reflect/Type#Implements().(typeDesc) { |
| 92 | return s, nil |
| 93 | } |
| 94 | } |
| 95 | return nil, fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Errorf().( |
| 96 | "unsupported native conversion from string to '%v'", typeDesc) |
| 97 | } |
| 98 | |
| 99 | // ConvertToType implements ref.Val.ConvertToType. |
| 100 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) ConvertToTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#ConvertToType().(typeVal refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Typescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Type#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 101 | switch typeVal { |
| 102 | case IntTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/IntType.: |
| 103 | if n, err := strconvscip-go gomod github.com/golang/go/src go1.23.0 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.23.0 strconv/ParseInt().(s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string), 10, 64); err == nil { |
| 104 | return Intscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Int#(n) |
| 105 | } |
| 106 | case UintTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/UintType.: |
| 107 | if n, err := strconvscip-go gomod github.com/golang/go/src go1.23.0 strconv/.ParseUintscip-go gomod github.com/golang/go/src go1.23.0 strconv/ParseUint().(s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string), 10, 64); err == nil { |
| 108 | return Uintscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Uint#(n) |
| 109 | } |
| 110 | case DoubleTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/DoubleType.: |
| 111 | if n, err := strconvscip-go gomod github.com/golang/go/src go1.23.0 strconv/.ParseFloatscip-go gomod github.com/golang/go/src go1.23.0 strconv/ParseFloat().(s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string), 64); err == nil { |
| 112 | return Doublescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Double#(n) |
| 113 | } |
| 114 | case BoolTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/BoolType.: |
| 115 | if b, err := strconvscip-go gomod github.com/golang/go/src go1.23.0 strconv/.ParseBoolscip-go gomod github.com/golang/go/src go1.23.0 strconv/ParseBool().(s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string)); err == nil { |
| 116 | return Boolscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Bool#(b) |
| 117 | } |
| 118 | case BytesTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/BytesType.: |
| 119 | return Bytesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Bytes#(s) |
| 120 | case DurationTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/DurationType.: |
| 121 | if d, err := timescip-go gomod github.com/golang/go/src go1.23.0 time/.ParseDurationscip-go gomod github.com/golang/go/src go1.23.0 time/ParseDuration().(s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string)); err == nil { |
| 122 | return durationOfscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/durationOf().(d) |
| 123 | } |
| 124 | case TimestampTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/TimestampType.: |
| 125 | if t, err := timescip-go gomod github.com/golang/go/src go1.23.0 time/.Parsescip-go gomod github.com/golang/go/src go1.23.0 time/Parse().(timescip-go gomod github.com/golang/go/src go1.23.0 time/.RFC3339scip-go gomod github.com/golang/go/src go1.23.0 time/RFC3339., s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string)); err == nil { |
| 126 | if t.Unixscip-go gomod github.com/golang/go/src go1.23.0 time/Time#Unix().() < minUnixTimescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/minUnixTime. || t.Unixscip-go gomod github.com/golang/go/src go1.23.0 time/Time#Unix().() > maxUnixTimescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/maxUnixTime. { |
| 127 | return celErrTimestampOverflowscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/celErrTimestampOverflow. |
| 128 | } |
| 129 | return timestampOfscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/timestampOf().(t) |
| 130 | } |
| 131 | case StringTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/StringType.: |
| 132 | return s |
| 133 | case TypeTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/TypeType.: |
| 134 | return StringTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/StringType. |
| 135 | } |
| 136 | return NewErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/NewErr().("type conversion error from '%s' to '%s'", StringTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/StringType., typeVal) |
| 137 | } |
| 138 | |
| 139 | // Equal implements ref.Val.Equal. |
| 140 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) Equalscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Equal().(other refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 141 | otherString, ok := other.(Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) |
| 142 | return Boolscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Bool#(ok && s == otherString) |
| 143 | } |
| 144 | |
| 145 | // IsZeroValue returns true if the string is empty. |
| 146 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) IsZeroValuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#IsZeroValue().() bool { |
| 147 | return len(s) == 0 |
| 148 | } |
| 149 | |
| 150 | // Match implements traits.Matcher.Match. |
| 151 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) Matchscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Match().(pattern refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 152 | pat, ok := pattern.(Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) |
| 153 | if !ok { |
| 154 | return MaybeNoSuchOverloadErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MaybeNoSuchOverloadErr().(pattern) |
| 155 | } |
| 156 | matched, err := regexpscip-go gomod github.com/golang/go/src go1.23.0 regexp/.MatchStringscip-go gomod github.com/golang/go/src go1.23.0 regexp/MatchString().(pat.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string), s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string)) |
| 157 | if err != nil { |
| 158 | return &Errscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Err#{errorscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Err#error.: err} |
| 159 | } |
| 160 | return Boolscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Bool#(matched) |
| 161 | } |
| 162 | |
| 163 | // Receive implements traits.Receiver.Receive. |
| 164 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) Receivescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Receive().(function string, overload string, args []refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 165 | switch len(args) { |
| 166 | case 1: |
| 167 | if f, found := stringOneArgOverloadsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/stringOneArgOverloads.[function]; found { |
| 168 | return f(s, args[0]) |
| 169 | } |
| 170 | } |
| 171 | return NoSuchOverloadErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/NoSuchOverloadErr().() |
| 172 | } |
| 173 | |
| 174 | // Size implements traits.Sizer.Size. |
| 175 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) Sizescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Size().() refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 176 | return Intscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Int#(len([]rune(s.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().().(string)))) |
| 177 | } |
| 178 | |
| 179 | // Type implements ref.Val.Type. |
| 180 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) Typescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Type().() refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Typescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Type# { |
| 181 | return StringTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/StringType. |
| 182 | } |
| 183 | |
| 184 | // Value implements ref.Val.Value. |
| 185 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#Value().() any { |
| 186 | return string(s) |
| 187 | } |
| 188 | |
| 189 | func (s Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) formatscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#format().(sb *stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/.Builderscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#) { |
| 190 | sb.WriteStringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#WriteString().(strconvscip-go gomod github.com/golang/go/src go1.23.0 strconv/.Quotescip-go gomod github.com/golang/go/src go1.23.0 strconv/Quote().(string(s))) |
| 191 | } |
| 192 | |
| 193 | // StringContains returns whether the string contains a substring. |
| 194 | func StringContainsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/StringContains().(s, sub refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 195 | str, ok := s.(Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) |
| 196 | if !ok { |
| 197 | return MaybeNoSuchOverloadErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MaybeNoSuchOverloadErr().(s) |
| 198 | } |
| 199 | subStr, ok := sub.(Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) |
| 200 | if !ok { |
| 201 | return MaybeNoSuchOverloadErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MaybeNoSuchOverloadErr().(sub) |
| 202 | } |
| 203 | return Boolscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Bool#(stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.23.0 strings/Contains().(string(str), string(subStr))) |
| 204 | } |
| 205 | |
| 206 | // StringEndsWith returns whether the target string contains the input suffix. |
| 207 | func StringEndsWithscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/StringEndsWith().(s, suf refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 208 | str, ok := s.(Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) |
| 209 | if !ok { |
| 210 | return MaybeNoSuchOverloadErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MaybeNoSuchOverloadErr().(s) |
| 211 | } |
| 212 | sufStr, ok := suf.(Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) |
| 213 | if !ok { |
| 214 | return MaybeNoSuchOverloadErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MaybeNoSuchOverloadErr().(suf) |
| 215 | } |
| 216 | return Boolscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Bool#(stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.23.0 strings/HasSuffix().(string(str), string(sufStr))) |
| 217 | } |
| 218 | |
| 219 | // StringStartsWith returns whether the target string contains the input prefix. |
| 220 | func StringStartsWithscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/StringStartsWith().(s, pre refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 221 | str, ok := s.(Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) |
| 222 | if !ok { |
| 223 | return MaybeNoSuchOverloadErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MaybeNoSuchOverloadErr().(s) |
| 224 | } |
| 225 | preStr, ok := pre.(Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#) |
| 226 | if !ok { |
| 227 | return MaybeNoSuchOverloadErrscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MaybeNoSuchOverloadErr().(pre) |
| 228 | } |
| 229 | return Boolscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Bool#(stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.23.0 strings/HasPrefix().(string(str), string(preStr))) |
| 230 | } |