From cfec10564b5ba7af45edb44e0e69f38e7b60a00a Mon Sep 17 00:00:00 2001 From: Max Cherry Date: Thu, 19 Oct 2017 21:29:06 +0300 Subject: [PATCH] Ptr helpers for enum types --- ad_position.go | 5 +++++ connection_type.go | 5 +++++ no_bid_reason_code.go | 5 +++++ production_quality.go | 5 +++++ ptr.go | 12 ++++++++---- start_delay.go | 5 +++++ volume_normalization_mode.go | 5 +++++ 7 files changed, 38 insertions(+), 4 deletions(-) diff --git a/ad_position.go b/ad_position.go index 71d3d8a..e12e4ec 100644 --- a/ad_position.go +++ b/ad_position.go @@ -18,3 +18,8 @@ const ( AdPositionSidebar AdPosition = 6 // Sidebar AdPositionFullScreen AdPosition = 7 // Full Screen ) + +// PtrAdPosition returns pointer to passed argument. +func PtrAdPosition(p AdPosition) *AdPosition { + return &p +} diff --git a/connection_type.go b/connection_type.go index 3504fe5..cb433a9 100644 --- a/connection_type.go +++ b/connection_type.go @@ -14,3 +14,8 @@ const ( ConnectionTypeCellularNetwork3G ConnectionType = 5 // Cellular Network – 3G ConnectionTypeCellularNetwork4G ConnectionType = 6 // Cellular Network – 4G ) + +// PtrConnectionType returns pointer to passed argument. +func PtrConnectionType(t ConnectionType) *ConnectionType { + return &t +} diff --git a/no_bid_reason_code.go b/no_bid_reason_code.go index 0aa0328..95e8f83 100644 --- a/no_bid_reason_code.go +++ b/no_bid_reason_code.go @@ -18,3 +18,8 @@ const ( NoBidReasonCodeDailyReaderCapMet NoBidReasonCode = 9 // Daily Reader Cap Met NoBidReasonCodeDailyDomainCapMet NoBidReasonCode = 10 // Daily Domain Cap Met ) + +// PtrNoBidReasonCode returns pointer to passed argument. +func PtrNoBidReasonCode(c NoBidReasonCode) *NoBidReasonCode { + return &c +} diff --git a/production_quality.go b/production_quality.go index 1dd5bce..e2c0bdb 100644 --- a/production_quality.go +++ b/production_quality.go @@ -12,3 +12,8 @@ const ( ProductionQualityProsumer ProductionQuality = 2 // Prosumer ProductionQualityUserGenerated ProductionQuality = 3 // User Generated (UGC) ) + +// PtrProductionQuality returns pointer to passed argument. +func PtrProductionQuality(q ProductionQuality) *ProductionQuality { + return &q +} diff --git a/ptr.go b/ptr.go index a2577d4..d844cab 100644 --- a/ptr.go +++ b/ptr.go @@ -1,7 +1,11 @@ package openrtb -// PtrInt8 returns pointer to passed number argument. -func PtrInt8(n int8) *int8 { return &n } +// PtrInt8 returns pointer to passed argument. +func PtrInt8(n int8) *int8 { + return &n +} -// PtrUint64 returns pointer to passed number argument. -func PtrUint64(n uint64) *uint64 { return &n } +// PtrUint64 returns pointer to passed argument. +func PtrUint64(n uint64) *uint64 { + return &n +} diff --git a/start_delay.go b/start_delay.go index 6a81dfc..03ba444 100644 --- a/start_delay.go +++ b/start_delay.go @@ -13,3 +13,8 @@ const ( StartDelayGenericMidRoll StartDelay = -1 // Generic Mid-Roll StartDelayGenericPostRoll StartDelay = -2 // Generic Post-Roll ) + +// PtrStartDelay returns pointer to passed argument. +func PtrStartDelay(d StartDelay) *StartDelay { + return &d +} diff --git a/volume_normalization_mode.go b/volume_normalization_mode.go index cbfc93b..c6af09c 100644 --- a/volume_normalization_mode.go +++ b/volume_normalization_mode.go @@ -12,3 +12,8 @@ const ( VolumeNormalizationModeAdLoudnessNormalizedToContent VolumeNormalizationMode = 3 // Ad Loudness Normalized to Content VolumeNormalizationModeCustomVolumeNormalizationMode VolumeNormalizationMode = 4 // Custom Volume Normalization ) + +// PtrVolumeNormalizationMode returns pointer to passed argument. +func PtrVolumeNormalizationMode(m VolumeNormalizationMode) *VolumeNormalizationMode { + return &m +}