| 1 | /* |
|---|---|
| 2 | * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | * You may not use this file except in compliance with the License. |
| 6 | * A copy of the License is located at |
| 7 | * |
| 8 | * http://aws.amazon.com/apache2.0 |
| 9 | * |
| 10 | * or in the "license" file accompanying this file. This file is distributed |
| 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | * express or implied. See the License for the specific language governing |
| 13 | * permissions and limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #include <aws/core/utils/EnumParseOverflowContainer.h> |
| 17 | #include <aws/core/utils/logging/LogMacros.h> |
| 18 | |
| 19 | using namespace Aws::Utils; |
| 20 | using namespace Aws::Utils::Threading; |
| 21 | |
| 22 | static const char LOG_TAG[] = "EnumParseOverflowContainer"; |
| 23 | |
| 24 | const Aws::String& EnumParseOverflowContainer::RetrieveOverflow(int hashCode) const |
| 25 | { |
| 26 | ReaderLockGuard guard(m_overflowLock); |
| 27 | auto foundIter = m_overflowMap.find(hashCode); |
| 28 | if (foundIter != m_overflowMap.end()) |
| 29 | { |
| 30 | AWS_LOGSTREAM_DEBUG(LOG_TAG, "Found value "<< foundIter->second << " for hash "<< hashCode << " from enum overflow container."); |
| 31 | return foundIter->second; |
| 32 | } |
| 33 | |
| 34 | AWS_LOGSTREAM_ERROR(LOG_TAG, "Could not find a previously stored overflow value for hash "<< hashCode << ". This will likely break some requests."); |
| 35 | return m_emptyString; |
| 36 | } |
| 37 | |
| 38 | void EnumParseOverflowContainer::StoreOverflow(int hashCode, const Aws::String& value) |
| 39 | { |
| 40 | WriterLockGuard guard(m_overflowLock); |
| 41 | AWS_LOGSTREAM_WARN(LOG_TAG, "Encountered enum member "<< value << " which is not modeled in your clients. You should update your clients when you get a chance."); |
| 42 | m_overflowMap[hashCode] = value; |
| 43 | } |
| 44 |