go.uber.org/cadence@v1.2.9/internal/common/convert.go (about) 1 // Copyright (c) 2017 Uber Technologies, Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 package common 22 23 import ( 24 "math" 25 26 s "go.uber.org/cadence/.gen/go/shared" 27 ) 28 29 // Int32Ceil return the int32 ceil of a float64 30 func Int32Ceil(v float64) int32 { 31 return int32(math.Ceil(v)) 32 } 33 34 // Int64Ceil return the int64 ceil of a float64 35 func Int64Ceil(v float64) int64 { 36 return int64(math.Ceil(v)) 37 } 38 39 // Int32Ptr makes a copy and returns the pointer to an int32. 40 func Int32Ptr(v int32) *int32 { 41 return &v 42 } 43 44 // Float64Ptr makes a copy and returns the pointer to a float64. 45 func Float64Ptr(v float64) *float64 { 46 return &v 47 } 48 49 // Int64Ptr makes a copy and returns the pointer to an int64. 50 func Int64Ptr(v int64) *int64 { 51 return &v 52 } 53 54 // StringPtr makes a copy and returns the pointer to a string. 55 func StringPtr(v string) *string { 56 return &v 57 } 58 59 // BoolPtr makes a copy and returns the pointer to a string. 60 func BoolPtr(v bool) *bool { 61 return &v 62 } 63 64 // TaskListPtr makes a copy and returns the pointer to a TaskList. 65 func TaskListPtr(v s.TaskList) *s.TaskList { 66 return &v 67 } 68 69 // DecisionTypePtr makes a copy and returns the pointer to a DecisionType. 70 func DecisionTypePtr(t s.DecisionType) *s.DecisionType { 71 return &t 72 } 73 74 // EventTypePtr makes a copy and returns the pointer to a EventType. 75 func EventTypePtr(t s.EventType) *s.EventType { 76 return &t 77 } 78 79 // QueryTaskCompletedTypePtr makes a copy and returns the pointer to a QueryTaskCompletedType. 80 func QueryTaskCompletedTypePtr(t s.QueryTaskCompletedType) *s.QueryTaskCompletedType { 81 return &t 82 } 83 84 // TaskListKindPtr makes a copy and returns the pointer to a TaskListKind. 85 func TaskListKindPtr(t s.TaskListKind) *s.TaskListKind { 86 return &t 87 } 88 89 // QueryResultTypePtr makes a copy and returns the pointer to a QueryResultType. 90 func QueryResultTypePtr(t s.QueryResultType) *s.QueryResultType { 91 return &t 92 }