1 /** 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * SPDX-License-Identifier: Apache-2.0. 4 */ 5 6 #include <aws/cloudsearchdomain/model/QueryParser.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 CloudSearchDomain 17 { 18 namespace Model 19 { 20 namespace QueryParserMapper 21 { 22 23 static const int simple_HASH = HashingUtils::HashString("simple"); 24 static const int structured_HASH = HashingUtils::HashString("structured"); 25 static const int lucene_HASH = HashingUtils::HashString("lucene"); 26 static const int dismax_HASH = HashingUtils::HashString("dismax"); 27 28 GetQueryParserForName(const Aws::String & name)29 QueryParser GetQueryParserForName(const Aws::String& name) 30 { 31 int hashCode = HashingUtils::HashString(name.c_str()); 32 if (hashCode == simple_HASH) 33 { 34 return QueryParser::simple; 35 } 36 else if (hashCode == structured_HASH) 37 { 38 return QueryParser::structured; 39 } 40 else if (hashCode == lucene_HASH) 41 { 42 return QueryParser::lucene; 43 } 44 else if (hashCode == dismax_HASH) 45 { 46 return QueryParser::dismax; 47 } 48 EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); 49 if(overflowContainer) 50 { 51 overflowContainer->StoreOverflow(hashCode, name); 52 return static_cast<QueryParser>(hashCode); 53 } 54 55 return QueryParser::NOT_SET; 56 } 57 GetNameForQueryParser(QueryParser enumValue)58 Aws::String GetNameForQueryParser(QueryParser enumValue) 59 { 60 switch(enumValue) 61 { 62 case QueryParser::simple: 63 return "simple"; 64 case QueryParser::structured: 65 return "structured"; 66 case QueryParser::lucene: 67 return "lucene"; 68 case QueryParser::dismax: 69 return "dismax"; 70 default: 71 EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); 72 if(overflowContainer) 73 { 74 return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); 75 } 76 77 return {}; 78 } 79 } 80 81 } // namespace QueryParserMapper 82 } // namespace Model 83 } // namespace CloudSearchDomain 84 } // namespace Aws 85