1 /** 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * SPDX-License-Identifier: Apache-2.0. 4 */ 5 6 #include <aws/elasticmapreduce/model/Unit.h> 7 #include <aws/core/utils/HashingUtils.h> 8 #include <aws/core/Globals.h> 9 #include <aws/core/utils/EnumParseOverflowContainer.h> 10 11 using namespace Aws::Utils; 12 13 14 namespace Aws 15 { 16 namespace EMR 17 { 18 namespace Model 19 { 20 namespace UnitMapper 21 { 22 23 static const int NONE_HASH = HashingUtils::HashString("NONE"); 24 static const int SECONDS_HASH = HashingUtils::HashString("SECONDS"); 25 static const int MICRO_SECONDS_HASH = HashingUtils::HashString("MICRO_SECONDS"); 26 static const int MILLI_SECONDS_HASH = HashingUtils::HashString("MILLI_SECONDS"); 27 static const int BYTES_HASH = HashingUtils::HashString("BYTES"); 28 static const int KILO_BYTES_HASH = HashingUtils::HashString("KILO_BYTES"); 29 static const int MEGA_BYTES_HASH = HashingUtils::HashString("MEGA_BYTES"); 30 static const int GIGA_BYTES_HASH = HashingUtils::HashString("GIGA_BYTES"); 31 static const int TERA_BYTES_HASH = HashingUtils::HashString("TERA_BYTES"); 32 static const int BITS_HASH = HashingUtils::HashString("BITS"); 33 static const int KILO_BITS_HASH = HashingUtils::HashString("KILO_BITS"); 34 static const int MEGA_BITS_HASH = HashingUtils::HashString("MEGA_BITS"); 35 static const int GIGA_BITS_HASH = HashingUtils::HashString("GIGA_BITS"); 36 static const int TERA_BITS_HASH = HashingUtils::HashString("TERA_BITS"); 37 static const int PERCENT_HASH = HashingUtils::HashString("PERCENT"); 38 static const int COUNT_HASH = HashingUtils::HashString("COUNT"); 39 static const int BYTES_PER_SECOND_HASH = HashingUtils::HashString("BYTES_PER_SECOND"); 40 static const int KILO_BYTES_PER_SECOND_HASH = HashingUtils::HashString("KILO_BYTES_PER_SECOND"); 41 static const int MEGA_BYTES_PER_SECOND_HASH = HashingUtils::HashString("MEGA_BYTES_PER_SECOND"); 42 static const int GIGA_BYTES_PER_SECOND_HASH = HashingUtils::HashString("GIGA_BYTES_PER_SECOND"); 43 static const int TERA_BYTES_PER_SECOND_HASH = HashingUtils::HashString("TERA_BYTES_PER_SECOND"); 44 static const int BITS_PER_SECOND_HASH = HashingUtils::HashString("BITS_PER_SECOND"); 45 static const int KILO_BITS_PER_SECOND_HASH = HashingUtils::HashString("KILO_BITS_PER_SECOND"); 46 static const int MEGA_BITS_PER_SECOND_HASH = HashingUtils::HashString("MEGA_BITS_PER_SECOND"); 47 static const int GIGA_BITS_PER_SECOND_HASH = HashingUtils::HashString("GIGA_BITS_PER_SECOND"); 48 static const int TERA_BITS_PER_SECOND_HASH = HashingUtils::HashString("TERA_BITS_PER_SECOND"); 49 static const int COUNT_PER_SECOND_HASH = HashingUtils::HashString("COUNT_PER_SECOND"); 50 51 GetUnitForName(const Aws::String & name)52 Unit GetUnitForName(const Aws::String& name) 53 { 54 int hashCode = HashingUtils::HashString(name.c_str()); 55 if (hashCode == NONE_HASH) 56 { 57 return Unit::NONE; 58 } 59 else if (hashCode == SECONDS_HASH) 60 { 61 return Unit::SECONDS; 62 } 63 else if (hashCode == MICRO_SECONDS_HASH) 64 { 65 return Unit::MICRO_SECONDS; 66 } 67 else if (hashCode == MILLI_SECONDS_HASH) 68 { 69 return Unit::MILLI_SECONDS; 70 } 71 else if (hashCode == BYTES_HASH) 72 { 73 return Unit::BYTES; 74 } 75 else if (hashCode == KILO_BYTES_HASH) 76 { 77 return Unit::KILO_BYTES; 78 } 79 else if (hashCode == MEGA_BYTES_HASH) 80 { 81 return Unit::MEGA_BYTES; 82 } 83 else if (hashCode == GIGA_BYTES_HASH) 84 { 85 return Unit::GIGA_BYTES; 86 } 87 else if (hashCode == TERA_BYTES_HASH) 88 { 89 return Unit::TERA_BYTES; 90 } 91 else if (hashCode == BITS_HASH) 92 { 93 return Unit::BITS; 94 } 95 else if (hashCode == KILO_BITS_HASH) 96 { 97 return Unit::KILO_BITS; 98 } 99 else if (hashCode == MEGA_BITS_HASH) 100 { 101 return Unit::MEGA_BITS; 102 } 103 else if (hashCode == GIGA_BITS_HASH) 104 { 105 return Unit::GIGA_BITS; 106 } 107 else if (hashCode == TERA_BITS_HASH) 108 { 109 return Unit::TERA_BITS; 110 } 111 else if (hashCode == PERCENT_HASH) 112 { 113 return Unit::PERCENT; 114 } 115 else if (hashCode == COUNT_HASH) 116 { 117 return Unit::COUNT; 118 } 119 else if (hashCode == BYTES_PER_SECOND_HASH) 120 { 121 return Unit::BYTES_PER_SECOND; 122 } 123 else if (hashCode == KILO_BYTES_PER_SECOND_HASH) 124 { 125 return Unit::KILO_BYTES_PER_SECOND; 126 } 127 else if (hashCode == MEGA_BYTES_PER_SECOND_HASH) 128 { 129 return Unit::MEGA_BYTES_PER_SECOND; 130 } 131 else if (hashCode == GIGA_BYTES_PER_SECOND_HASH) 132 { 133 return Unit::GIGA_BYTES_PER_SECOND; 134 } 135 else if (hashCode == TERA_BYTES_PER_SECOND_HASH) 136 { 137 return Unit::TERA_BYTES_PER_SECOND; 138 } 139 else if (hashCode == BITS_PER_SECOND_HASH) 140 { 141 return Unit::BITS_PER_SECOND; 142 } 143 else if (hashCode == KILO_BITS_PER_SECOND_HASH) 144 { 145 return Unit::KILO_BITS_PER_SECOND; 146 } 147 else if (hashCode == MEGA_BITS_PER_SECOND_HASH) 148 { 149 return Unit::MEGA_BITS_PER_SECOND; 150 } 151 else if (hashCode == GIGA_BITS_PER_SECOND_HASH) 152 { 153 return Unit::GIGA_BITS_PER_SECOND; 154 } 155 else if (hashCode == TERA_BITS_PER_SECOND_HASH) 156 { 157 return Unit::TERA_BITS_PER_SECOND; 158 } 159 else if (hashCode == COUNT_PER_SECOND_HASH) 160 { 161 return Unit::COUNT_PER_SECOND; 162 } 163 EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); 164 if(overflowContainer) 165 { 166 overflowContainer->StoreOverflow(hashCode, name); 167 return static_cast<Unit>(hashCode); 168 } 169 170 return Unit::NOT_SET; 171 } 172 GetNameForUnit(Unit enumValue)173 Aws::String GetNameForUnit(Unit enumValue) 174 { 175 switch(enumValue) 176 { 177 case Unit::NONE: 178 return "NONE"; 179 case Unit::SECONDS: 180 return "SECONDS"; 181 case Unit::MICRO_SECONDS: 182 return "MICRO_SECONDS"; 183 case Unit::MILLI_SECONDS: 184 return "MILLI_SECONDS"; 185 case Unit::BYTES: 186 return "BYTES"; 187 case Unit::KILO_BYTES: 188 return "KILO_BYTES"; 189 case Unit::MEGA_BYTES: 190 return "MEGA_BYTES"; 191 case Unit::GIGA_BYTES: 192 return "GIGA_BYTES"; 193 case Unit::TERA_BYTES: 194 return "TERA_BYTES"; 195 case Unit::BITS: 196 return "BITS"; 197 case Unit::KILO_BITS: 198 return "KILO_BITS"; 199 case Unit::MEGA_BITS: 200 return "MEGA_BITS"; 201 case Unit::GIGA_BITS: 202 return "GIGA_BITS"; 203 case Unit::TERA_BITS: 204 return "TERA_BITS"; 205 case Unit::PERCENT: 206 return "PERCENT"; 207 case Unit::COUNT: 208 return "COUNT"; 209 case Unit::BYTES_PER_SECOND: 210 return "BYTES_PER_SECOND"; 211 case Unit::KILO_BYTES_PER_SECOND: 212 return "KILO_BYTES_PER_SECOND"; 213 case Unit::MEGA_BYTES_PER_SECOND: 214 return "MEGA_BYTES_PER_SECOND"; 215 case Unit::GIGA_BYTES_PER_SECOND: 216 return "GIGA_BYTES_PER_SECOND"; 217 case Unit::TERA_BYTES_PER_SECOND: 218 return "TERA_BYTES_PER_SECOND"; 219 case Unit::BITS_PER_SECOND: 220 return "BITS_PER_SECOND"; 221 case Unit::KILO_BITS_PER_SECOND: 222 return "KILO_BITS_PER_SECOND"; 223 case Unit::MEGA_BITS_PER_SECOND: 224 return "MEGA_BITS_PER_SECOND"; 225 case Unit::GIGA_BITS_PER_SECOND: 226 return "GIGA_BITS_PER_SECOND"; 227 case Unit::TERA_BITS_PER_SECOND: 228 return "TERA_BITS_PER_SECOND"; 229 case Unit::COUNT_PER_SECOND: 230 return "COUNT_PER_SECOND"; 231 default: 232 EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); 233 if(overflowContainer) 234 { 235 return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); 236 } 237 238 return {}; 239 } 240 } 241 242 } // namespace UnitMapper 243 } // namespace Model 244 } // namespace EMR 245 } // namespace Aws 246