private_handle_accessor.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // Copyright 2020 The Abseil Authors.
  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. // You may obtain a copy of the License at
  7. //
  8. // https://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #ifndef ABSL_FLAGS_INTERNAL_PRIVATE_HANDLE_ACCESSOR_H_
  16. #define ABSL_FLAGS_INTERNAL_PRIVATE_HANDLE_ACCESSOR_H_
  17. #include <memory>
  18. #include <string>
  19. #include "absl/base/config.h"
  20. #include "absl/flags/commandlineflag.h"
  21. #include "absl/flags/internal/commandlineflag.h"
  22. #include "absl/strings/string_view.h"
  23. namespace absl {
  24. ABSL_NAMESPACE_BEGIN
  25. namespace flags_internal {
  26. // This class serves as a trampoline to access private methods of
  27. // CommandLineFlag. This class is intended for use exclusively internally inside
  28. // of the Abseil Flags implementation.
  29. class PrivateHandleAccessor {
  30. public:
  31. // Access to CommandLineFlag::TypeId.
  32. static FlagFastTypeId TypeId(const CommandLineFlag& flag);
  33. // Access to CommandLineFlag::SaveState.
  34. static std::unique_ptr<FlagStateInterface> SaveState(CommandLineFlag& flag);
  35. // Access to CommandLineFlag::IsSpecifiedOnCommandLine.
  36. static bool IsSpecifiedOnCommandLine(const CommandLineFlag& flag);
  37. // Access to CommandLineFlag::ValidateInputValue.
  38. static bool ValidateInputValue(const CommandLineFlag& flag,
  39. absl::string_view value);
  40. // Access to CommandLineFlag::CheckDefaultValueParsingRoundtrip.
  41. static void CheckDefaultValueParsingRoundtrip(const CommandLineFlag& flag);
  42. static bool ParseFrom(CommandLineFlag& flag, absl::string_view value,
  43. flags_internal::FlagSettingMode set_mode,
  44. flags_internal::ValueSource source, std::string& error);
  45. };
  46. } // namespace flags_internal
  47. ABSL_NAMESPACE_END
  48. } // namespace absl
  49. #endif // ABSL_FLAGS_INTERNAL_PRIVATE_HANDLE_ACCESSOR_H_