from_ptr.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. // Code generated by smithy-go/ptr/generate.go DO NOT EDIT.
  2. package ptr
  3. import (
  4. "time"
  5. )
  6. // ToBool returns bool value dereferenced if the passed
  7. // in pointer was not nil. Returns a bool zero value if the
  8. // pointer was nil.
  9. func ToBool(p *bool) (v bool) {
  10. if p == nil {
  11. return v
  12. }
  13. return *p
  14. }
  15. // ToBoolSlice returns a slice of bool values, that are
  16. // dereferenced if the passed in pointer was not nil. Returns a bool
  17. // zero value if the pointer was nil.
  18. func ToBoolSlice(vs []*bool) []bool {
  19. ps := make([]bool, len(vs))
  20. for i, v := range vs {
  21. ps[i] = ToBool(v)
  22. }
  23. return ps
  24. }
  25. // ToBoolMap returns a map of bool values, that are
  26. // dereferenced if the passed in pointer was not nil. The bool
  27. // zero value is used if the pointer was nil.
  28. func ToBoolMap(vs map[string]*bool) map[string]bool {
  29. ps := make(map[string]bool, len(vs))
  30. for k, v := range vs {
  31. ps[k] = ToBool(v)
  32. }
  33. return ps
  34. }
  35. // ToByte returns byte value dereferenced if the passed
  36. // in pointer was not nil. Returns a byte zero value if the
  37. // pointer was nil.
  38. func ToByte(p *byte) (v byte) {
  39. if p == nil {
  40. return v
  41. }
  42. return *p
  43. }
  44. // ToByteSlice returns a slice of byte values, that are
  45. // dereferenced if the passed in pointer was not nil. Returns a byte
  46. // zero value if the pointer was nil.
  47. func ToByteSlice(vs []*byte) []byte {
  48. ps := make([]byte, len(vs))
  49. for i, v := range vs {
  50. ps[i] = ToByte(v)
  51. }
  52. return ps
  53. }
  54. // ToByteMap returns a map of byte values, that are
  55. // dereferenced if the passed in pointer was not nil. The byte
  56. // zero value is used if the pointer was nil.
  57. func ToByteMap(vs map[string]*byte) map[string]byte {
  58. ps := make(map[string]byte, len(vs))
  59. for k, v := range vs {
  60. ps[k] = ToByte(v)
  61. }
  62. return ps
  63. }
  64. // ToString returns string value dereferenced if the passed
  65. // in pointer was not nil. Returns a string zero value if the
  66. // pointer was nil.
  67. func ToString(p *string) (v string) {
  68. if p == nil {
  69. return v
  70. }
  71. return *p
  72. }
  73. // ToStringSlice returns a slice of string values, that are
  74. // dereferenced if the passed in pointer was not nil. Returns a string
  75. // zero value if the pointer was nil.
  76. func ToStringSlice(vs []*string) []string {
  77. ps := make([]string, len(vs))
  78. for i, v := range vs {
  79. ps[i] = ToString(v)
  80. }
  81. return ps
  82. }
  83. // ToStringMap returns a map of string values, that are
  84. // dereferenced if the passed in pointer was not nil. The string
  85. // zero value is used if the pointer was nil.
  86. func ToStringMap(vs map[string]*string) map[string]string {
  87. ps := make(map[string]string, len(vs))
  88. for k, v := range vs {
  89. ps[k] = ToString(v)
  90. }
  91. return ps
  92. }
  93. // ToInt returns int value dereferenced if the passed
  94. // in pointer was not nil. Returns a int zero value if the
  95. // pointer was nil.
  96. func ToInt(p *int) (v int) {
  97. if p == nil {
  98. return v
  99. }
  100. return *p
  101. }
  102. // ToIntSlice returns a slice of int values, that are
  103. // dereferenced if the passed in pointer was not nil. Returns a int
  104. // zero value if the pointer was nil.
  105. func ToIntSlice(vs []*int) []int {
  106. ps := make([]int, len(vs))
  107. for i, v := range vs {
  108. ps[i] = ToInt(v)
  109. }
  110. return ps
  111. }
  112. // ToIntMap returns a map of int values, that are
  113. // dereferenced if the passed in pointer was not nil. The int
  114. // zero value is used if the pointer was nil.
  115. func ToIntMap(vs map[string]*int) map[string]int {
  116. ps := make(map[string]int, len(vs))
  117. for k, v := range vs {
  118. ps[k] = ToInt(v)
  119. }
  120. return ps
  121. }
  122. // ToInt8 returns int8 value dereferenced if the passed
  123. // in pointer was not nil. Returns a int8 zero value if the
  124. // pointer was nil.
  125. func ToInt8(p *int8) (v int8) {
  126. if p == nil {
  127. return v
  128. }
  129. return *p
  130. }
  131. // ToInt8Slice returns a slice of int8 values, that are
  132. // dereferenced if the passed in pointer was not nil. Returns a int8
  133. // zero value if the pointer was nil.
  134. func ToInt8Slice(vs []*int8) []int8 {
  135. ps := make([]int8, len(vs))
  136. for i, v := range vs {
  137. ps[i] = ToInt8(v)
  138. }
  139. return ps
  140. }
  141. // ToInt8Map returns a map of int8 values, that are
  142. // dereferenced if the passed in pointer was not nil. The int8
  143. // zero value is used if the pointer was nil.
  144. func ToInt8Map(vs map[string]*int8) map[string]int8 {
  145. ps := make(map[string]int8, len(vs))
  146. for k, v := range vs {
  147. ps[k] = ToInt8(v)
  148. }
  149. return ps
  150. }
  151. // ToInt16 returns int16 value dereferenced if the passed
  152. // in pointer was not nil. Returns a int16 zero value if the
  153. // pointer was nil.
  154. func ToInt16(p *int16) (v int16) {
  155. if p == nil {
  156. return v
  157. }
  158. return *p
  159. }
  160. // ToInt16Slice returns a slice of int16 values, that are
  161. // dereferenced if the passed in pointer was not nil. Returns a int16
  162. // zero value if the pointer was nil.
  163. func ToInt16Slice(vs []*int16) []int16 {
  164. ps := make([]int16, len(vs))
  165. for i, v := range vs {
  166. ps[i] = ToInt16(v)
  167. }
  168. return ps
  169. }
  170. // ToInt16Map returns a map of int16 values, that are
  171. // dereferenced if the passed in pointer was not nil. The int16
  172. // zero value is used if the pointer was nil.
  173. func ToInt16Map(vs map[string]*int16) map[string]int16 {
  174. ps := make(map[string]int16, len(vs))
  175. for k, v := range vs {
  176. ps[k] = ToInt16(v)
  177. }
  178. return ps
  179. }
  180. // ToInt32 returns int32 value dereferenced if the passed
  181. // in pointer was not nil. Returns a int32 zero value if the
  182. // pointer was nil.
  183. func ToInt32(p *int32) (v int32) {
  184. if p == nil {
  185. return v
  186. }
  187. return *p
  188. }
  189. // ToInt32Slice returns a slice of int32 values, that are
  190. // dereferenced if the passed in pointer was not nil. Returns a int32
  191. // zero value if the pointer was nil.
  192. func ToInt32Slice(vs []*int32) []int32 {
  193. ps := make([]int32, len(vs))
  194. for i, v := range vs {
  195. ps[i] = ToInt32(v)
  196. }
  197. return ps
  198. }
  199. // ToInt32Map returns a map of int32 values, that are
  200. // dereferenced if the passed in pointer was not nil. The int32
  201. // zero value is used if the pointer was nil.
  202. func ToInt32Map(vs map[string]*int32) map[string]int32 {
  203. ps := make(map[string]int32, len(vs))
  204. for k, v := range vs {
  205. ps[k] = ToInt32(v)
  206. }
  207. return ps
  208. }
  209. // ToInt64 returns int64 value dereferenced if the passed
  210. // in pointer was not nil. Returns a int64 zero value if the
  211. // pointer was nil.
  212. func ToInt64(p *int64) (v int64) {
  213. if p == nil {
  214. return v
  215. }
  216. return *p
  217. }
  218. // ToInt64Slice returns a slice of int64 values, that are
  219. // dereferenced if the passed in pointer was not nil. Returns a int64
  220. // zero value if the pointer was nil.
  221. func ToInt64Slice(vs []*int64) []int64 {
  222. ps := make([]int64, len(vs))
  223. for i, v := range vs {
  224. ps[i] = ToInt64(v)
  225. }
  226. return ps
  227. }
  228. // ToInt64Map returns a map of int64 values, that are
  229. // dereferenced if the passed in pointer was not nil. The int64
  230. // zero value is used if the pointer was nil.
  231. func ToInt64Map(vs map[string]*int64) map[string]int64 {
  232. ps := make(map[string]int64, len(vs))
  233. for k, v := range vs {
  234. ps[k] = ToInt64(v)
  235. }
  236. return ps
  237. }
  238. // ToUint returns uint value dereferenced if the passed
  239. // in pointer was not nil. Returns a uint zero value if the
  240. // pointer was nil.
  241. func ToUint(p *uint) (v uint) {
  242. if p == nil {
  243. return v
  244. }
  245. return *p
  246. }
  247. // ToUintSlice returns a slice of uint values, that are
  248. // dereferenced if the passed in pointer was not nil. Returns a uint
  249. // zero value if the pointer was nil.
  250. func ToUintSlice(vs []*uint) []uint {
  251. ps := make([]uint, len(vs))
  252. for i, v := range vs {
  253. ps[i] = ToUint(v)
  254. }
  255. return ps
  256. }
  257. // ToUintMap returns a map of uint values, that are
  258. // dereferenced if the passed in pointer was not nil. The uint
  259. // zero value is used if the pointer was nil.
  260. func ToUintMap(vs map[string]*uint) map[string]uint {
  261. ps := make(map[string]uint, len(vs))
  262. for k, v := range vs {
  263. ps[k] = ToUint(v)
  264. }
  265. return ps
  266. }
  267. // ToUint8 returns uint8 value dereferenced if the passed
  268. // in pointer was not nil. Returns a uint8 zero value if the
  269. // pointer was nil.
  270. func ToUint8(p *uint8) (v uint8) {
  271. if p == nil {
  272. return v
  273. }
  274. return *p
  275. }
  276. // ToUint8Slice returns a slice of uint8 values, that are
  277. // dereferenced if the passed in pointer was not nil. Returns a uint8
  278. // zero value if the pointer was nil.
  279. func ToUint8Slice(vs []*uint8) []uint8 {
  280. ps := make([]uint8, len(vs))
  281. for i, v := range vs {
  282. ps[i] = ToUint8(v)
  283. }
  284. return ps
  285. }
  286. // ToUint8Map returns a map of uint8 values, that are
  287. // dereferenced if the passed in pointer was not nil. The uint8
  288. // zero value is used if the pointer was nil.
  289. func ToUint8Map(vs map[string]*uint8) map[string]uint8 {
  290. ps := make(map[string]uint8, len(vs))
  291. for k, v := range vs {
  292. ps[k] = ToUint8(v)
  293. }
  294. return ps
  295. }
  296. // ToUint16 returns uint16 value dereferenced if the passed
  297. // in pointer was not nil. Returns a uint16 zero value if the
  298. // pointer was nil.
  299. func ToUint16(p *uint16) (v uint16) {
  300. if p == nil {
  301. return v
  302. }
  303. return *p
  304. }
  305. // ToUint16Slice returns a slice of uint16 values, that are
  306. // dereferenced if the passed in pointer was not nil. Returns a uint16
  307. // zero value if the pointer was nil.
  308. func ToUint16Slice(vs []*uint16) []uint16 {
  309. ps := make([]uint16, len(vs))
  310. for i, v := range vs {
  311. ps[i] = ToUint16(v)
  312. }
  313. return ps
  314. }
  315. // ToUint16Map returns a map of uint16 values, that are
  316. // dereferenced if the passed in pointer was not nil. The uint16
  317. // zero value is used if the pointer was nil.
  318. func ToUint16Map(vs map[string]*uint16) map[string]uint16 {
  319. ps := make(map[string]uint16, len(vs))
  320. for k, v := range vs {
  321. ps[k] = ToUint16(v)
  322. }
  323. return ps
  324. }
  325. // ToUint32 returns uint32 value dereferenced if the passed
  326. // in pointer was not nil. Returns a uint32 zero value if the
  327. // pointer was nil.
  328. func ToUint32(p *uint32) (v uint32) {
  329. if p == nil {
  330. return v
  331. }
  332. return *p
  333. }
  334. // ToUint32Slice returns a slice of uint32 values, that are
  335. // dereferenced if the passed in pointer was not nil. Returns a uint32
  336. // zero value if the pointer was nil.
  337. func ToUint32Slice(vs []*uint32) []uint32 {
  338. ps := make([]uint32, len(vs))
  339. for i, v := range vs {
  340. ps[i] = ToUint32(v)
  341. }
  342. return ps
  343. }
  344. // ToUint32Map returns a map of uint32 values, that are
  345. // dereferenced if the passed in pointer was not nil. The uint32
  346. // zero value is used if the pointer was nil.
  347. func ToUint32Map(vs map[string]*uint32) map[string]uint32 {
  348. ps := make(map[string]uint32, len(vs))
  349. for k, v := range vs {
  350. ps[k] = ToUint32(v)
  351. }
  352. return ps
  353. }
  354. // ToUint64 returns uint64 value dereferenced if the passed
  355. // in pointer was not nil. Returns a uint64 zero value if the
  356. // pointer was nil.
  357. func ToUint64(p *uint64) (v uint64) {
  358. if p == nil {
  359. return v
  360. }
  361. return *p
  362. }
  363. // ToUint64Slice returns a slice of uint64 values, that are
  364. // dereferenced if the passed in pointer was not nil. Returns a uint64
  365. // zero value if the pointer was nil.
  366. func ToUint64Slice(vs []*uint64) []uint64 {
  367. ps := make([]uint64, len(vs))
  368. for i, v := range vs {
  369. ps[i] = ToUint64(v)
  370. }
  371. return ps
  372. }
  373. // ToUint64Map returns a map of uint64 values, that are
  374. // dereferenced if the passed in pointer was not nil. The uint64
  375. // zero value is used if the pointer was nil.
  376. func ToUint64Map(vs map[string]*uint64) map[string]uint64 {
  377. ps := make(map[string]uint64, len(vs))
  378. for k, v := range vs {
  379. ps[k] = ToUint64(v)
  380. }
  381. return ps
  382. }
  383. // ToFloat32 returns float32 value dereferenced if the passed
  384. // in pointer was not nil. Returns a float32 zero value if the
  385. // pointer was nil.
  386. func ToFloat32(p *float32) (v float32) {
  387. if p == nil {
  388. return v
  389. }
  390. return *p
  391. }
  392. // ToFloat32Slice returns a slice of float32 values, that are
  393. // dereferenced if the passed in pointer was not nil. Returns a float32
  394. // zero value if the pointer was nil.
  395. func ToFloat32Slice(vs []*float32) []float32 {
  396. ps := make([]float32, len(vs))
  397. for i, v := range vs {
  398. ps[i] = ToFloat32(v)
  399. }
  400. return ps
  401. }
  402. // ToFloat32Map returns a map of float32 values, that are
  403. // dereferenced if the passed in pointer was not nil. The float32
  404. // zero value is used if the pointer was nil.
  405. func ToFloat32Map(vs map[string]*float32) map[string]float32 {
  406. ps := make(map[string]float32, len(vs))
  407. for k, v := range vs {
  408. ps[k] = ToFloat32(v)
  409. }
  410. return ps
  411. }
  412. // ToFloat64 returns float64 value dereferenced if the passed
  413. // in pointer was not nil. Returns a float64 zero value if the
  414. // pointer was nil.
  415. func ToFloat64(p *float64) (v float64) {
  416. if p == nil {
  417. return v
  418. }
  419. return *p
  420. }
  421. // ToFloat64Slice returns a slice of float64 values, that are
  422. // dereferenced if the passed in pointer was not nil. Returns a float64
  423. // zero value if the pointer was nil.
  424. func ToFloat64Slice(vs []*float64) []float64 {
  425. ps := make([]float64, len(vs))
  426. for i, v := range vs {
  427. ps[i] = ToFloat64(v)
  428. }
  429. return ps
  430. }
  431. // ToFloat64Map returns a map of float64 values, that are
  432. // dereferenced if the passed in pointer was not nil. The float64
  433. // zero value is used if the pointer was nil.
  434. func ToFloat64Map(vs map[string]*float64) map[string]float64 {
  435. ps := make(map[string]float64, len(vs))
  436. for k, v := range vs {
  437. ps[k] = ToFloat64(v)
  438. }
  439. return ps
  440. }
  441. // ToTime returns time.Time value dereferenced if the passed
  442. // in pointer was not nil. Returns a time.Time zero value if the
  443. // pointer was nil.
  444. func ToTime(p *time.Time) (v time.Time) {
  445. if p == nil {
  446. return v
  447. }
  448. return *p
  449. }
  450. // ToTimeSlice returns a slice of time.Time values, that are
  451. // dereferenced if the passed in pointer was not nil. Returns a time.Time
  452. // zero value if the pointer was nil.
  453. func ToTimeSlice(vs []*time.Time) []time.Time {
  454. ps := make([]time.Time, len(vs))
  455. for i, v := range vs {
  456. ps[i] = ToTime(v)
  457. }
  458. return ps
  459. }
  460. // ToTimeMap returns a map of time.Time values, that are
  461. // dereferenced if the passed in pointer was not nil. The time.Time
  462. // zero value is used if the pointer was nil.
  463. func ToTimeMap(vs map[string]*time.Time) map[string]time.Time {
  464. ps := make(map[string]time.Time, len(vs))
  465. for k, v := range vs {
  466. ps[k] = ToTime(v)
  467. }
  468. return ps
  469. }
  470. // ToDuration returns time.Duration value dereferenced if the passed
  471. // in pointer was not nil. Returns a time.Duration zero value if the
  472. // pointer was nil.
  473. func ToDuration(p *time.Duration) (v time.Duration) {
  474. if p == nil {
  475. return v
  476. }
  477. return *p
  478. }
  479. // ToDurationSlice returns a slice of time.Duration values, that are
  480. // dereferenced if the passed in pointer was not nil. Returns a time.Duration
  481. // zero value if the pointer was nil.
  482. func ToDurationSlice(vs []*time.Duration) []time.Duration {
  483. ps := make([]time.Duration, len(vs))
  484. for i, v := range vs {
  485. ps[i] = ToDuration(v)
  486. }
  487. return ps
  488. }
  489. // ToDurationMap returns a map of time.Duration values, that are
  490. // dereferenced if the passed in pointer was not nil. The time.Duration
  491. // zero value is used if the pointer was nil.
  492. func ToDurationMap(vs map[string]*time.Duration) map[string]time.Duration {
  493. ps := make(map[string]time.Duration, len(vs))
  494. for k, v := range vs {
  495. ps[k] = ToDuration(v)
  496. }
  497. return ps
  498. }