...

Source file src/github.com/aws/smithy-go/ptr/from_ptr.go

Documentation: github.com/aws/smithy-go/ptr

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

View as plain text