ObjectCannedACL.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. * SPDX-License-Identifier: Apache-2.0.
  4. */
  5. #include <aws/s3/model/ObjectCannedACL.h>
  6. #include <aws/core/utils/HashingUtils.h>
  7. #include <aws/core/Globals.h>
  8. #include <aws/core/utils/EnumParseOverflowContainer.h>
  9. using namespace Aws::Utils;
  10. namespace Aws
  11. {
  12. namespace S3
  13. {
  14. namespace Model
  15. {
  16. namespace ObjectCannedACLMapper
  17. {
  18. static const int private__HASH = HashingUtils::HashString("private");
  19. static const int public_read_HASH = HashingUtils::HashString("public-read");
  20. static const int public_read_write_HASH = HashingUtils::HashString("public-read-write");
  21. static const int authenticated_read_HASH = HashingUtils::HashString("authenticated-read");
  22. static const int aws_exec_read_HASH = HashingUtils::HashString("aws-exec-read");
  23. static const int bucket_owner_read_HASH = HashingUtils::HashString("bucket-owner-read");
  24. static const int bucket_owner_full_control_HASH = HashingUtils::HashString("bucket-owner-full-control");
  25. ObjectCannedACL GetObjectCannedACLForName(const Aws::String& name)
  26. {
  27. int hashCode = HashingUtils::HashString(name.c_str());
  28. if (hashCode == private__HASH)
  29. {
  30. return ObjectCannedACL::private_;
  31. }
  32. else if (hashCode == public_read_HASH)
  33. {
  34. return ObjectCannedACL::public_read;
  35. }
  36. else if (hashCode == public_read_write_HASH)
  37. {
  38. return ObjectCannedACL::public_read_write;
  39. }
  40. else if (hashCode == authenticated_read_HASH)
  41. {
  42. return ObjectCannedACL::authenticated_read;
  43. }
  44. else if (hashCode == aws_exec_read_HASH)
  45. {
  46. return ObjectCannedACL::aws_exec_read;
  47. }
  48. else if (hashCode == bucket_owner_read_HASH)
  49. {
  50. return ObjectCannedACL::bucket_owner_read;
  51. }
  52. else if (hashCode == bucket_owner_full_control_HASH)
  53. {
  54. return ObjectCannedACL::bucket_owner_full_control;
  55. }
  56. EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
  57. if(overflowContainer)
  58. {
  59. overflowContainer->StoreOverflow(hashCode, name);
  60. return static_cast<ObjectCannedACL>(hashCode);
  61. }
  62. return ObjectCannedACL::NOT_SET;
  63. }
  64. Aws::String GetNameForObjectCannedACL(ObjectCannedACL enumValue)
  65. {
  66. switch(enumValue)
  67. {
  68. case ObjectCannedACL::private_:
  69. return "private";
  70. case ObjectCannedACL::public_read:
  71. return "public-read";
  72. case ObjectCannedACL::public_read_write:
  73. return "public-read-write";
  74. case ObjectCannedACL::authenticated_read:
  75. return "authenticated-read";
  76. case ObjectCannedACL::aws_exec_read:
  77. return "aws-exec-read";
  78. case ObjectCannedACL::bucket_owner_read:
  79. return "bucket-owner-read";
  80. case ObjectCannedACL::bucket_owner_full_control:
  81. return "bucket-owner-full-control";
  82. default:
  83. EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
  84. if(overflowContainer)
  85. {
  86. return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue));
  87. }
  88. return {};
  89. }
  90. }
  91. } // namespace ObjectCannedACLMapper
  92. } // namespace Model
  93. } // namespace S3
  94. } // namespace Aws